mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
function "write_quoted" rewritten more clearly.
This commit is contained in:
parent
8c1a9899d4
commit
c7e834f424
23
iolib.c
23
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user