diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-16 17:24:48 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-16 17:24:48 -0300 |
commit | 6c8e652aa6b5bf7018ff74473a6ef5bb58e4890e (patch) | |
tree | 343aabce9645ac52904ebdff4d5ab0727f360296 | |
parent | 9f25df02d53f6d31d904957bc411ef72d8378dc8 (diff) | |
download | lua-6c8e652aa6b5bf7018ff74473a6ef5bb58e4890e.tar.gz lua-6c8e652aa6b5bf7018ff74473a6ef5bb58e4890e.tar.bz2 lua-6c8e652aa6b5bf7018ff74473a6ef5bb58e4890e.zip |
use macros for 'getc'
-rw-r--r-- | ldo.c | 4 | ||||
-rw-r--r-- | liolib.c | 6 |
2 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.136 2001/06/08 19:00:57 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.137 2001/07/12 19:34:03 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -243,7 +243,7 @@ LUA_API int lua_loadfile (lua_State *L, const l_char *filename) { | |||
243 | int nlevel; /* level on the stack of filename */ | 243 | int nlevel; /* level on the stack of filename */ |
244 | FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); | 244 | FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); |
245 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ | 245 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ |
246 | bin = (ungetc(fgetc(f), f) == LUA_SIGNATURE[0]); | 246 | bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]); |
247 | if (bin && f != stdin) { | 247 | if (bin && f != stdin) { |
248 | fclose(f); | 248 | fclose(f); |
249 | f = fopen(filename, l_s("rb")); /* reopen in binary mode */ | 249 | f = fopen(filename, l_s("rb")); /* reopen in binary mode */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.118 2001/07/12 14:59:14 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.119 2001/07/12 18:11:58 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -237,7 +237,7 @@ static int read_until (lua_State *L, FILE *f, const l_char *p, int pl) { | |||
237 | luaL_buffinit(L, &b); | 237 | luaL_buffinit(L, &b); |
238 | prep_read_until(next, p, pl); | 238 | prep_read_until(next, p, pl); |
239 | j = 0; | 239 | j = 0; |
240 | while ((c = fgetc(f)) != EOF) { | 240 | while ((c = getc(f)) != EOF) { |
241 | NoRead: | 241 | NoRead: |
242 | if (c == p[j]) { | 242 | if (c == p[j]) { |
243 | j++; /* go to next char in pattern */ | 243 | j++; /* go to next char in pattern */ |
@@ -272,7 +272,7 @@ static int read_number (lua_State *L, FILE *f) { | |||
272 | 272 | ||
273 | 273 | ||
274 | static int test_eof (lua_State *L, FILE *f) { | 274 | static int test_eof (lua_State *L, FILE *f) { |
275 | l_charint c = fgetc(f); | 275 | l_charint c = getc(f); |
276 | ungetc(c, f); | 276 | ungetc(c, f); |
277 | lua_pushlstring(L, NULL, 0); | 277 | lua_pushlstring(L, NULL, 0); |
278 | return (c != EOF); | 278 | return (c != EOF); |