diff options
Diffstat (limited to '')
| -rw-r--r-- | iolib.c | 28 |
1 files changed, 20 insertions, 8 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Input/output library to LUA | 3 | ** Input/output library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_iolib="$Id: iolib.c,v 1.2 1993/12/30 14:52:18 roberto Exp celes $"; | 6 | char *rcs_iolib="$Id: iolib.c,v 1.3 1994/03/28 15:14:02 celes Exp celes $"; |
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -179,7 +179,7 @@ static void io_appendto (void) | |||
| 179 | static void io_read (void) | 179 | static void io_read (void) |
| 180 | { | 180 | { |
| 181 | lua_Object o = lua_getparam (1); | 181 | lua_Object o = lua_getparam (1); |
| 182 | if (o == NULL) /* free format */ | 182 | if (o == NULL || !lua_isstring(o)) /* free format */ |
| 183 | { | 183 | { |
| 184 | int c; | 184 | int c; |
| 185 | char s[256]; | 185 | char s[256]; |
| @@ -187,19 +187,31 @@ static void io_read (void) | |||
| 187 | ; | 187 | ; |
| 188 | if (c == '\"') | 188 | if (c == '\"') |
| 189 | { | 189 | { |
| 190 | if (fscanf (in, "%[^\"]\"", s) != 1) | 190 | int c, n=0; |
| 191 | while((c = fgetc(in)) != '\"') | ||
| 191 | { | 192 | { |
| 192 | lua_pushnil (); | 193 | if (c == EOF) |
| 193 | return; | 194 | { |
| 195 | lua_pushnil (); | ||
| 196 | return; | ||
| 197 | } | ||
| 198 | s[n++] = c; | ||
| 194 | } | 199 | } |
| 200 | s[n] = 0; | ||
| 195 | } | 201 | } |
| 196 | else if (c == '\'') | 202 | else if (c == '\'') |
| 197 | { | 203 | { |
| 198 | if (fscanf (in, "%[^\']\'", s) != 1) | 204 | int c, n=0; |
| 205 | while((c = fgetc(in)) != '\'') | ||
| 199 | { | 206 | { |
| 200 | lua_pushnil (); | 207 | if (c == EOF) |
| 201 | return; | 208 | { |
| 209 | lua_pushnil (); | ||
| 210 | return; | ||
| 211 | } | ||
| 212 | s[n++] = c; | ||
| 202 | } | 213 | } |
| 214 | s[n] = 0; | ||
| 203 | } | 215 | } |
| 204 | else | 216 | else |
| 205 | { | 217 | { |
