Unified · Split
| @@ -1,4 +1,4 @@ | |||
| 1 | This is Lua 5.1. | 1 | HISTORY for Lua 5.1 |
| 2 | 2 | ||
| 3 | * Changes from version 5.0 to 5.1 | 3 | * Changes from version 5.0 to 5.1 |
| 4 | ------------------------------- | 4 | ------------------------------- |
| @@ -14,6 +14,7 @@ This is Lua 5.1. · 9 unmodified lines | |||
| 14 | API: | 14 | API: |
| 15 | + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer. | 15 | + new functions: lua_createtable, lua_get(set)field, lua_push(to)integer. |
| 16 | + user supplies memory allocator (lua_open becomes lua_newstate). | 16 | + user supplies memory allocator (lua_open becomes lua_newstate). |
| 17 | + luaopen_* functionst be called through Lua. | ||
| 17 | Implementation: | 18 | Implementation: |
| 18 | + new configuration scheme via luaconf.h. | 19 | + new configuration scheme via luaconf.h. |
| 19 | + incremental garbage collection. | 20 | + incremental garbage collection. |
| @@ -1,4 +1,4 @@ | |||
| 1 | This is Lua 5.1. | 1 | INSTALL for Lua 5.1 |
| 2 | 2 | ||
| 3 | * Building Lua | 3 | * Building Lua |
| 4 | ------------ | 4 | ------------ |
| @@ -8,7 +8,7 @@ This is Lua 5.1. · 3 unmodified lines | |||
| 8 | Building Lua on Unix systems should be very easy. First do "make" and | 8 | Building Lua on Unix systems should be very easy. First do "make" and |
| 9 | see if your platform is listed. If so, just do "make xxx", where xxx | 9 | see if your platform is listed. If so, just do "make xxx", where xxx |
| 10 | is your platform name. The platforms currently supported are: | 10 | is your platform name. The platforms currently supported are: |
| 11 | ansi bsd generic linux macosx mingw posix | 11 | ansi bsd generic linux macosx mingw posix solaris |
| 12 | 12 | ||
| 13 | See below for customization instructions and for instructions on how | 13 | See below for customization instructions and for instructions on how |
| 14 | to build with other Windows compilers. | 14 | to build with other Windows compilers. |
| @@ -1,4 +1,4 @@ | |||
| 1 | MANIFEST contents of Lua 5.1 distribution on Wed Jan 11 22:50:45 BRST 2006 | 1 | MANIFEST contents of Lua 5.1 distribution on Tue Jan 24 16:12:03 BRST 2006 |
| 2 | lua-5.1 | 2 | lua-5.1 |
| 3 | lua-5.1/COPYRIGHT | 3 | lua-5.1/COPYRIGHT |
| 4 | lua-5.1/doc | 4 | lua-5.1/doc |
| @@ -16,6 +16,8 @@ INSTALL_BIN= $(INSTALL_TOP)/bin · 15 unmodified lines | |||
| 16 | INSTALL_INC= $(INSTALL_TOP)/include | 16 | INSTALL_INC= $(INSTALL_TOP)/include |
| 17 | INSTALL_LIB= $(INSTALL_TOP)/lib | 17 | INSTALL_LIB= $(INSTALL_TOP)/lib |
| 18 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 | 18 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 |
| 19 | INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V | ||
| 20 | INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V | ||
| 19 | 21 | ||
| 20 | # How to install. You may prefer "install" instead of "cp" if you have it. | 22 | # How to install. You may prefer "install" instead of "cp" if you have it. |
| 21 | # To remove debug information from binaries, use "install -s" in INSTALL_EXEC. | 23 | # To remove debug information from binaries, use "install -s" in INSTALL_EXEC. |
| @@ -28,7 +30,7 @@ INSTALL_DATA= cp · 6 unmodified lines | |||
| 28 | # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= | 30 | # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= |
| 29 | 31 | ||
| 30 | # Convenience platforms targets. | 32 | # Convenience platforms targets. |
| 31 | PLATS= ansi bsd generic linux macosx mingw posix | 33 | PLATS= ansi bsd generic linux macosx mingw posix solaris |
| 32 | 34 | ||
| 33 | # What to install. | 35 | # What to install. |
| 34 | TO_BIN= lua luac | 36 | TO_BIN= lua luac |
| @@ -39,7 +41,7 @@ TO_MAN= lua.1 luac.1 · 4 unmodified lines | |||
| 39 | # Lua version. Currently used only for messages. | 41 | # Lua version. Currently used only for messages. |
| 40 | V= 5.1 | 42 | V= 5.1 |
| 41 | 43 | ||
| 42 | all: $(PLAT) | 44 | all: $(PLAT) |
| 43 | 45 | ||
| 44 | $(PLATS) clean: | 46 | $(PLATS) clean: |
| 45 | cd src; $(MAKE) $@ | 47 | cd src; $(MAKE) $@ |
| @@ -47,8 +49,8 @@ $(PLATS) clean: · 1 unmodified line | |||
| 47 | test: all | 49 | test: all |
| 48 | src/lua test/hello.lua | 50 | src/lua test/hello.lua |
| 49 | 51 | ||
| 50 | install: all | 52 | install: |
| 51 | cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) | 53 | cd src; mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) |
| 52 | cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) | 54 | cd src; $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) |
| 53 | cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) | 55 | cd src; $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) |
| 54 | cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) | 56 | cd src; $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) |
| @@ -77,6 +79,9 @@ echo: · 22 unmodified lines | |||
| 77 | @echo "INSTALL_MAN = $(INSTALL_MAN)" | 79 | @echo "INSTALL_MAN = $(INSTALL_MAN)" |
| 78 | @echo "INSTALL_EXEC = $(INSTALL_EXEC)" | 80 | @echo "INSTALL_EXEC = $(INSTALL_EXEC)" |
| 79 | @echo "INSTALL_DATA = $(INSTALL_DATA)" | 81 | @echo "INSTALL_DATA = $(INSTALL_DATA)" |
| 82 | @echo "INSTALL_LMOD = $(INSTALL_LMOD)" | ||
| 83 | @echo "INSTALL_CMOD = $(INSTALL_CMOD)" | ||
| 84 | @echo "INSTALL_CMOD = $(INSTALL_CMOD)" | ||
| 80 | @echo "" | 85 | @echo "" |
| 81 | @echo "See also src/luaconf.h ." | 86 | @echo "See also src/luaconf.h ." |
| 82 | @echo "" | 87 | @echo "" |
| @@ -1,4 +1,6 @@ | |||
| 1 | This is Lua 5.1. | 1 | README for Lua 5.1 |
| 2 | |||
| 3 | See INSTALL for installation instructions. | ||
| 2 | See HISTORY for a summary of changes since the last released version. | 4 | See HISTORY for a summary of changes since the last released version. |
| 3 | 5 | ||
| 4 | * What is Lua? | 6 | * What is Lua? |
| @@ -1174,7 +1174,7 @@ while all of them share the same <code>x</code>. · 1173 unmodified lines | |||
| 1174 | 1174 | ||
| 1175 | <p>Because Lua is an embedded extension language, | 1175 | <p>Because Lua is an embedded extension language, |
| 1176 | all Lua actions start from C code in the host program | 1176 | all Lua actions start from C code in the host program |
| 1177 | calling a function from the Lua library (see <a href="#lua_pcall"></a>). | 1177 | calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>). |
| 1178 | Whenever an error occurs during Lua compilation or execution, | 1178 | Whenever an error occurs during Lua compilation or execution, |
| 1179 | control returns to C, | 1179 | control returns to C, |
| 1180 | which can take appropriate measures | 1180 | which can take appropriate measures |
| @@ -1509,11 +1509,11 @@ called when Lua calls a value. · 328 unmodified lines | |||
| 1509 | <pre> | 1509 | <pre> |
| 1510 | function function_event (func, ...) | 1510 | function function_event (func, ...) |
| 1511 | if type(func) == "function" then | 1511 | if type(func) == "function" then |
| 1512 | return func(unpack(arg)) -- primitive call | 1512 | return func(...) -- primitive call |
| 1513 | else | 1513 | else |
| 1514 | local h = metatable(func).__call | 1514 | local h = metatable(func).__call |
| 1515 | if h then | 1515 | if h then |
| 1516 | return h(func, unpack(arg)) | 1516 | return h(func, ...) |
| 1517 | else | 1517 | else |
| 1518 | error("...") | 1518 | error("...") |
| 1519 | end | 1519 | end |
| @@ -1553,7 +1553,7 @@ all accesses to global variables within that function (see <a href="#variables"> · 33 unmodified lines | |||
| 1553 | They are used as the default environment for other Lua functions | 1553 | They are used as the default environment for other Lua functions |
| 1554 | created by that function. | 1554 | created by that function. |
| 1555 | 1555 | ||
| 1556 | <p>You can change the environment of a Lua function of the | 1556 | <p>You can change the environment of a Lua function or the |
| 1557 | running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>. | 1557 | running thread calling <a href="#pdf-setfenv"><code>setfenv</code></a>. |
| 1558 | You can get the environment of a Lua function or the running thread | 1558 | You can get the environment of a Lua function or the running thread |
| 1559 | calling <a href="#pdf-getfenv"><code>getfenv</code></a>. | 1559 | calling <a href="#pdf-getfenv"><code>getfenv</code></a>. |
| @@ -1565,8 +1565,8 @@ use the C API. · 5 unmodified lines | |||
| 1565 | 1565 | ||
| 1566 | <p>Lua performs automatic memory management. | 1566 | <p>Lua performs automatic memory management. |
| 1567 | That means that | 1567 | That means that |
| 1568 | you do not have to worry about allocating memory for new objects | 1568 | you do not have to worry neither about allocating memory for new objects |
| 1569 | not about freeing it when the objects are no longer needed. | 1569 | nor about freeing it when the objects are no longer needed. |
| 1570 | Lua manages memory automatically by running | 1570 | Lua manages memory automatically by running |
| 1571 | a <em>garbage collector</em> from time to time | 1571 | a <em>garbage collector</em> from time to time |
| 1572 | to collect all <em>dead objects</em> | 1572 | to collect all <em>dead objects</em> |
| @@ -2821,7 +2821,7 @@ onto the stack. · 1248 unmodified lines | |||
| 2821 | Lua makes (or reuses) an internal copy of the given string, | 2821 | Lua makes (or reuses) an internal copy of the given string, |
| 2822 | so the memory at <code>s</code> can be freed or reused immediately after | 2822 | so the memory at <code>s</code> can be freed or reused immediately after |
| 2823 | the function returns. | 2823 | the function returns. |
| 2824 | The string cannot embedded zeros; | 2824 | The string cannot contain embedded zeros; |
| 2825 | it is assumed to end at the first zero. | 2825 | it is assumed to end at the first zero. |
| 2826 | 2826 | ||
| 2827 | <p><a name="lua_pushthread"></a> | 2827 | <p><a name="lua_pushthread"></a> |
| @@ -3609,7 +3609,7 @@ or when it jumps back in the code (even to the same line). · 781 unmodified lines | |||
| 3609 | 3609 | ||
| 3610 | <p>Sets the value of a local variable of a given activation record. | 3610 | <p>Sets the value of a local variable of a given activation record. |
| 3611 | Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal</code></a> | 3611 | Parameters <code>ar</code> and <code>n</code> are as in <a href="#lua_getlocal"><code>lua_getlocal</code></a> |
| 3612 | (see <a href="#lua_getlocal"></a>). | 3612 | (see <a href="#lua_getlocal"><code>lua_getlocal</code></a>). |
| 3613 | <a href="#lua_setlocal"><code>lua_setlocal</code></a> assigns the value at the top of the stack | 3613 | <a href="#lua_setlocal"><code>lua_setlocal</code></a> assigns the value at the top of the stack |
| 3614 | to the variable and returns its name. | 3614 | to the variable and returns its name. |
| 3615 | It also pops the value from the stack. | 3615 | It also pops the value from the stack. |
| @@ -3627,7 +3627,7 @@ the number of active local variables. · 11 unmodified lines | |||
| 3627 | 3627 | ||
| 3628 | <p>Sets the value of a closure's upvalue. | 3628 | <p>Sets the value of a closure's upvalue. |
| 3629 | Parameters <code>funcindex</code> and <code>n</code> are as in <a href="#lua_getupvalue"><code>lua_getupvalue</code></a> | 3629 | Parameters <code>funcindex</code> and <code>n</code> are as in <a href="#lua_getupvalue"><code>lua_getupvalue</code></a> |
| 3630 | (see <a href="#lua_getupvalue"></a>). | 3630 | (see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>). |
| 3631 | It assigns the value at the top of the stack | 3631 | It assigns the value at the top of the stack |
| 3632 | to the upvalue and returns its name. | 3632 | to the upvalue and returns its name. |
| 3633 | It also pops the value from the stack. | 3633 | It also pops the value from the stack. |
| @@ -3995,9 +3995,9 @@ in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code> · 361 unmodified lines | |||
| 3995 | </pre> | 3995 | </pre> |
| 3996 | 3996 | ||
| 3997 | 3997 | ||
| 3998 | <p>Creates a copy of string <code>s</code> by replacing any occurrence | 3998 | <p>Creates a copy of string <code>s</code> by replacing |
| 3999 | any occurrence of the string <code>p</code> | 3999 | any occurrence of the string <code>p</code> |
| 4000 | wth the string <code>r</code>. | 4000 | with the string <code>r</code>. |
| 4001 | Pushes the resulting string on the stack and returns it. | 4001 | Pushes the resulting string on the stack and returns it. |
| 4002 | 4002 | ||
| 4003 | <p><a name="luaL_loadbuffer"></a> | 4003 | <p><a name="luaL_loadbuffer"></a> |
| @@ -5302,6 +5302,8 @@ of table <code>t</code>. · 1298 unmodified lines | |||
| 5302 | 5302 | ||
| 5303 | <p>Returns the largest positive numerical index of the given table, | 5303 | <p>Returns the largest positive numerical index of the given table, |
| 5304 | or zero if the table has no positive numerical indices. | 5304 | or zero if the table has no positive numerical indices. |
| 5305 | (To do its job this function does a linear traversal of | ||
| 5306 | the whole table.) | ||
| 5305 | 5307 | ||
| 5306 | <p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3> | 5308 | <p><a name="pdf-table.remove"></a><hr /><h3><code>table.remove (table [, pos])</code></h3> |
| 5307 | 5309 | ||
| @@ -6076,7 +6078,15 @@ use <code>collectgarbage("count")</code> instead. · 768 unmodified lines | |||
| 6076 | 6078 | ||
| 6077 | <p><h3>Changes in the API</h3> | 6079 | <p><h3>Changes in the API</h3> |
| 6078 | <ul> | 6080 | <ul> |
| 6079 | <li> | 6081 | |
| 6082 | <p><li> | ||
| 6083 | The <code>luaopen_*</code> functions (to open libraries) | ||
| 6084 | cannot be called directly, | ||
| 6085 | like a regular C function. | ||
| 6086 | They must be called through Lua, | ||
| 6087 | like a Lua function. | ||
| 6088 | |||
| 6089 | <p><li> | ||
| 6080 | Function <code>lua_open</code> was replaced by <a href="#lua_newstate"><code>lua_newstate</code></a> to | 6090 | Function <code>lua_open</code> was replaced by <a href="#lua_newstate"><code>lua_newstate</code></a> to |
| 6081 | allow the user to set a memory allocation function. | 6091 | allow the user to set a memory allocation function. |
| 6082 | You can use <a href="#luaL_newstate"><code>luaL_newstate</code></a> from the standard library to | 6092 | You can use <a href="#luaL_newstate"><code>luaL_newstate</code></a> from the standard library to |
| @@ -1,13 +1,16 @@ | |||
| 1 | # lua.pc -- pkg-config data for Lua | 1 | # lua.pc -- pkg-config data for Lua |
| 2 | 2 | ||
| 3 | # vars from install Makefile | 3 | # vars from install Makefile |
| 4 | # grep ^INSTALL_...= ../Makefile | 4 | # grep '^INSTALL_.*=' ../Makefile |
| 5 | INSTALL_TOP= /usr/local | 5 | INSTALL_TOP= /usr/local |
| 6 | INSTALL_BIN= $(INSTALL_TOP)/bin | 6 | INSTALL_BIN= $(INSTALL_TOP)/bin |
| 7 | INSTALL_INC= $(INSTALL_TOP)/include | 7 | INSTALL_INC= $(INSTALL_TOP)/include |
| 8 | INSTALL_LIB= $(INSTALL_TOP)/lib | 8 | INSTALL_LIB= $(INSTALL_TOP)/lib |
| 9 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 | 9 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 |
| 10 | # grep ^V= ../Makefile | 10 | INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V |
| 11 | INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V | ||
| 12 | |||
| 13 | # grep '^V=' ../Makefile | ||
| 11 | V= 5.1 | 14 | V= 5.1 |
| 12 | 15 | ||
| 13 | prefix=${INSTALL_TOP} | 16 | prefix=${INSTALL_TOP} |
| @@ -1,5 +1,5 @@ | |||
| 1 | # makefile for building Lua | 1 | # makefile for building Lua |
| 2 | # see INSTALL for installation instructions | 2 | # see ../INSTALL for installation instructions |
| 3 | # see ../Makefile and luaconf.h for further customization | 3 | # see ../Makefile and luaconf.h for further customization |
| 4 | 4 | ||
| 5 | # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= | 5 | # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= |
| @@ -20,7 +20,7 @@ MYLIBS= · 14 unmodified lines | |||
| 20 | 20 | ||
| 21 | # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= | 21 | # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= |
| 22 | 22 | ||
| 23 | PLATS= ansi bsd generic linux macosx mingw posix | 23 | PLATS= ansi bsd generic linux macosx mingw posix solaris |
| 24 | 24 | ||
| 25 | LUA_A= liblua.a | 25 | LUA_A= liblua.a |
| 26 | CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ | 26 | CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ |
| @@ -74,7 +74,7 @@ echo: · 47 unmodified lines | |||
| 74 | @echo "MYLDFLAGS = $(MYLDFLAGS)" | 74 | @echo "MYLDFLAGS = $(MYLDFLAGS)" |
| 75 | @echo "MYLIBS = $(MYLIBS)" | 75 | @echo "MYLIBS = $(MYLIBS)" |
| 76 | 76 | ||
| 77 | # convenience targets for usual platforms | 77 | # convenience targets for popular platforms |
| 78 | 78 | ||
| 79 | none: | 79 | none: |
| 80 | @echo "Please choose a platform: $(PLATS)" | 80 | @echo "Please choose a platform: $(PLATS)" |
| @@ -93,15 +93,21 @@ linux: · 12 unmodified lines | |||
| 93 | 93 | ||
| 94 | macosx: | 94 | macosx: |
| 95 | $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX | 95 | $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX |
| 96 | # use this on Mac OS X 10.4 | ||
| 97 | # $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline" | ||
| 96 | 98 | ||
| 97 | mingw: | 99 | mingw: |
| 98 | $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ | 100 | $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ |
| 99 | "AR=gcc -shared -o" "RANLIB=strip --strip-unneeded" \ | 101 | "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ |
| 100 | "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe | 102 | "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe |
| 101 | 103 | ||
| 102 | posix: | 104 | posix: |
| 103 | $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX | 105 | $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX |
| 104 | 106 | ||
| 107 | solaris: | ||
| 108 | $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" | ||
| 109 | |||
| 110 | |||
| 105 | # DO NOT DELETE | 111 | # DO NOT DELETE |
| 106 | 112 | ||
| 107 | lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ | 113 | lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.157 2005/12/29 15:32:11 roberto Exp $ | 2 | ** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $ |
| 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 | */ |
| @@ -295,23 +295,33 @@ static void getsizes (lua_State *L) { · 289 unmodified lines | |||
| 295 | 295 | ||
| 296 | LUALIB_API void luaL_setn (lua_State *L, int t, int n) { | 296 | LUALIB_API void luaL_setn (lua_State *L, int t, int n) { |
| 297 | t = abs_index(L, t); | 297 | t = abs_index(L, t); |
| 298 | getsizes(L); | 298 | lua_pushliteral(L, "n"); |
| 299 | lua_pushvalue(L, t); | 299 | lua_rawget(L, t); |
| 300 | lua_pushinteger(L, n); | 300 | if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ |
| 301 | lua_rawset(L, -3); /* sizes[t] = n */ | 301 | lua_pushliteral(L, "n"); /* use it */ |
| 302 | lua_pop(L, 1); /* remove `sizes' */ | 302 | lua_pushinteger(L, n); |
| 303 | lua_rawset(L, t); | ||
| 304 | } | ||
| 305 | else { /* use `sizes' */ | ||
| 306 | getsizes(L); | ||
| 307 | lua_pushvalue(L, t); | ||
| 308 | lua_pushinteger(L, n); | ||
| 309 | lua_rawset(L, -3); /* sizes[t] = n */ | ||
| 310 | lua_pop(L, 1); /* remove `sizes' */ | ||
| 311 | } | ||
| 303 | } | 312 | } |
| 304 | 313 | ||
| 305 | 314 | ||
| 306 | LUALIB_API int luaL_getn (lua_State *L, int t) { | 315 | LUALIB_API int luaL_getn (lua_State *L, int t) { |
| 307 | int n; | 316 | int n; |
| 308 | t = abs_index(L, t); | 317 | t = abs_index(L, t); |
| 309 | getsizes(L); /* try sizes[t] */ | 318 | lua_pushliteral(L, "n"); /* try t.n */ |
| 319 | lua_rawget(L, t); | ||
| 320 | if ((n = checkint(L, 1)) >= 0) return n; | ||
| 321 | getsizes(L); /* else try sizes[t] */ | ||
| 310 | lua_pushvalue(L, t); | 322 | lua_pushvalue(L, t); |
| 311 | lua_rawget(L, -2); | 323 | lua_rawget(L, -2); |
| 312 | if ((n = checkint(L, 2)) >= 0) return n; | 324 | if ((n = checkint(L, 2)) >= 0) return n; |
| 313 | lua_getfield(L, t, "n"); /* else try t.n */ | ||
| 314 | if ((n = checkint(L, 1)) >= 0) return n; | ||
| 315 | return (int)lua_objlen(L, t); | 325 | return (int)lua_objlen(L, t); |
| 316 | } | 326 | } |
| 317 | 327 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.188 2005/12/29 15:32:11 roberto Exp $ | 2 | ** $Id: lbaselib.c,v 1.189 2006/01/18 11:49:12 roberto Exp $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -201,7 +201,7 @@ static int luaB_collectgarbage (lua_State *L) { · 195 unmodified lines | |||
| 201 | switch (optsnum[o]) { | 201 | switch (optsnum[o]) { |
| 202 | case LUA_GCCOUNT: { | 202 | case LUA_GCCOUNT: { |
| 203 | int b = lua_gc(L, LUA_GCCOUNTB, 0); | 203 | int b = lua_gc(L, LUA_GCCOUNTB, 0); |
| 204 | lua_pushnumber(L, ((lua_Number)res*1024 + b)/1024); | 204 | lua_pushnumber(L, res + ((lua_Number)b/1024)); |
| 205 | return 1; | 205 | return 1; |
| 206 | } | 206 | } |
| 207 | case LUA_GCSTEP: { | 207 | case LUA_GCSTEP: { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp $ | 2 | ** $Id: liolib.c,v 2.71 2006/01/17 13:54:02 roberto Exp $ |
| 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 | */ |
| @@ -28,6 +28,7 @@ static const char *const fnames[] = {"input", "output"}; · 22 unmodified lines | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | static int pushresult (lua_State *L, int i, const char *filename) { | 30 | static int pushresult (lua_State *L, int i, const char *filename) { |
| 31 | int en = errno; /* calls to Lua API may change this value */ | ||
| 31 | if (i) { | 32 | if (i) { |
| 32 | lua_pushboolean(L, 1); | 33 | lua_pushboolean(L, 1); |
| 33 | return 1; | 34 | return 1; |
| @@ -35,10 +36,10 @@ static int pushresult (lua_State *L, int i, const char *filename) { · 1 unmodified line | |||
| 35 | else { | 36 | else { |
| 36 | lua_pushnil(L); | 37 | lua_pushnil(L); |
| 37 | if (filename) | 38 | if (filename) |
| 38 | lua_pushfstring(L, "%s: %s", filename, strerror(errno)); | 39 | lua_pushfstring(L, "%s: %s", filename, strerror(en)); |
| 39 | else | 40 | else |
| 40 | lua_pushfstring(L, "%s", strerror(errno)); | 41 | lua_pushfstring(L, "%s", strerror(en)); |
| 41 | lua_pushinteger(L, errno); | 42 | lua_pushinteger(L, en); |
| 42 | return 3; | 43 | return 3; |
| 43 | } | 44 | } |
| 44 | } | 45 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.c,v 2.17 2005/12/22 16:19:56 roberto Exp $ | 2 | ** $Id: llex.c,v 2.18 2006/01/23 20:06:19 roberto Exp $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -193,12 +193,10 @@ static void read_numeral (LexState *ls, SemInfo *seminfo) { · 187 unmodified lines | |||
| 193 | do { | 193 | do { |
| 194 | save_and_next(ls); | 194 | save_and_next(ls); |
| 195 | } while (isdigit(ls->current) || ls->current == '.'); | 195 | } while (isdigit(ls->current) || ls->current == '.'); |
| 196 | if (check_next(ls, "Ee")) { /* `E'? */ | 196 | if (check_next(ls, "Ee")) /* `E'? */ |
| 197 | check_next(ls, "+-"); /* optional exponent sign */ | 197 | check_next(ls, "+-"); /* optional exponent sign */ |
| 198 | while (isdigit(ls->current)) { | 198 | while (isalnum(ls->current) || ls->current == '_') |
| 199 | save_and_next(ls); | 199 | save_and_next(ls); |
| 200 | } | ||
| 201 | } | ||
| 202 | save(ls, '\0'); | 200 | save(ls, '\0'); |
| 203 | buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ | 201 | buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ |
| 204 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ | 202 | if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.19 2006/01/10 12:51:53 roberto Exp $ | 2 | ** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -119,9 +119,6 @@ typedef struct lua_TValue { · 113 unmodified lines | |||
| 119 | #define setnvalue(obj,x) \ | 119 | #define setnvalue(obj,x) \ |
| 120 | { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } | 120 | { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } |
| 121 | 121 | ||
| 122 | #define chgnvalue(obj,x) \ | ||
| 123 | check_exp(ttype(obj)==LUA_TNUMBER, (obj)->value.n=(x)) | ||
| 124 | |||
| 125 | #define setpvalue(obj,x) \ | 122 | #define setpvalue(obj,x) \ |
| 126 | { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } | 123 | { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } |
| 127 | 124 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp $ | 2 | ** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $ |
| 3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -122,7 +122,7 @@ static int arrayindex (const TValue *key) { · 116 unmodified lines | |||
| 122 | lua_Number n = nvalue(key); | 122 | lua_Number n = nvalue(key); |
| 123 | int k; | 123 | int k; |
| 124 | lua_number2int(k, n); | 124 | lua_number2int(k, n); |
| 125 | if (luai_numeq(cast_num(k), nvalue(key))) | 125 | if (luai_numeq(cast_num(k), n)) |
| 126 | return k; | 126 | return k; |
| 127 | } | 127 | } |
| 128 | return -1; /* `key' did not match some condition */ | 128 | return -1; /* `key' did not match some condition */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.77 2005/12/27 17:12:00 roberto Exp $ | 2 | ** $Id: luaconf.h,v 1.79 2006/01/23 19:51:43 roberto Exp $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -488,6 +488,7 @@ · 482 unmodified lines | |||
| 488 | ** =================================================================== | 488 | ** =================================================================== |
| 489 | */ | 489 | */ |
| 490 | 490 | ||
| 491 | #define LUA_NUMBER_DOUBLE | ||
| 491 | #define LUA_NUMBER double | 492 | #define LUA_NUMBER double |
| 492 | 493 | ||
| 493 | /* | 494 | /* |
| @@ -702,7 +703,7 @@ union luai_Cast { double l_d; long l_l; }; · 208 unmodified lines | |||
| 702 | 703 | ||
| 703 | /* | 704 | /* |
| 704 | @@ LUA_INTFRMLEN is the length modifier for integer conversions | 705 | @@ LUA_INTFRMLEN is the length modifier for integer conversions |
| 705 | @* in 'string.fomat'. | 706 | @* in 'string.format'. |
| 706 | @@ LUA_INTFRM_T is the integer type correspoding to the previous length | 707 | @@ LUA_INTFRM_T is the integer type correspoding to the previous length |
| 707 | @* modifier. | 708 | @* modifier. |
| 708 | ** CHANGE them if your system supports long long or does not support long. | 709 | ** CHANGE them if your system supports long long or does not support long. |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.61 2006/01/10 12:50:00 roberto Exp $ | 2 | ** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -95,7 +95,8 @@ static void callTMres (lua_State *L, StkId res, const TValue *f, · 89 unmodified lines | |||
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | 97 | ||
| 98 | static void callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3) { | 98 | static void callTM (lua_State *L, const TValue *f, const TValue *p1, |
| 99 | const TValue *p2, const TValue *p3) { | ||
| 99 | setobj2s(L, L->top, f); /* push function */ | 100 | setobj2s(L, L->top, f); /* push function */ |
| 100 | setobj2s(L, L->top+1, p1); /* 1st argument */ | 101 | setobj2s(L, L->top+1, p1); /* 1st argument */ |
| 101 | setobj2s(L, L->top+2, p2); /* 2nd argument */ | 102 | setobj2s(L, L->top+2, p2); /* 2nd argument */ |
| @@ -649,7 +650,8 @@ void luaV_execute (lua_State *L, int nexeccalls) { · 547 unmodified lines | |||
| 649 | lua_Number step = nvalue(ra+2); | 650 | lua_Number step = nvalue(ra+2); |
| 650 | lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ | 651 | lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ |
| 651 | lua_Number limit = nvalue(ra+1); | 652 | lua_Number limit = nvalue(ra+1); |
| 652 | if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) { | 653 | if (luai_numlt(0, step) ? luai_numle(idx, limit) |
| 654 | : luai_numle(limit, idx)) { | ||
| 653 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ | 655 | dojump(L, pc, GETARG_sBx(i)); /* jump back */ |
| 654 | setnvalue(ra, idx); /* update internal index... */ | 656 | setnvalue(ra, idx); /* update internal index... */ |
| 655 | setnvalue(ra+3, idx); /* ...and external index */ | 657 | setnvalue(ra+3, idx); /* ...and external index */ |