mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
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.
This commit is contained in:
parent
44521b21e5
commit
cde6ab1782
28
iolib.c
28
iolib.c
@ -3,7 +3,7 @@
|
|||||||
** Input/output library to LUA
|
** 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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -179,7 +179,7 @@ static void io_appendto (void)
|
|||||||
static void io_read (void)
|
static void io_read (void)
|
||||||
{
|
{
|
||||||
lua_Object o = lua_getparam (1);
|
lua_Object o = lua_getparam (1);
|
||||||
if (o == NULL) /* free format */
|
if (o == NULL || !lua_isstring(o)) /* free format */
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char s[256];
|
char s[256];
|
||||||
@ -187,19 +187,31 @@ static void io_read (void)
|
|||||||
;
|
;
|
||||||
if (c == '\"')
|
if (c == '\"')
|
||||||
{
|
{
|
||||||
if (fscanf (in, "%[^\"]\"", s) != 1)
|
int c, n=0;
|
||||||
|
while((c = fgetc(in)) != '\"')
|
||||||
{
|
{
|
||||||
lua_pushnil ();
|
if (c == EOF)
|
||||||
return;
|
{
|
||||||
|
lua_pushnil ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s[n++] = c;
|
||||||
}
|
}
|
||||||
|
s[n] = 0;
|
||||||
}
|
}
|
||||||
else if (c == '\'')
|
else if (c == '\'')
|
||||||
{
|
{
|
||||||
if (fscanf (in, "%[^\']\'", s) != 1)
|
int c, n=0;
|
||||||
|
while((c = fgetc(in)) != '\'')
|
||||||
{
|
{
|
||||||
lua_pushnil ();
|
if (c == EOF)
|
||||||
return;
|
{
|
||||||
|
lua_pushnil ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s[n++] = c;
|
||||||
}
|
}
|
||||||
|
s[n] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user