From cde6ab178200cc4bb79c287ecf40a7508953933a Mon Sep 17 00:00:00 2001 From: Waldemar Celes Date: Mon, 25 Apr 1994 17:11:23 -0300 Subject: [PATCH] Correcao de erro na funcao read quando a variavel que especifica o formato nao era uma string e correcao do erro para ler strings entre aspas nula no formato livre. --- iolib.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/iolib.c b/iolib.c index f866fb3d..10d06f8c 100644 --- a/iolib.c +++ b/iolib.c @@ -3,7 +3,7 @@ ** Input/output library to LUA */ -char *rcs_iolib="$Id: iolib.c,v 1.2 1993/12/30 14:52:18 roberto Exp celes $"; +char *rcs_iolib="$Id: iolib.c,v 1.3 1994/03/28 15:14:02 celes Exp celes $"; #include #include @@ -179,7 +179,7 @@ static void io_appendto (void) static void io_read (void) { lua_Object o = lua_getparam (1); - if (o == NULL) /* free format */ + if (o == NULL || !lua_isstring(o)) /* free format */ { int c; char s[256]; @@ -187,19 +187,31 @@ static void io_read (void) ; if (c == '\"') { - if (fscanf (in, "%[^\"]\"", s) != 1) + int c, n=0; + while((c = fgetc(in)) != '\"') { - lua_pushnil (); - return; + if (c == EOF) + { + lua_pushnil (); + return; + } + s[n++] = c; } + s[n] = 0; } else if (c == '\'') { - if (fscanf (in, "%[^\']\'", s) != 1) + int c, n=0; + while((c = fgetc(in)) != '\'') { - lua_pushnil (); - return; + if (c == EOF) + { + lua_pushnil (); + return; + } + s[n++] = c; } + s[n] = 0; } else {