diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
commit | 72659a06050632da1a9b4c492302be46ac283f6b (patch) | |
tree | bac06b4ea523ba5443564d0869e392180d4b7b77 /ldo.c | |
parent | dfaf8c5291fa8aef5bedbfa375853475364ac76e (diff) | |
download | lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.gz lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.bz2 lua-72659a06050632da1a9b4c492302be46ac283f6b.zip |
no more explicit support for wide-chars; too much troble...
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.143 2001/10/17 21:12:57 roberto Exp $ | 2 | ** $Id: ldo.c,v 1.144 2001/11/27 20:56:47 roberto Exp $ |
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 | */ |
@@ -10,7 +10,6 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #define LUA_PRIVATE | ||
14 | #include "lua.h" | 13 | #include "lua.h" |
15 | 14 | ||
16 | #include "ldebug.h" | 15 | #include "ldebug.h" |
@@ -58,7 +57,7 @@ void luaD_stackerror (lua_State *L) { | |||
58 | else { | 57 | else { |
59 | L->stack_last += EXTRA_STACK; /* to be used by error message */ | 58 | L->stack_last += EXTRA_STACK; /* to be used by error message */ |
60 | lua_assert(L->stack_last == L->stack+L->stacksize-1); | 59 | lua_assert(L->stack_last == L->stack+L->stacksize-1); |
61 | luaD_error(L, l_s("stack overflow")); | 60 | luaD_error(L, "stack overflow"); |
62 | } | 61 | } |
63 | } | 62 | } |
64 | 63 | ||
@@ -99,7 +98,7 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) { | |||
99 | void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) { | 98 | void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) { |
100 | if (L->allowhooks) { | 99 | if (L->allowhooks) { |
101 | lua_Debug ar; | 100 | lua_Debug ar; |
102 | ar.event = l_s("line"); | 101 | ar.event = "line"; |
103 | ar._ci = L->ci; | 102 | ar._ci = L->ci; |
104 | ar.currentline = line; | 103 | ar.currentline = line; |
105 | dohook(L, &ar, linehook); | 104 | dohook(L, &ar, linehook); |
@@ -108,7 +107,7 @@ void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) { | |||
108 | 107 | ||
109 | 108 | ||
110 | static void luaD_callHook (lua_State *L, lua_Hook callhook, | 109 | static void luaD_callHook (lua_State *L, lua_Hook callhook, |
111 | const l_char *event) { | 110 | const char *event) { |
112 | if (L->allowhooks) { | 111 | if (L->allowhooks) { |
113 | lua_Debug ar; | 112 | lua_Debug ar; |
114 | ar.event = event; | 113 | ar.event = event; |
@@ -146,7 +145,7 @@ void luaD_call (lua_State *L, StkId func) { | |||
146 | /* `func' is not a function; check the `function' tag method */ | 145 | /* `func' is not a function; check the `function' tag method */ |
147 | Closure *tm = luaT_gettmbyObj(G(L), func, TM_FUNCTION); | 146 | Closure *tm = luaT_gettmbyObj(G(L), func, TM_FUNCTION); |
148 | if (tm == NULL) | 147 | if (tm == NULL) |
149 | luaG_typeerror(L, func, l_s("call")); | 148 | luaG_typeerror(L, func, "call"); |
150 | luaD_openstack(L, func); | 149 | luaD_openstack(L, func); |
151 | setclvalue(func, tm); /* tag method is the new function to be called */ | 150 | setclvalue(func, tm); /* tag method is the new function to be called */ |
152 | } | 151 | } |
@@ -155,12 +154,12 @@ void luaD_call (lua_State *L, StkId func) { | |||
155 | ci.base = func+1; | 154 | ci.base = func+1; |
156 | callhook = L->callhook; | 155 | callhook = L->callhook; |
157 | if (callhook) | 156 | if (callhook) |
158 | luaD_callHook(L, callhook, l_s("call")); | 157 | luaD_callHook(L, callhook, "call"); |
159 | firstResult = (clvalue(func)->c.isC ? | 158 | firstResult = (clvalue(func)->c.isC ? |
160 | callCclosure(L, &clvalue(func)->c) : | 159 | callCclosure(L, &clvalue(func)->c) : |
161 | luaV_execute(L, &clvalue(func)->l, func+1)); | 160 | luaV_execute(L, &clvalue(func)->l, func+1)); |
162 | if (callhook) /* same hook that was active at entry */ | 161 | if (callhook) /* same hook that was active at entry */ |
163 | luaD_callHook(L, callhook, l_s("return")); | 162 | luaD_callHook(L, callhook, "return"); |
164 | L->ci = ci.prev; /* unchain callinfo */ | 163 | L->ci = ci.prev; /* unchain callinfo */ |
165 | /* move results to `func' (to erase parameters and function) */ | 164 | /* move results to `func' (to erase parameters and function) */ |
166 | while (firstResult < L->top) | 165 | while (firstResult < L->top) |
@@ -245,21 +244,21 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) { | |||
245 | } | 244 | } |
246 | 245 | ||
247 | 246 | ||
248 | LUA_API int lua_loadfile (lua_State *L, const l_char *filename) { | 247 | LUA_API int lua_loadfile (lua_State *L, const char *filename) { |
249 | ZIO z; | 248 | ZIO z; |
250 | int status; | 249 | int status; |
251 | int bin; /* flag for file mode */ | 250 | int bin; /* flag for file mode */ |
252 | int nlevel; /* level on the stack of filename */ | 251 | int nlevel; /* level on the stack of filename */ |
253 | FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); | 252 | FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); |
254 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ | 253 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ |
255 | bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]); | 254 | bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]); |
256 | if (bin && f != stdin) { | 255 | if (bin && f != stdin) { |
257 | fclose(f); | 256 | fclose(f); |
258 | f = fopen(filename, l_s("rb")); /* reopen in binary mode */ | 257 | f = fopen(filename, "rb"); /* reopen in binary mode */ |
259 | if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ | 258 | if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ |
260 | } | 259 | } |
261 | lua_pushliteral(L, l_s("@")); | 260 | lua_pushliteral(L, "@"); |
262 | lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename); | 261 | lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); |
263 | lua_concat(L, 2); | 262 | lua_concat(L, 2); |
264 | nlevel = lua_gettop(L); | 263 | nlevel = lua_gettop(L); |
265 | filename = lua_tostring(L, -1); /* filename = `@'..filename */ | 264 | filename = lua_tostring(L, -1); /* filename = `@'..filename */ |
@@ -272,11 +271,11 @@ LUA_API int lua_loadfile (lua_State *L, const l_char *filename) { | |||
272 | } | 271 | } |
273 | 272 | ||
274 | 273 | ||
275 | LUA_API int lua_loadbuffer (lua_State *L, const l_char *buff, size_t size, | 274 | LUA_API int lua_loadbuffer (lua_State *L, const char *buff, size_t size, |
276 | const l_char *name) { | 275 | const char *name) { |
277 | ZIO z; | 276 | ZIO z; |
278 | int status; | 277 | int status; |
279 | if (!name) name = l_s("?"); | 278 | if (!name) name = "?"; |
280 | luaZ_mopen(&z, buff, size, name); | 279 | luaZ_mopen(&z, buff, size, name); |
281 | status = protectedparser(L, &z, buff[0]==LUA_SIGNATURE[0]); | 280 | status = protectedparser(L, &z, buff[0]==LUA_SIGNATURE[0]); |
282 | return status; | 281 | return status; |
@@ -301,9 +300,9 @@ struct lua_longjmp { | |||
301 | }; | 300 | }; |
302 | 301 | ||
303 | 302 | ||
304 | static void message (lua_State *L, const l_char *s) { | 303 | static void message (lua_State *L, const char *s) { |
305 | StkId top = L->top; | 304 | StkId top = L->top; |
306 | luaV_getglobal(L, luaS_newliteral(L, l_s(LUA_ERRORMESSAGE)), top); | 305 | luaV_getglobal(L, luaS_newliteral(L, LUA_ERRORMESSAGE), top); |
307 | if (ttype(top) == LUA_TFUNCTION) { | 306 | if (ttype(top) == LUA_TFUNCTION) { |
308 | incr_top; | 307 | incr_top; |
309 | setsvalue(top+1, luaS_new(L, s)); | 308 | setsvalue(top+1, luaS_new(L, s)); |
@@ -317,7 +316,7 @@ static void message (lua_State *L, const l_char *s) { | |||
317 | /* | 316 | /* |
318 | ** Reports an error, and jumps up to the available recovery label | 317 | ** Reports an error, and jumps up to the available recovery label |
319 | */ | 318 | */ |
320 | void luaD_error (lua_State *L, const l_char *s) { | 319 | void luaD_error (lua_State *L, const char *s) { |
321 | if (s) message(L, s); | 320 | if (s) message(L, s); |
322 | luaD_breakrun(L, LUA_ERRRUN); | 321 | luaD_breakrun(L, LUA_ERRRUN); |
323 | } | 322 | } |
@@ -330,7 +329,7 @@ void luaD_breakrun (lua_State *L, int errcode) { | |||
330 | } | 329 | } |
331 | else { | 330 | else { |
332 | if (errcode != LUA_ERRMEM) | 331 | if (errcode != LUA_ERRMEM) |
333 | message(L, l_s("unable to recover; exiting\n")); | 332 | message(L, "unable to recover; exiting\n"); |
334 | exit(EXIT_FAILURE); | 333 | exit(EXIT_FAILURE); |
335 | } | 334 | } |
336 | } | 335 | } |