aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iolib.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/iolib.c b/iolib.c
index 2d805010..fbb36634 100644
--- a/iolib.c
+++ b/iolib.c
@@ -3,7 +3,7 @@
3** Input/output library to LUA 3** Input/output library to LUA
4*/ 4*/
5 5
6char *rcs_iolib="$Id: iolib.c,v 1.35 1996/02/09 19:35:23 roberto Exp roberto $"; 6char *rcs_iolib="$Id: iolib.c,v 1.36 1996/02/16 13:10:14 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <ctype.h> 9#include <ctype.h>
@@ -373,24 +373,15 @@ static int write_string (char *s, int just, int m)
373 373
374static int write_quoted (int just, int m) 374static int write_quoted (int just, int m)
375{ 375{
376 char *s = lua_check_string(1, "write"); 376 char *s;
377 luaI_addchar(0); 377 luaI_addchar(0);
378 luaI_addchar('"'); 378 luaI_addchar('"');
379 while (1) 379 for (s = lua_check_string(1, "write"); *s; s++)
380 { 380 {
381 switch (*s) 381 if (*s == '"' || *s == '\\' || *s == '\n')
382 { 382 luaI_addchar('\\');
383 case '"': case '\\': case '\n': 383 luaI_addchar(*s);
384 luaI_addchar('\\'); 384 }
385 luaI_addchar(*s);
386 break;
387 case 0:
388 goto END_WHILE;
389 default:
390 luaI_addchar(*s);
391 }
392 s++;
393 } END_WHILE:
394 luaI_addchar('"'); 385 luaI_addchar('"');
395 return write_string(luaI_addchar(0), just, m); 386 return write_string(luaI_addchar(0), just, m);
396} 387}