diff options
-rw-r--r-- | lstate.c | 4 | ||||
-rw-r--r-- | lstate.h | 6 | ||||
-rw-r--r-- | lua.c | 4 | ||||
-rw-r--r-- | lzio.c | 22 |
4 files changed, 16 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.30 2005/04/05 15:57:59 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.31 2005/05/05 15:34:03 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -83,7 +83,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
83 | 83 | ||
84 | 84 | ||
85 | static void preinit_state (lua_State *L, global_State *g) { | 85 | static void preinit_state (lua_State *L, global_State *g) { |
86 | L->l_G = g; | 86 | G(L) = g; |
87 | L->stack = NULL; | 87 | L->stack = NULL; |
88 | L->stacksize = 0; | 88 | L->stacksize = 0; |
89 | L->errorJmp = NULL; | 89 | L->errorJmp = NULL; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.20 2005/04/25 19:24:10 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.21 2005/05/05 15:34:03 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -101,7 +101,7 @@ struct lua_State { | |||
101 | CommonHeader; | 101 | CommonHeader; |
102 | StkId top; /* first free slot in the stack */ | 102 | StkId top; /* first free slot in the stack */ |
103 | StkId base; /* base of current function */ | 103 | StkId base; /* base of current function */ |
104 | global_State *l_G; | 104 | global_State *_G; |
105 | CallInfo *ci; /* call info for current function */ | 105 | CallInfo *ci; /* call info for current function */ |
106 | const Instruction *savedpc; /* `savedpc' of current function */ | 106 | const Instruction *savedpc; /* `savedpc' of current function */ |
107 | StkId stack_last; /* last free slot in the stack */ | 107 | StkId stack_last; /* last free slot in the stack */ |
@@ -126,7 +126,7 @@ struct lua_State { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | 128 | ||
129 | #define G(L) (L->l_G) | 129 | #define G(L) (L->_G) |
130 | 130 | ||
131 | 131 | ||
132 | /* | 132 | /* |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.143 2005/05/16 21:19:00 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.144 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -149,7 +149,7 @@ static const char *get_prompt (lua_State *L, int firstline) { | |||
149 | 149 | ||
150 | static int incomplete (lua_State *L, int status) { | 150 | static int incomplete (lua_State *L, int status) { |
151 | if (status == LUA_ERRSYNTAX && | 151 | if (status == LUA_ERRSYNTAX && |
152 | strstr(lua_tostring(L, -1), "<eof>") != NULL) { | 152 | strstr(lua_tostring(L, -1), LUA_QL("<eof>")) != NULL) { |
153 | lua_pop(L, 1); | 153 | lua_pop(L, 1); |
154 | return 1; | 154 | return 1; |
155 | } | 155 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.c,v 1.29 2004/04/30 20:13:38 roberto Exp roberto $ | 2 | ** $Id: lzio.c,v 1.30 2005/05/17 19:49:15 roberto Exp roberto $ |
3 | ** a generic input stream interface | 3 | ** a generic input stream interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,10 +34,12 @@ int luaZ_fill (ZIO *z) { | |||
34 | 34 | ||
35 | int luaZ_lookahead (ZIO *z) { | 35 | int luaZ_lookahead (ZIO *z) { |
36 | if (z->n == 0) { | 36 | if (z->n == 0) { |
37 | int c = luaZ_fill(z); | 37 | if (luaZ_fill(z) == EOZ) |
38 | if (c == EOZ) return c; | 38 | return EOZ; |
39 | z->n++; | 39 | else { |
40 | z->p--; | 40 | z->n++; /* luaZ_fill removed first byte; put back it */ |
41 | z->p--; | ||
42 | } | ||
41 | } | 43 | } |
42 | return char2int(*z->p); | 44 | return char2int(*z->p); |
43 | } | 45 | } |
@@ -56,14 +58,8 @@ void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { | |||
56 | size_t luaZ_read (ZIO *z, void *b, size_t n) { | 58 | size_t luaZ_read (ZIO *z, void *b, size_t n) { |
57 | while (n) { | 59 | while (n) { |
58 | size_t m; | 60 | size_t m; |
59 | if (z->n == 0) { | 61 | if (luaZ_lookahead(z) == EOZ) |
60 | if (luaZ_fill(z) == EOZ) | 62 | return n; /* return number of missing bytes */ |
61 | return n; /* return number of missing bytes */ | ||
62 | else { | ||
63 | ++z->n; /* filbuf removed first byte; put back it */ | ||
64 | --z->p; | ||
65 | } | ||
66 | } | ||
67 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ | 63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ |
68 | memcpy(b, z->p, m); | 64 | memcpy(b, z->p, m); |
69 | z->n -= m; | 65 | z->n -= m; |