mirror of https://github.com/rusefi/lua.git
small improvement
This commit is contained in:
parent
e33d7bae45
commit
eca9fa02d2
4
lstate.c
4
lstate.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstate.c,v 2.30 2005/04/05 15:57:59 roberto Exp roberto $
|
** $Id: lstate.c,v 2.31 2005/05/05 15:34:03 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +83,7 @@ static void f_luaopen (lua_State *L, void *ud) {
|
||||||
|
|
||||||
|
|
||||||
static void preinit_state (lua_State *L, global_State *g) {
|
static void preinit_state (lua_State *L, global_State *g) {
|
||||||
L->l_G = g;
|
G(L) = g;
|
||||||
L->stack = NULL;
|
L->stack = NULL;
|
||||||
L->stacksize = 0;
|
L->stacksize = 0;
|
||||||
L->errorJmp = NULL;
|
L->errorJmp = NULL;
|
||||||
|
|
6
lstate.h
6
lstate.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 2.20 2005/04/25 19:24:10 roberto Exp roberto $
|
** $Id: lstate.h,v 2.21 2005/05/05 15:34:03 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -101,7 +101,7 @@ struct lua_State {
|
||||||
CommonHeader;
|
CommonHeader;
|
||||||
StkId top; /* first free slot in the stack */
|
StkId top; /* first free slot in the stack */
|
||||||
StkId base; /* base of current function */
|
StkId base; /* base of current function */
|
||||||
global_State *l_G;
|
global_State *_G;
|
||||||
CallInfo *ci; /* call info for current function */
|
CallInfo *ci; /* call info for current function */
|
||||||
const Instruction *savedpc; /* `savedpc' of current function */
|
const Instruction *savedpc; /* `savedpc' of current function */
|
||||||
StkId stack_last; /* last free slot in the stack */
|
StkId stack_last; /* last free slot in the stack */
|
||||||
|
@ -126,7 +126,7 @@ struct lua_State {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define G(L) (L->l_G)
|
#define G(L) (L->_G)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
4
lua.c
4
lua.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.143 2005/05/16 21:19:00 roberto Exp roberto $
|
** $Id: lua.c,v 1.144 2005/05/17 19:49:15 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +149,7 @@ static const char *get_prompt (lua_State *L, int firstline) {
|
||||||
|
|
||||||
static int incomplete (lua_State *L, int status) {
|
static int incomplete (lua_State *L, int status) {
|
||||||
if (status == LUA_ERRSYNTAX &&
|
if (status == LUA_ERRSYNTAX &&
|
||||||
strstr(lua_tostring(L, -1), "<eof>") != NULL) {
|
strstr(lua_tostring(L, -1), LUA_QL("<eof>")) != NULL) {
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
22
lzio.c
22
lzio.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lzio.c,v 1.29 2004/04/30 20:13:38 roberto Exp roberto $
|
** $Id: lzio.c,v 1.30 2005/05/17 19:49:15 roberto Exp roberto $
|
||||||
** a generic input stream interface
|
** a generic input stream interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -34,10 +34,12 @@ int luaZ_fill (ZIO *z) {
|
||||||
|
|
||||||
int luaZ_lookahead (ZIO *z) {
|
int luaZ_lookahead (ZIO *z) {
|
||||||
if (z->n == 0) {
|
if (z->n == 0) {
|
||||||
int c = luaZ_fill(z);
|
if (luaZ_fill(z) == EOZ)
|
||||||
if (c == EOZ) return c;
|
return EOZ;
|
||||||
z->n++;
|
else {
|
||||||
z->p--;
|
z->n++; /* luaZ_fill removed first byte; put back it */
|
||||||
|
z->p--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return char2int(*z->p);
|
return char2int(*z->p);
|
||||||
}
|
}
|
||||||
|
@ -56,14 +58,8 @@ void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
|
||||||
size_t luaZ_read (ZIO *z, void *b, size_t n) {
|
size_t luaZ_read (ZIO *z, void *b, size_t n) {
|
||||||
while (n) {
|
while (n) {
|
||||||
size_t m;
|
size_t m;
|
||||||
if (z->n == 0) {
|
if (luaZ_lookahead(z) == EOZ)
|
||||||
if (luaZ_fill(z) == EOZ)
|
return n; /* return number of missing bytes */
|
||||||
return n; /* return number of missing bytes */
|
|
||||||
else {
|
|
||||||
++z->n; /* filbuf removed first byte; put back it */
|
|
||||||
--z->p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
|
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
|
||||||
memcpy(b, z->p, m);
|
memcpy(b, z->p, m);
|
||||||
z->n -= m;
|
z->n -= m;
|
||||||
|
|
Loading…
Reference in New Issue