commit c7e834f424f97f3b300cda931e607c37612cd2a4
parent 8c1a9899d4460aa19780919f4245c08d7ebba0e9
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 22 Feb 1996 17:56:13 -0300
function "write_quoted" rewritten more clearly.
Diffstat:
M | iolib.c | | | 23 | +++++++---------------- |
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git 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);
}