From c7e834f424f97f3b300cda931e607c37612cd2a4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> Date: Thu, 22 Feb 1996 17:56:33 -0300 Subject: function "write_quoted" rewritten more clearly. --- iolib.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'iolib.c') diff --git a/iolib.c b/iolib.c index 2d805010..fbb36634 100644 --- a/iolib.c +++ b/iolib.c @@ -3,7 +3,7 @@ ** Input/output library to LUA */ -char *rcs_iolib="$Id: iolib.c,v 1.35 1996/02/09 19:35:23 roberto Exp roberto $"; +char *rcs_iolib="$Id: iolib.c,v 1.36 1996/02/16 13:10:14 roberto Exp roberto $"; #include <stdio.h> #include <ctype.h> @@ -373,24 +373,15 @@ static int write_string (char *s, int just, int m) static int write_quoted (int just, int m) { - char *s = lua_check_string(1, "write"); + char *s; luaI_addchar(0); luaI_addchar('"'); - while (1) + for (s = lua_check_string(1, "write"); *s; s++) { - switch (*s) - { - case '"': case '\\': case '\n': - luaI_addchar('\\'); - luaI_addchar(*s); - break; - case 0: - goto END_WHILE; - default: - luaI_addchar(*s); - } - s++; - } END_WHILE: + if (*s == '"' || *s == '\\' || *s == '\n') + luaI_addchar('\\'); + luaI_addchar(*s); + } luaI_addchar('"'); return write_string(luaI_addchar(0), just, m); } -- cgit v1.2.3-55-g6feb