mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
use macros for 'getc'
This commit is contained in:
parent
9f25df02d5
commit
6c8e652aa6
4
ldo.c
4
ldo.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.136 2001/06/08 19:00:57 roberto Exp roberto $
|
** $Id: ldo.c,v 1.137 2001/07/12 19:34:03 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -243,7 +243,7 @@ LUA_API int lua_loadfile (lua_State *L, const l_char *filename) {
|
|||||||
int nlevel; /* level on the stack of filename */
|
int nlevel; /* level on the stack of filename */
|
||||||
FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r"));
|
FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r"));
|
||||||
if (f == NULL) return LUA_ERRFILE; /* unable to open file */
|
if (f == NULL) return LUA_ERRFILE; /* unable to open file */
|
||||||
bin = (ungetc(fgetc(f), f) == LUA_SIGNATURE[0]);
|
bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
|
||||||
if (bin && f != stdin) {
|
if (bin && f != stdin) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
f = fopen(filename, l_s("rb")); /* reopen in binary mode */
|
f = fopen(filename, l_s("rb")); /* reopen in binary mode */
|
||||||
|
6
liolib.c
6
liolib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 1.118 2001/07/12 14:59:14 roberto Exp roberto $
|
** $Id: liolib.c,v 1.119 2001/07/12 18:11:58 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -237,7 +237,7 @@ static int read_until (lua_State *L, FILE *f, const l_char *p, int pl) {
|
|||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
prep_read_until(next, p, pl);
|
prep_read_until(next, p, pl);
|
||||||
j = 0;
|
j = 0;
|
||||||
while ((c = fgetc(f)) != EOF) {
|
while ((c = getc(f)) != EOF) {
|
||||||
NoRead:
|
NoRead:
|
||||||
if (c == p[j]) {
|
if (c == p[j]) {
|
||||||
j++; /* go to next char in pattern */
|
j++; /* go to next char in pattern */
|
||||||
@ -272,7 +272,7 @@ static int read_number (lua_State *L, FILE *f) {
|
|||||||
|
|
||||||
|
|
||||||
static int test_eof (lua_State *L, FILE *f) {
|
static int test_eof (lua_State *L, FILE *f) {
|
||||||
l_charint c = fgetc(f);
|
l_charint c = getc(f);
|
||||||
ungetc(c, f);
|
ungetc(c, f);
|
||||||
lua_pushlstring(L, NULL, 0);
|
lua_pushlstring(L, NULL, 0);
|
||||||
return (c != EOF);
|
return (c != EOF);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user