diff options
-rw-r--r-- | lapi.c | 7 | ||||
-rw-r--r-- | lauxlib.c | 3 | ||||
-rw-r--r-- | lbaselib.c | 83 | ||||
-rw-r--r-- | lcode.c | 3 | ||||
-rw-r--r-- | ldblib.c | 3 | ||||
-rw-r--r-- | ldebug.c | 3 | ||||
-rw-r--r-- | ldo.c | 5 | ||||
-rw-r--r-- | lfunc.c | 3 | ||||
-rw-r--r-- | lgc.c | 3 | ||||
-rw-r--r-- | liolib.c | 12 | ||||
-rw-r--r-- | llex.c | 3 | ||||
-rw-r--r-- | llimits.h | 33 | ||||
-rw-r--r-- | lmathlib.c | 3 | ||||
-rw-r--r-- | lmem.c | 3 | ||||
-rw-r--r-- | lobject.c | 5 | ||||
-rw-r--r-- | lparser.c | 3 | ||||
-rw-r--r-- | lstate.c | 3 | ||||
-rw-r--r-- | lstring.c | 3 | ||||
-rw-r--r-- | lstrlib.c | 3 | ||||
-rw-r--r-- | ltable.c | 3 | ||||
-rw-r--r-- | ltests.c | 3 | ||||
-rw-r--r-- | ltm.c | 3 | ||||
-rw-r--r-- | lua.c | 5 | ||||
-rw-r--r-- | lua.h | 69 | ||||
-rw-r--r-- | lualib.h | 27 | ||||
-rw-r--r-- | lundump.c | 12 | ||||
-rw-r--r-- | lundump.h | 6 | ||||
-rw-r--r-- | lvm.c | 5 | ||||
-rw-r--r-- | lzio.c | 8 | ||||
-rw-r--r-- | lzio.h | 3 |
30 files changed, 208 insertions, 120 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.135 2001/03/02 17:27:50 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.136 2001/03/07 18:09:25 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "lapi.h" | 13 | #include "lapi.h" |
@@ -22,8 +23,8 @@ | |||
22 | #include "lvm.h" | 23 | #include "lvm.h" |
23 | 24 | ||
24 | 25 | ||
25 | const l_char lua_ident[] = l_s("$Lua: ") LUA_VERSION l_s(" ") | 26 | const l_char lua_ident[] = l_s("$Lua: ") l_s(LUA_VERSION) l_s(" ") |
26 | LUA_COPYRIGHT l_s(" $\n") l_s("$Authors: ") LUA_AUTHORS l_s(" $"); | 27 | l_s(LUA_COPYRIGHT) l_s(" $\n") l_s("$Authors: ") l_s(LUA_AUTHORS) l_s(" $"); |
27 | 28 | ||
28 | 29 | ||
29 | 30 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.47 2001/02/14 17:04:11 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.48 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -14,6 +14,7 @@ | |||
14 | ** With care, these functions can be used by other libraries. | 14 | ** With care, these functions can be used by other libraries. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LUA_PRIVATE | ||
17 | #include "lua.h" | 18 | #include "lua.h" |
18 | 19 | ||
19 | #include "lauxlib.h" | 20 | #include "lauxlib.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.29 2001/03/06 20:09:38 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.30 2001/03/07 12:43:52 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -11,6 +11,7 @@ | |||
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <string.h> | 12 | #include <string.h> |
13 | 13 | ||
14 | #define LUA_PRIVATE | ||
14 | #include "lua.h" | 15 | #include "lua.h" |
15 | 16 | ||
16 | #include "lauxlib.h" | 17 | #include "lauxlib.h" |
@@ -42,7 +43,7 @@ static int luaB__ALERT (lua_State *L) { | |||
42 | */ | 43 | */ |
43 | static int luaB__ERRORMESSAGE (lua_State *L) { | 44 | static int luaB__ERRORMESSAGE (lua_State *L) { |
44 | luaL_checktype(L, 1, LUA_TSTRING); | 45 | luaL_checktype(L, 1, LUA_TSTRING); |
45 | lua_getglobal(L, LUA_ALERT); | 46 | lua_getglobal(L, l_s(LUA_ALERT)); |
46 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ | 47 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ |
47 | lua_Debug ar; | 48 | lua_Debug ar; |
48 | lua_pushliteral(L, l_s("error: ")); | 49 | lua_pushliteral(L, l_s("error: ")); |
@@ -303,6 +304,68 @@ static int luaB_dofile (lua_State *L) { | |||
303 | } | 304 | } |
304 | 305 | ||
305 | 306 | ||
307 | #define LUA_PATH l_s("LUA_PATH") | ||
308 | |||
309 | #define LUA_PATH_SEP l_s(";") | ||
310 | |||
311 | #ifndef LUA_PATH_DEFAULT | ||
312 | #define LUA_PATH_DEFAULT l_s("./") | ||
313 | #endif | ||
314 | |||
315 | static int luaB_require (lua_State *L) { | ||
316 | const l_char *path; | ||
317 | luaL_check_string(L, 1); | ||
318 | lua_settop(L, 1); | ||
319 | lua_getglobal(L, LUA_PATH); /* get path */ | ||
320 | if (lua_isstring(L, 2)) /* is LUA_PATH defined? */ | ||
321 | path = lua_tostring(L, 2); | ||
322 | else { /* LUA_PATH not defined */ | ||
323 | lua_pop(L, 1); /* pop old global value */ | ||
324 | path = getenv(LUA_PATH); /* try environment variable */ | ||
325 | if (path == NULL) path = LUA_PATH_DEFAULT; /* else use default */ | ||
326 | lua_pushstring(L, path); | ||
327 | lua_pushvalue(L, -1); /* duplicate to leave a copy on stack */ | ||
328 | lua_setglobal(L, LUA_PATH); | ||
329 | } | ||
330 | lua_getregistry(L); | ||
331 | lua_pushliteral(L, LUA_PATH); | ||
332 | lua_gettable(L, 3); /* get book-keeping table */ | ||
333 | if (lua_isnil(L, 4)) { /* no book-keeping table? */ | ||
334 | lua_pop(L, 1); /* pop the `nil' */ | ||
335 | lua_newtable(L); /* create book-keeping table */ | ||
336 | lua_pushliteral(L, LUA_PATH); | ||
337 | lua_pushvalue(L, -2); /* duplicate table to leave a copy on stack */ | ||
338 | lua_settable(L, 3); /* store book-keeping table in registry */ | ||
339 | } | ||
340 | lua_pushvalue(L, 1); | ||
341 | lua_gettable(L, 4); /* check package's name in book-keeping table */ | ||
342 | if (!lua_isnil(L, -1)) /* is it there? */ | ||
343 | return 0; /* package is already loaded */ | ||
344 | else { /* must load it */ | ||
345 | for (;;) { /* traverse path */ | ||
346 | int res; | ||
347 | int l = strcspn(path, LUA_PATH_SEP); /* find separator */ | ||
348 | lua_pushlstring(L, path, l); /* directory name */ | ||
349 | lua_pushvalue(L, 1); /* package name */ | ||
350 | lua_concat(L, 2); /* concat directory with package name */ | ||
351 | res = lua_dofile(L, lua_tostring(L, -1)); /* try to load it */ | ||
352 | lua_settop(L, 4); /* pop string and eventual results from dofile */ | ||
353 | if (res == 0) break; /* ok; file done */ | ||
354 | else if (res != LUA_ERRFILE) | ||
355 | lua_error(L, NULL); /* error running package; propagate it */ | ||
356 | if (*(path+l) == l_c('\0')) /* no more directories? */ | ||
357 | luaL_verror(L, l_s("could not load package `%.20s' from path `%.200s'"), | ||
358 | lua_tostring(L, 1), lua_tostring(L, 2)); | ||
359 | path += l+1; /* try next directory */ | ||
360 | } | ||
361 | } | ||
362 | lua_pushvalue(L, 1); | ||
363 | lua_pushnumber(L, 1); | ||
364 | lua_settable(L, 4); /* mark it as loaded */ | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | |||
306 | static int luaB_pack (lua_State *L) { | 369 | static int luaB_pack (lua_State *L) { |
307 | int n = lua_gettop(L); | 370 | int n = lua_gettop(L); |
308 | lua_newtable(L); | 371 | lua_newtable(L); |
@@ -337,10 +400,10 @@ static int luaB_call (lua_State *L) { | |||
337 | int status; | 400 | int status; |
338 | int n; | 401 | int n; |
339 | if (!lua_isnull(L, 4)) { /* set new error method */ | 402 | if (!lua_isnull(L, 4)) { /* set new error method */ |
340 | lua_getglobal(L, LUA_ERRORMESSAGE); | 403 | lua_getglobal(L, l_s(LUA_ERRORMESSAGE)); |
341 | err = lua_gettop(L); /* get index */ | 404 | err = lua_gettop(L); /* get index */ |
342 | lua_pushvalue(L, 4); | 405 | lua_pushvalue(L, 4); |
343 | lua_setglobal(L, LUA_ERRORMESSAGE); | 406 | lua_setglobal(L, l_s(LUA_ERRORMESSAGE)); |
344 | } | 407 | } |
345 | oldtop = lua_gettop(L); /* top before function-call preparation */ | 408 | oldtop = lua_gettop(L); /* top before function-call preparation */ |
346 | /* push function */ | 409 | /* push function */ |
@@ -349,7 +412,7 @@ static int luaB_call (lua_State *L) { | |||
349 | status = lua_call(L, n, LUA_MULTRET); | 412 | status = lua_call(L, n, LUA_MULTRET); |
350 | if (err != 0) { /* restore old error method */ | 413 | if (err != 0) { /* restore old error method */ |
351 | lua_pushvalue(L, err); | 414 | lua_pushvalue(L, err); |
352 | lua_setglobal(L, LUA_ERRORMESSAGE); | 415 | lua_setglobal(L, l_s(LUA_ERRORMESSAGE)); |
353 | } | 416 | } |
354 | if (status != 0) { /* error in call? */ | 417 | if (status != 0) { /* error in call? */ |
355 | if (strchr(options, l_c('x'))) | 418 | if (strchr(options, l_c('x'))) |
@@ -382,7 +445,8 @@ static int luaB_tostring (lua_State *L) { | |||
382 | case LUA_TUSERDATA: { | 445 | case LUA_TUSERDATA: { |
383 | const l_char *t = lua_xtype(L, 1); | 446 | const l_char *t = lua_xtype(L, 1); |
384 | if (strcmp(t, l_s("userdata")) == 0) | 447 | if (strcmp(t, l_s("userdata")) == 0) |
385 | sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1), lua_touserdata(L, 1)); | 448 | sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1), |
449 | lua_touserdata(L, 1)); | ||
386 | else | 450 | else |
387 | sprintf(buff, l_s("%.40s: %p"), t, lua_touserdata(L, 1)); | 451 | sprintf(buff, l_s("%.40s: %p"), t, lua_touserdata(L, 1)); |
388 | break; | 452 | break; |
@@ -663,8 +727,8 @@ static void deprecated_funcs (lua_State *L) { | |||
663 | /* }====================================================== */ | 727 | /* }====================================================== */ |
664 | 728 | ||
665 | static const luaL_reg base_funcs[] = { | 729 | static const luaL_reg base_funcs[] = { |
666 | {LUA_ALERT, luaB__ALERT}, | 730 | {l_s(LUA_ALERT), luaB__ALERT}, |
667 | {LUA_ERRORMESSAGE, luaB__ERRORMESSAGE}, | 731 | {l_s(LUA_ERRORMESSAGE), luaB__ERRORMESSAGE}, |
668 | {l_s("call"), luaB_call}, | 732 | {l_s("call"), luaB_call}, |
669 | {l_s("collectgarbage"), luaB_collectgarbage}, | 733 | {l_s("collectgarbage"), luaB_collectgarbage}, |
670 | {l_s("copytagmethods"), luaB_copytagmethods}, | 734 | {l_s("copytagmethods"), luaB_copytagmethods}, |
@@ -685,6 +749,7 @@ static const luaL_reg base_funcs[] = { | |||
685 | {l_s("rawset"), luaB_rawset}, | 749 | {l_s("rawset"), luaB_rawset}, |
686 | {l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */ | 750 | {l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */ |
687 | {l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */ | 751 | {l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */ |
752 | {l_s("require"), luaB_require}, | ||
688 | {l_s("setglobal"), luaB_setglobal}, | 753 | {l_s("setglobal"), luaB_setglobal}, |
689 | {l_s("settag"), luaB_settag}, | 754 | {l_s("settag"), luaB_settag}, |
690 | {l_s("settagmethod"), luaB_settagmethod}, | 755 | {l_s("settagmethod"), luaB_settagmethod}, |
@@ -706,7 +771,7 @@ static const luaL_reg base_funcs[] = { | |||
706 | 771 | ||
707 | LUALIB_API int lua_baselibopen (lua_State *L) { | 772 | LUALIB_API int lua_baselibopen (lua_State *L) { |
708 | luaL_openl(L, base_funcs); | 773 | luaL_openl(L, base_funcs); |
709 | lua_pushliteral(L, LUA_VERSION); | 774 | lua_pushliteral(L, l_s(LUA_VERSION)); |
710 | lua_setglobal(L, l_s("_VERSION")); | 775 | lua_setglobal(L, l_s("_VERSION")); |
711 | deprecated_funcs(L); | 776 | deprecated_funcs(L); |
712 | return 0; | 777 | return 0; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.64 2001/02/23 20:28:19 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.65 2001/03/07 13:22:55 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "lcode.h" | 13 | #include "lcode.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.34 2001/03/06 20:09:38 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.35 2001/03/07 18:09:25 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | 11 | ||
12 | #define LUA_PRIVATE | ||
12 | #include "lua.h" | 13 | #include "lua.h" |
13 | 14 | ||
14 | #include "lauxlib.h" | 15 | #include "lauxlib.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.73 2001/03/07 13:22:55 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.74 2001/03/07 18:09:25 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "lapi.h" | 13 | #include "lapi.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.130 2001/03/02 17:27:50 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.131 2001/03/07 18:09:25 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 | */ |
@@ -10,6 +10,7 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #define LUA_PRIVATE | ||
13 | #include "lua.h" | 14 | #include "lua.h" |
14 | 15 | ||
15 | #include "ldebug.h" | 16 | #include "ldebug.h" |
@@ -328,7 +329,7 @@ struct lua_longjmp { | |||
328 | 329 | ||
329 | 330 | ||
330 | static void message (lua_State *L, const l_char *s) { | 331 | static void message (lua_State *L, const l_char *s) { |
331 | luaV_getglobal(L, luaS_newliteral(L, LUA_ERRORMESSAGE), L->top); | 332 | luaV_getglobal(L, luaS_newliteral(L, l_s(LUA_ERRORMESSAGE)), L->top); |
332 | if (ttype(L->top) == LUA_TFUNCTION) { | 333 | if (ttype(L->top) == LUA_TFUNCTION) { |
333 | incr_top; | 334 | incr_top; |
334 | setsvalue(L->top, luaS_new(L, s)); | 335 | setsvalue(L->top, luaS_new(L, s)); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 1.41 2001/02/20 18:28:11 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.42 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "lfunc.h" | 13 | #include "lfunc.h" |
@@ -1,9 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.93 2001/03/02 17:27:50 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.94 2001/03/07 18:09:25 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #define LUA_PRIVATE | ||
7 | #include "lua.h" | 8 | #include "lua.h" |
8 | 9 | ||
9 | #include "ldo.h" | 10 | #include "ldo.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.109 2001/02/23 17:28:12 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.110 2001/03/06 20:09:38 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 | */ |
@@ -11,6 +11,7 @@ | |||
11 | #include <string.h> | 11 | #include <string.h> |
12 | #include <time.h> | 12 | #include <time.h> |
13 | 13 | ||
14 | #define LUA_PRIVATE | ||
14 | #include "lua.h" | 15 | #include "lua.h" |
15 | 16 | ||
16 | #include "lauxlib.h" | 17 | #include "lauxlib.h" |
@@ -353,9 +354,10 @@ static int io_write (lua_State *L) { | |||
353 | int arg; | 354 | int arg; |
354 | int status = 1; | 355 | int status = 1; |
355 | for (arg=1; arg<=nargs; arg++) { | 356 | for (arg=1; arg<=nargs; arg++) { |
356 | if (lua_type(L, arg) == LUA_TNUMBER) { /* LUA_NUMBER */ | 357 | if (lua_type(L, arg) == LUA_TNUMBER) { |
357 | /* optimization: could be done exactly as for strings */ | 358 | /* optimization: could be done exactly as for strings */ |
358 | status = status && fprintf(f, l_s("%.16g"), lua_tonumber(L, arg)) > 0; | 359 | status = status && |
360 | fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0; | ||
359 | } | 361 | } |
360 | else { | 362 | else { |
361 | size_t l; | 363 | size_t l; |
@@ -638,7 +640,7 @@ static int errorfb (lua_State *L) { | |||
638 | luaL_addstring(&b, l_s("\n")); | 640 | luaL_addstring(&b, l_s("\n")); |
639 | } | 641 | } |
640 | luaL_pushresult(&b); | 642 | luaL_pushresult(&b); |
641 | lua_getglobal(L, LUA_ALERT); | 643 | lua_getglobal(L, l_s(LUA_ALERT)); |
642 | if (lua_isfunction(L, -1)) { /* avoid loop if _ALERT is not defined */ | 644 | if (lua_isfunction(L, -1)) { /* avoid loop if _ALERT is not defined */ |
643 | lua_pushvalue(L, -2); /* error message */ | 645 | lua_pushvalue(L, -2); /* error message */ |
644 | lua_rawcall(L, 1, 0); | 646 | lua_rawcall(L, 1, 0); |
@@ -671,7 +673,7 @@ static const luaL_reg iolib[] = { | |||
671 | {l_s("tmpname"), io_tmpname}, | 673 | {l_s("tmpname"), io_tmpname}, |
672 | {l_s("write"), io_write}, | 674 | {l_s("write"), io_write}, |
673 | {l_s("writeto"), io_writeto}, | 675 | {l_s("writeto"), io_writeto}, |
674 | {LUA_ERRORMESSAGE, errorfb} | 676 | {l_s(LUA_ERRORMESSAGE), errorfb} |
675 | }; | 677 | }; |
676 | 678 | ||
677 | 679 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 1.82 2001/03/06 14:46:54 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 1.83 2001/03/07 12:49:37 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | 11 | ||
12 | #define LUA_PRIVATE | ||
12 | #include "lua.h" | 13 | #include "lua.h" |
13 | 14 | ||
14 | #include "llex.h" | 15 | #include "llex.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.26 2001/02/23 17:28:12 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.27 2001/02/23 20:28:56 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -33,31 +33,6 @@ | |||
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | 35 | ||
36 | /* function to convert a lua_Number to a string */ | ||
37 | #ifndef NUMBER_FMT | ||
38 | #define NUMBER_FMT l_s("%.16g") /* LUA_NUMBER */ | ||
39 | #endif | ||
40 | #ifndef lua_number2str | ||
41 | #define lua_number2str(s,n) sprintf((s), NUMBER_FMT, (n)) | ||
42 | #endif | ||
43 | |||
44 | /* function to convert a string to a lua_Number */ | ||
45 | #ifndef lua_str2number | ||
46 | #define lua_str2number(s,p) strtod((s), (p)) | ||
47 | #endif | ||
48 | |||
49 | |||
50 | /* macro to control type of literal strings */ | ||
51 | #ifndef l_s | ||
52 | #define l_s(x) x | ||
53 | #endif | ||
54 | |||
55 | /* macro to control type of literal chars */ | ||
56 | #ifndef l_c | ||
57 | #define l_c(x) x | ||
58 | #endif | ||
59 | |||
60 | |||
61 | /* | 36 | /* |
62 | ** the following types define integer types for values that may not | 37 | ** the following types define integer types for values that may not |
63 | ** fit in a `small int' (16 bits), but may waste space in a | 38 | ** fit in a `small int' (16 bits), but may waste space in a |
@@ -81,12 +56,6 @@ typedef long ls_nstr; | |||
81 | typedef unsigned char lu_byte; | 56 | typedef unsigned char lu_byte; |
82 | 57 | ||
83 | 58 | ||
84 | /* macro to `unsign' a character */ | ||
85 | #ifndef uchar | ||
86 | #define uchar(c) ((unsigned char)(c)) | ||
87 | #endif | ||
88 | |||
89 | |||
90 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) | 59 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) |
91 | 60 | ||
92 | 61 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.36 2001/02/23 17:17:25 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.37 2001/03/06 20:09:38 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,6 +8,7 @@ | |||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <math.h> | 9 | #include <math.h> |
10 | 10 | ||
11 | #define LUA_PRIVATE | ||
11 | #include "lua.h" | 12 | #include "lua.h" |
12 | 13 | ||
13 | #include "lauxlib.h" | 14 | #include "lauxlib.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.c,v 1.47 2001/02/20 18:15:33 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.48 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "ldo.h" | 13 | #include "ldo.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.68 2001/02/23 20:30:01 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.69 2001/03/07 12:27:06 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -10,6 +10,7 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #define LUA_PRIVATE | ||
13 | #include "lua.h" | 14 | #include "lua.h" |
14 | 15 | ||
15 | #include "ldo.h" | 16 | #include "ldo.h" |
@@ -44,7 +45,7 @@ void *luaO_openspaceaux (lua_State *L, size_t n) { | |||
44 | } | 45 | } |
45 | 46 | ||
46 | 47 | ||
47 | int luaO_str2d (const l_char *s, lua_Number *result) { /* LUA_NUMBER */ | 48 | int luaO_str2d (const l_char *s, lua_Number *result) { |
48 | l_char *endptr; | 49 | l_char *endptr; |
49 | lua_Number res = lua_str2number(s, &endptr); | 50 | lua_Number res = lua_str2number(s, &endptr); |
50 | if (endptr == s) return 0; /* no conversion */ | 51 | if (endptr == s) return 0; /* no conversion */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.138 2001/02/23 13:38:56 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.139 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,6 +8,7 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #define LUA_PRIVATE | ||
11 | #include "lua.h" | 12 | #include "lua.h" |
12 | 13 | ||
13 | #include "lcode.h" | 14 | #include "lcode.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 1.59 2001/03/07 18:09:25 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.60 2001/03/09 18:05:05 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 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "ldo.h" | 13 | #include "ldo.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 1.60 2001/02/22 17:15:18 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 1.61 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
10 | #include "lua.h" | 11 | #include "lua.h" |
11 | 12 | ||
12 | #include "lmem.h" | 13 | #include "lmem.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.66 2001/03/02 17:40:08 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.67 2001/03/06 20:09:38 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -11,6 +11,7 @@ | |||
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <string.h> | 12 | #include <string.h> |
13 | 13 | ||
14 | #define LUA_PRIVATE | ||
14 | #include "lua.h" | 15 | #include "lua.h" |
15 | 16 | ||
16 | #include "lauxlib.h" | 17 | #include "lauxlib.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.76 2001/02/20 18:15:33 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.77 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | 20 | ||
21 | #define LUA_PRIVATE | ||
21 | #include "lua.h" | 22 | #include "lua.h" |
22 | 23 | ||
23 | #include "ldo.h" | 24 | #include "ldo.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.75 2001/03/07 13:22:55 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.76 2001/03/09 18:05:05 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -12,6 +12,7 @@ | |||
12 | #include <string.h> | 12 | #include <string.h> |
13 | 13 | ||
14 | 14 | ||
15 | #define LUA_PRIVATE | ||
15 | #include "lua.h" | 16 | #include "lua.h" |
16 | 17 | ||
17 | #include "lapi.h" | 18 | #include "lapi.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 1.69 2001/02/23 17:17:25 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 1.70 2001/03/02 17:27:50 roberto Exp roberto $ |
3 | ** Tag methods | 3 | ** Tag methods |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,6 +8,7 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #define LUA_PRIVATE | ||
11 | #include "lua.h" | 12 | #include "lua.h" |
12 | 13 | ||
13 | #include "ldo.h" | 14 | #include "ldo.h" |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.64 2001/02/23 20:28:26 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.65 2001/03/09 18:05:05 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 | */ |
@@ -10,6 +10,7 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #define LUA_PRIVATE | ||
13 | #include "lua.h" | 14 | #include "lua.h" |
14 | 15 | ||
15 | #include "luadebug.h" | 16 | #include "luadebug.h" |
@@ -118,7 +119,7 @@ static void print_message (void) { | |||
118 | 119 | ||
119 | 120 | ||
120 | static void print_version (void) { | 121 | static void print_version (void) { |
121 | printf(l_s("%.80s %.80s\n"), LUA_VERSION, LUA_COPYRIGHT); | 122 | printf(l_s("%.80s %.80s\n"), l_s(LUA_VERSION), l_s(LUA_COPYRIGHT)); |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.90 2001/02/23 17:28:12 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.91 2001/03/09 18:05:05 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
6 | ** www: http://www.tecgraf.puc-rio.br/lua/ | 6 | ** www: http://www.lua.org |
7 | ** See Copyright Notice at the end of this file | 7 | ** See Copyright Notice at the end of this file |
8 | */ | 8 | */ |
9 | 9 | ||
@@ -17,13 +17,13 @@ | |||
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | #define LUA_VERSION l_s("Lua 4.1 (work)") | 20 | #define LUA_VERSION "Lua 4.1 (work)" |
21 | #define LUA_COPYRIGHT l_s("Copyright (C) 1994-2000 TeCGraf, PUC-Rio") | 21 | #define LUA_COPYRIGHT "Copyright (C) 1994-2001 TeCGraf, PUC-Rio" |
22 | #define LUA_AUTHORS l_s("W. Celes, R. Ierusalimschy & L. H. de Figueiredo") | 22 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
23 | 23 | ||
24 | 24 | ||
25 | /* name of global variable with error handler */ | 25 | /* name of global variable with error handler */ |
26 | #define LUA_ERRORMESSAGE l_s("_ERRORMESSAGE") | 26 | #define LUA_ERRORMESSAGE "_ERRORMESSAGE" |
27 | 27 | ||
28 | 28 | ||
29 | /* pre-defined references */ | 29 | /* pre-defined references */ |
@@ -77,10 +77,16 @@ typedef int (*lua_CFunction) (lua_State *L); | |||
77 | 77 | ||
78 | 78 | ||
79 | /* Lua numerical type */ | 79 | /* Lua numerical type */ |
80 | typedef double lua_Number; | 80 | #ifndef LUA_NUMBER |
81 | #define LUA_NUMBER double | ||
82 | #endif | ||
83 | typedef LUA_NUMBER lua_Number; | ||
81 | 84 | ||
82 | /* Lua character type */ | 85 | /* Lua character type */ |
83 | typedef char l_char; | 86 | #ifndef L_CHAR |
87 | #define L_CHAR char | ||
88 | #endif | ||
89 | typedef L_CHAR l_char; | ||
84 | 90 | ||
85 | 91 | ||
86 | /* mark for all API functions */ | 92 | /* mark for all API functions */ |
@@ -89,7 +95,6 @@ typedef char l_char; | |||
89 | #endif | 95 | #endif |
90 | 96 | ||
91 | 97 | ||
92 | |||
93 | /* | 98 | /* |
94 | ** state manipulation | 99 | ** state manipulation |
95 | */ | 100 | */ |
@@ -227,7 +232,7 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); | |||
227 | 232 | ||
228 | #define lua_getregistry(L) lua_getref(L, LUA_REFREGISTRY) | 233 | #define lua_getregistry(L) lua_getref(L, LUA_REFREGISTRY) |
229 | 234 | ||
230 | #define lua_pushliteral(L, s) lua_pushlstring(L, l_s("") s, \ | 235 | #define lua_pushliteral(L, s) lua_pushlstring(L, s, \ |
231 | (sizeof(s)/sizeof(l_char))-1) | 236 | (sizeof(s)/sizeof(l_char))-1) |
232 | 237 | ||
233 | 238 | ||
@@ -238,6 +243,50 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); | |||
238 | 243 | ||
239 | 244 | ||
240 | 245 | ||
246 | /* | ||
247 | ** {====================================================================== | ||
248 | ** useful definitions for Lua kernel and libraries | ||
249 | */ | ||
250 | #ifdef LUA_PRIVATE | ||
251 | |||
252 | /* macro to control type of literal strings */ | ||
253 | #ifndef l_s | ||
254 | #define l_s(x) x | ||
255 | #endif | ||
256 | |||
257 | /* macro to control type of literal chars */ | ||
258 | #ifndef l_c | ||
259 | #define l_c(x) x | ||
260 | #endif | ||
261 | |||
262 | /* macro to `unsign' a character */ | ||
263 | #ifndef uchar | ||
264 | #define uchar(c) ((unsigned char)(c)) | ||
265 | #endif | ||
266 | |||
267 | /* integer type to hold the result of fgetc */ | ||
268 | #ifndef l_charint | ||
269 | #define l_charint int | ||
270 | #endif | ||
271 | |||
272 | /* function to convert a lua_Number to a string */ | ||
273 | #ifndef LUA_NUMBER_FMT | ||
274 | #define LUA_NUMBER_FMT "%.16g" | ||
275 | #endif | ||
276 | #ifndef lua_number2str | ||
277 | #define lua_number2str(s,n) sprintf((s), l_s(LUA_NUMBER_FMT), (n)) | ||
278 | #endif | ||
279 | |||
280 | /* function to convert a string to a lua_Number */ | ||
281 | #ifndef lua_str2number | ||
282 | #define lua_str2number(s,p) strtod((s), (p)) | ||
283 | #endif | ||
284 | |||
285 | #endif | ||
286 | /* }====================================================================== */ | ||
287 | |||
288 | |||
289 | |||
241 | /****************************************************************************** | 290 | /****************************************************************************** |
242 | * Copyright (C) 1994-2000 TeCGraf, PUC-Rio. All rights reserved. | 291 | * Copyright (C) 1994-2000 TeCGraf, PUC-Rio. All rights reserved. |
243 | * | 292 | * |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lualib.h,v 1.19 2001/02/23 20:31:37 roberto Exp roberto $ | 2 | ** $Id: lualib.h,v 1.20 2001/03/06 20:09:38 roberto Exp roberto $ |
3 | ** Lua standard libraries | 3 | ** Lua standard libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -16,7 +16,7 @@ | |||
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | 18 | ||
19 | #define LUA_ALERT l_s("_ALERT") | 19 | #define LUA_ALERT "_ALERT" |
20 | 20 | ||
21 | LUALIB_API int lua_baselibopen (lua_State *L); | 21 | LUALIB_API int lua_baselibopen (lua_State *L); |
22 | LUALIB_API int lua_iolibopen (lua_State *L); | 22 | LUALIB_API int lua_iolibopen (lua_State *L); |
@@ -25,27 +25,4 @@ LUALIB_API int lua_mathlibopen (lua_State *L); | |||
25 | LUALIB_API int lua_dblibopen (lua_State *L); | 25 | LUALIB_API int lua_dblibopen (lua_State *L); |
26 | 26 | ||
27 | 27 | ||
28 | |||
29 | /* | ||
30 | ** `private' part | ||
31 | */ | ||
32 | |||
33 | /* macro to `unsign' a character */ | ||
34 | #ifndef uchar | ||
35 | #define uchar(c) ((unsigned char)(c)) | ||
36 | #endif | ||
37 | |||
38 | /* integer type to hold the result of fgetc */ | ||
39 | typedef int l_charint; | ||
40 | |||
41 | /* macro to control type of literal strings */ | ||
42 | #ifndef l_s | ||
43 | #define l_s(x) x | ||
44 | #endif | ||
45 | |||
46 | /* macro to control type of literal chars */ | ||
47 | #ifndef l_c | ||
48 | #define l_c(x) x | ||
49 | #endif | ||
50 | |||
51 | #endif | 28 | #endif |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.c,v 1.38 2001/01/15 16:13:24 roberto Exp roberto $ | 2 | ** $Id: lundump.c,v 1.39 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** load bytecodes from files | 3 | ** load bytecodes from files |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,6 +7,9 @@ | |||
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
11 | #include "lua.h" | ||
12 | |||
10 | #include "lfunc.h" | 13 | #include "lfunc.h" |
11 | #include "lmem.h" | 14 | #include "lmem.h" |
12 | #include "lopcodes.h" | 15 | #include "lopcodes.h" |
@@ -96,7 +99,7 @@ static TString* LoadString (lua_State* L, ZIO* Z, int swap) | |||
96 | return NULL; | 99 | return NULL; |
97 | else | 100 | else |
98 | { | 101 | { |
99 | l_char* s=luaO_openspace(L,size); | 102 | char* s=luaO_openspace(L,size,char); |
100 | LoadBlock(L,s,size,Z,0); | 103 | LoadBlock(L,s,size,Z,0); |
101 | return luaS_newlstr(L,s,size-1); /* remove trailing l_c('\0') */ | 104 | return luaS_newlstr(L,s,size-1); /* remove trailing l_c('\0') */ |
102 | } | 105 | } |
@@ -171,7 +174,7 @@ static Proto* LoadFunction (lua_State* L, ZIO* Z, int swap) | |||
171 | 174 | ||
172 | static void LoadSignature (lua_State* L, ZIO* Z) | 175 | static void LoadSignature (lua_State* L, ZIO* Z) |
173 | { | 176 | { |
174 | const l_char* s=SIGNATURE; | 177 | const l_char* s=l_s(SIGNATURE); |
175 | while (*s!=0 && ezgetc(L,Z)==*s) | 178 | while (*s!=0 && ezgetc(L,Z)==*s) |
176 | ++s; | 179 | ++s; |
177 | if (*s!=0) luaO_verror(L,l_s("bad signature in `%.99s'"),ZNAME(Z)); | 180 | if (*s!=0) luaO_verror(L,l_s("bad signature in `%.99s'"),ZNAME(Z)); |
@@ -213,7 +216,8 @@ static int LoadHeader (lua_State* L, ZIO* Z) | |||
213 | f=LoadNumber(L,Z,swap); | 216 | f=LoadNumber(L,Z,swap); |
214 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ | 217 | if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ |
215 | luaO_verror(L,l_s("unknown number format in `%.99s':\n") | 218 | luaO_verror(L,l_s("unknown number format in `%.99s':\n") |
216 | l_s(" read ") NUMBER_FMT l_s("; expected ") NUMBER_FMT, ZNAME(Z),f,tf); | 219 | l_s(" read ") l_s(LUA_NUMBER_FMT) l_s("; expected ") l_s(LUA_NUMBER_FMT), |
220 | ZNAME(Z),f,tf); | ||
217 | return swap; | 221 | return swap; |
218 | } | 222 | } |
219 | 223 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lundump.h,v 1.19 2000/11/07 12:44:44 roberto Exp roberto $ | 2 | ** $Id: lundump.h,v 1.20 2001/02/23 17:17:25 roberto Exp roberto $ |
3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -20,12 +20,10 @@ int luaU_endianess (void); | |||
20 | #define VERSION 0x40 /* last format change was in 4.0 */ | 20 | #define VERSION 0x40 /* last format change was in 4.0 */ |
21 | #define VERSION0 0x40 /* last major change was in 4.0 */ | 21 | #define VERSION0 0x40 /* last major change was in 4.0 */ |
22 | #define ID_CHUNK 27 /* binary files start with ESC... */ | 22 | #define ID_CHUNK 27 /* binary files start with ESC... */ |
23 | #define SIGNATURE l_s("Lua") /* ...followed by this signature */ | 23 | #define SIGNATURE "Lua" /* ...followed by this signature */ |
24 | 24 | ||
25 | /* formats for error messages */ | 25 | /* formats for error messages */ |
26 | #define SOURCE_FMT l_s("<%d:%.99s>") | ||
27 | #define SOURCE tf->lineDefined,tf->source->str | 26 | #define SOURCE tf->lineDefined,tf->source->str |
28 | #define IN_FMT l_s(" in %p ") SOURCE_FMT | ||
29 | #define IN tf,SOURCE | 27 | #define IN tf,SOURCE |
30 | 28 | ||
31 | /* a multiple of PI for testing native format */ | 29 | /* a multiple of PI for testing native format */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.175 2001/03/07 18:09:25 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.176 2001/03/07 18:16:22 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -10,6 +10,7 @@ | |||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #define LUA_PRIVATE | ||
13 | #include "lua.h" | 14 | #include "lua.h" |
14 | 15 | ||
15 | #include "lapi.h" | 16 | #include "lapi.h" |
@@ -39,7 +40,7 @@ int luaV_tonumber (TObject *obj) { | |||
39 | } | 40 | } |
40 | 41 | ||
41 | 42 | ||
42 | int luaV_tostring (lua_State *L, TObject *obj) { /* LUA_NUMBER */ | 43 | int luaV_tostring (lua_State *L, TObject *obj) { |
43 | if (ttype(obj) != LUA_TNUMBER) | 44 | if (ttype(obj) != LUA_TNUMBER) |
44 | return 1; | 45 | return 1; |
45 | else { | 46 | else { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.c,v 1.12 2000/05/24 13:54:49 roberto Exp roberto $ | 2 | ** $Id: lzio.c,v 1.13 2000/06/12 13:52:05 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 | */ |
@@ -9,6 +9,7 @@ | |||
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | 11 | ||
12 | #define LUA_PRIVATE | ||
12 | #include "lua.h" | 13 | #include "lua.h" |
13 | 14 | ||
14 | #include "lzio.h" | 15 | #include "lzio.h" |
@@ -71,7 +72,10 @@ size_t zread (ZIO *z, void *b, size_t n) { | |||
71 | if (z->n == 0) { | 72 | if (z->n == 0) { |
72 | if (z->filbuf(z) == EOZ) | 73 | if (z->filbuf(z) == EOZ) |
73 | return n; /* return number of missing bytes */ | 74 | return n; /* return number of missing bytes */ |
74 | zungetc(z); /* put result from `filbuf' in the buffer */ | 75 | else { |
76 | ++z->n; /* filbuf removed first byte; put back it */ | ||
77 | --z->p; | ||
78 | } | ||
75 | } | 79 | } |
76 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ | 80 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ |
77 | memcpy(b, z->p, m); | 81 | memcpy(b, z->p, m); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lzio.h,v 1.6 2000/05/24 13:54:49 roberto Exp roberto $ | 2 | ** $Id: lzio.h,v 1.7 2000/10/20 16:36:32 roberto Exp roberto $ |
3 | ** Buffered streams | 3 | ** Buffered streams |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -29,7 +29,6 @@ ZIO* zmopen (ZIO* z, const char* b, size_t size, const char *name); /* memory */ | |||
29 | size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */ | 29 | size_t zread (ZIO* z, void* b, size_t n); /* read next n bytes */ |
30 | 30 | ||
31 | #define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z)) | 31 | #define zgetc(z) (((z)->n--)>0 ? ((int)*(z)->p++): (z)->filbuf(z)) |
32 | #define zungetc(z) (++(z)->n,--(z)->p) | ||
33 | #define zname(z) ((z)->name) | 32 | #define zname(z) ((z)->name) |
34 | 33 | ||
35 | 34 | ||