From bfcd7b7305c5465eb33acca86109ca96cb37403a Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Mon, 7 Feb 2011 21:57:20 +0100 Subject: [PATCH] lua: Updating to 5.1.4 Updating base code to 5.1.4 Adding -DSYSLINUX build flag Moving #if 0 to ifndef SYSLINUX --- com32/lua/doc/manual.html | 281 ++++++++++++++++++++++++++-------------------- com32/lua/doc/readme.html | 4 +- com32/lua/etc/lua.pc | 2 +- com32/lua/src/Makefile | 1 + com32/lua/src/lapi.c | 18 +-- com32/lua/src/lauxlib.c | 6 +- com32/lua/src/lbaselib.c | 12 +- com32/lua/src/ldebug.c | 34 ++++-- com32/lua/src/linit.c | 7 +- com32/lua/src/liolib.c | 26 ++--- com32/lua/src/llex.c | 10 +- com32/lua/src/loadlib.c | 14 ++- com32/lua/src/lobject.h | 4 +- com32/lua/src/loslib.c | 6 +- com32/lua/src/lstrlib.c | 7 +- com32/lua/src/ltablib.c | 22 ++-- com32/lua/src/lua.c | 28 +++-- com32/lua/src/lua.h | 7 +- com32/lua/src/lualib.h | 9 +- com32/lua/src/lundump.c | 10 +- com32/lua/src/lvm.c | 15 +-- 21 files changed, 308 insertions(+), 215 deletions(-) diff --git a/com32/lua/doc/manual.html b/com32/lua/doc/manual.html index b125c13..f46f17c 100644 --- a/com32/lua/doc/manual.html +++ b/com32/lua/doc/manual.html @@ -3,8 +3,8 @@ Lua 5.1 Reference Manual - - + + @@ -33,7 +33,7 @@ Freely available under the terms of the

- + @@ -103,7 +103,8 @@ in which Non-terminals are shown like non-terminal, keywords are shown like kword, and other terminal symbols are shown like `=´. -The complete syntax of Lua can be found at the end of this manual. +The complete syntax of Lua can be found in §8 +at the end of this manual. @@ -139,7 +140,7 @@ Lua is a case-sensitive language: and is a reserved word, but And and AND are two different, valid names. As a convention, names starting with an underscore followed by -uppercase letters (such as _VERSION) +uppercase letters (such as _VERSION) are reserved for internal global variables used by Lua. @@ -169,27 +170,16 @@ and can contain the following C-like escape sequences: and '\'' (apostrophe [single quote]). Moreover, a backslash followed by a real newline results in a newline in the string. -A character in a string may also be specified by its numerical value +A character in a string can also be specified by its numerical value using the escape sequence \ddd, where ddd is a sequence of up to three decimal digits. (Note that if a numerical escape is to be followed by a digit, it must be expressed using exactly three digits.) -Strings in Lua may contain any 8-bit value, including embedded zeros, +Strings in Lua can contain any 8-bit value, including embedded zeros, which can be specified as '\0'.

-To put a double (single) quote, a newline, a backslash, -a carriage return, -or an embedded zero -inside a literal string enclosed by double (single) quotes -you must use an escape sequence. -Any other character may be directly inserted into the literal. -(Some control characters may cause problems for the file system, -but Lua has no problem with them.) - - -

Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening @@ -202,10 +192,10 @@ A closing long bracket is defined similarly; for instance, a closing long bracket of level 4 is written as ]====]. A long string starts with an opening long bracket of any level and ends at the first closing long bracket of the same level. -Literals in this bracketed form may run for several lines, +Literals in this bracketed form can run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. -They may contain anything except a closing bracket of the proper level. +They can contain anything except a closing bracket of the proper level.

@@ -215,7 +205,7 @@ the newline is not included in the string. As an example, in a system using ASCII (in which 'a' is coded as 97, newline is coded as 10, and '1' is coded as 49), -the five literals below denote the same string: +the five literal strings below denote the same string:

      a = 'alo\n123"'
@@ -229,7 +219,7 @@ the five literals below denote the same string:
 

-A numerical constant may be written with an optional decimal part +A numerical constant can be written with an optional decimal part and an optional decimal exponent. Lua also accepts integer hexadecimal constants, by prefixing them with 0x. @@ -288,7 +278,7 @@ see file luaconf.h.) String represents arrays of characters. Lua is 8-bit clean: -strings may contain any 8-bit character, +strings can contain any 8-bit character, including embedded zeros ('\0') (see §2.1). @@ -327,7 +317,7 @@ but with any value (except nil). Tables can be heterogeneous; that is, they can contain values of all types (except nil). Tables are the sole data structuring mechanism in Lua; -they may be used to represent ordinary arrays, +they can be used to represent ordinary arrays, symbol tables, sets, records, graphs, trees, etc. To represent records, Lua uses the field name as an index. The language supports this representation by @@ -341,8 +331,8 @@ Like indices, the value of a table field can be of any type (except nil). In particular, because functions are first-class values, -table fields may contain functions. -Thus tables may also carry methods (see §2.5.9). +table fields can contain functions. +Thus tables can also carry methods (see §2.5.9).

@@ -477,7 +467,7 @@ We use them here only for explanatory purposes.) Lua supports an almost conventional set of statements, similar to those in Pascal or C. This set includes -assignment, control structures, function calls, +assignments, control structures, function calls, and variable declarations. @@ -505,15 +495,15 @@ receive arguments, and return values.

-A chunk may be stored in a file or in a string inside the host program. -When a chunk is executed, first it is pre-compiled into instructions for -a virtual machine, -and then the compiled code is executed -by an interpreter for the virtual machine. +A chunk can be stored in a file or in a string inside the host program. +To execute a chunk, +Lua first pre-compiles the chunk into instructions for a virtual machine, +and then it executes the compiled code +with an interpreter for the virtual machine.

-Chunks may also be pre-compiled into binary form; +Chunks can also be pre-compiled into binary form; see program luac for details. Programs in source and compiled forms are interchangeable; Lua automatically detects the file type and acts accordingly. @@ -532,7 +522,7 @@ syntactically, a block is the same as a chunk:

-A block may be explicitly delimited to produce a single statement: +A block can be explicitly delimited to produce a single statement:

 	stat ::= do block end
@@ -550,7 +540,7 @@ of another block (see §2.4.4).
 

2.4.3 - Assignment

-Lua allows multiple assignment. +Lua allows multiple assignments. Therefore, the syntax for assignment defines a list of variables on the left side and a list of expressions on the right side. @@ -573,7 +563,7 @@ the excess values are thrown away. If there are fewer values than needed, the list is extended with as many nil's as needed. If the list of expressions ends with a function call, -then all values returned by this call enter in the list of values, +then all values returned by that call enter the list of values, before the adjustment (except when the call is enclosed in parentheses; see §2.5). @@ -595,7 +585,13 @@ Similarly, the line

      x, y = y, x
 

-exchanges the values of x and y. +exchanges the values of x and y, +and + +

+     x, y, z = y, z, x
+

+cyclically permutes the values of x, y, and z.

@@ -644,7 +640,7 @@ Lua also has a for statement, in two flavors (see §

The condition expression of a -control structure may return any value. +control structure can return any value. Both false and nil are considered false. All values different from nil and false are considered true (in particular, the number 0 and the empty string are also true). @@ -662,8 +658,8 @@ declared inside the loop block. The return statement is used to return values from a function or a chunk (which is just a function). -Functions and chunks may return more than one value, -so the syntax for the return statement is +Functions and chunks can return more than one value, +and so the syntax for the return statement is

 	stat ::= return [explist]
@@ -745,7 +741,7 @@ They must all result in numbers.
 
 
  • var, limit, and step are invisible variables. -The names are here for explanatory purposes only. +The names shown here are for explanatory purposes only.
  • @@ -842,8 +838,8 @@ Function calls are explained in §2.5.8.

    2.4.7 - Local Declarations

    -Local variables may be declared anywhere inside a block. -The declaration may include an initial assignment: +Local variables can be declared anywhere inside a block. +The declaration can include an initial assignment:

     	stat ::= local namelist [`=´ explist]
    @@ -908,12 +904,12 @@ and the unary length operator (see §2.5.5).
     
     
     

    -Both function calls and vararg expressions may result in multiple values. -If the expression is used as a statement (see §2.4.6) -(only possible for function calls), +Both function calls and vararg expressions can result in multiple values. +If an expression is used as a statement +(only possible for function calls (see §2.4.6)), then its return list is adjusted to zero elements, thus discarding all returned values. -If the expression is used as the last (or the only) element +If an expression is used as the last (or the only) element of a list of expressions, then no adjustment is made (unless the call is enclosed in parentheses). @@ -931,7 +927,7 @@ Here are some examples: g(x, f()) -- g gets x plus all results from f() a,b,c = f(), x -- f() is adjusted to 1 result (c gets nil) a,b = ... -- a gets the first vararg parameter, b gets - -- the second (both a and b may get nil if there + -- the second (both a and b can get nil if there -- is no corresponding vararg parameter) a,b,c = x, f() -- f() is adjusted to 2 results @@ -945,7 +941,7 @@ Here are some examples:

    -An expression enclosed in parentheses always results in only one value. +Any expression enclosed in parentheses always results in only one value. Thus, (f(x,y,z)) is always a single value, even if f returns several values. @@ -1023,6 +1019,8 @@ Otherwise, if both arguments are strings, then their values are compared according to the current locale. Otherwise, Lua tries to call the "lt" or the "le" metamethod (see §2.8). +A comparison a > b is translated to b < a +and a >= b is translated to b <= a. @@ -1060,7 +1058,7 @@ Here are some examples: 10 and 20 --> 20

  • (In this manual, ---> indicates the result of the preceding expression.) +--> indicates the result of the preceding expression.) @@ -1090,13 +1088,13 @@ character is one byte). The length of a table t is defined to be any integer index n such that t[n] is not nil and t[n+1] is nil; -moreover, if t[1] is nil, n may be zero. +moreover, if t[1] is nil, n can be zero. For a regular array, with non-nil values from 1 to a given n, its length is exactly that n, the index of its last value. If the array has "holes" (that is, nil values between other non-nil values), -then #t may be any of the indices that +then #t can be any of the indices that directly precedes a nil value (that is, it may consider any such nil value as the end of the array). @@ -1132,7 +1130,7 @@ All other binary operators are left associative.

    2.5.7 - Table Constructors

    Table constructors are expressions that create tables. Every time a constructor is evaluated, a new table is created. -Constructors can be used to create empty tables, +A constructor can be used to create an empty table or to create a table and initialize some of its fields. The general syntax for constructors is @@ -1179,12 +1177,12 @@ and the expression is a function call or a vararg expression, then all values returned by this expression enter the list consecutively (see §2.5.8). To avoid this, -enclose the function call (or the vararg expression) +enclose the function call or the vararg expression in parentheses (see §2.5).

    -The field list may have an optional trailing separator, +The field list can have an optional trailing separator, as a convenience for machine-generated code. @@ -1349,8 +1347,8 @@ the function is instantiated (or closed). This function instance (or closure) is the final value of the expression. Different instances of the same function -may refer to different external local variables -and may have different environment tables. +can refer to different external local variables +and can have different environment tables.

    @@ -1377,7 +1375,7 @@ or in the middle of a list of expressions, then its return list is adjusted to one element. If the expression is used as the last element of a list of expressions, then no adjustment is made -(unless the call is enclosed in parentheses). +(unless that last expression is enclosed in parentheses).

    @@ -1520,7 +1518,7 @@ you can use the pcall function.

    2.8 - Metatables

    -Every value in Lua may have a metatable. +Every value in Lua can have a metatable. This metatable is an ordinary Lua table that defines the behavior of the original value under certain special operations. @@ -1549,22 +1547,22 @@ You can replace the metatable of tables through the setmetatable function. You cannot change the metatable of other types from Lua -(except using the debug library); +(except by using the debug library); you must use the C API for that.

    Tables and full userdata have individual metatables -(although multiple tables and userdata can share their metatables); -values of all other types share one single metatable per type. -So, there is one single metatable for all numbers, +(although multiple tables and userdata can share their metatables). +Values of all other types share one single metatable per type; +that is, there is one single metatable for all numbers, one for all strings, etc.

    -A metatable may control how an object behaves in arithmetic operations, +A metatable controls how an object behaves in arithmetic operations, order comparisons, concatenation, length operation, and indexing. -A metatable can also define a function to be called when a userdata +A metatable also can define a function to be called when a userdata is garbage collected. For each of these operations Lua associates a specific key called an event. @@ -1806,7 +1804,7 @@ the < operation. if h then return (h(op1, op2)) else - error(···); + error(···) end end end @@ -1833,7 +1831,7 @@ the <= operation. if h then return not h(op2, op1) else - error(···); + error(···) end end end @@ -1860,7 +1858,7 @@ The indexing access table[key]. else h = metatable(table).__index if h == nil then - error(···); + error(···) end end if type(h) == "function" then @@ -1886,7 +1884,7 @@ The indexing assignment table[key] = value. else h = metatable(table).__newindex if h == nil then - error(···); + error(···) end end if type(h) == "function" then @@ -1934,6 +1932,17 @@ multiple objects can share the same environment.

    +Threads are created sharing the environment of the creating thread. +Userdata and C functions are created sharing the environment +of the creating C function. +Non-nested Lua functions +(created by loadfile, loadstring or load) +are created sharing the environment of the creating thread. +Nested Lua functions are created sharing the environment of +the creating Lua function. + + +

    Environments associated with userdata have no meaning for Lua. It is only a convenience feature for programmers to associate a table to a userdata. @@ -1942,23 +1951,22 @@ a userdata.

    Environments associated with threads are called global environments. -They are used as the default environment for their threads and -non-nested functions created by the thread -(through loadfile, loadstring or load) +They are used as the default environment for threads and +non-nested Lua functions created by the thread and can be directly accessed by C code (see §3.3).

    -Environments associated with C functions can be directly +The environment associated with a C function can be directly accessed by C code (see §3.3). -They are used as the default environment for other C functions -created by the function. +It is used as the default environment for other C functions +and userdata created by the function.

    Environments associated with Lua functions are used to resolve all accesses to global variables within the function (see §2.3). -They are used as the default environment for other Lua functions +They are used as the default environment for nested Lua functions created by the function. @@ -1985,9 +1993,9 @@ nor about freeing it when the objects are no longer needed. Lua manages memory automatically by running a garbage collector from time to time to collect all dead objects -(that is, these objects that are no longer accessible from Lua). -All objects in Lua are subject to automatic management: -tables, userdata, functions, threads, and strings. +(that is, objects that are no longer accessible from Lua). +All memory used by Lua is subject to automatic management: +tables, userdata, functions, threads, strings, etc.

    @@ -1995,15 +2003,17 @@ Lua implements an incremental mark-and-sweep collector. It uses two numbers to control its garbage-collection cycles: the garbage-collector pause and the garbage-collector step multiplier. +Both use percentage points as units +(so that a value of 100 means an internal value of 1).

    The garbage-collector pause controls how long the collector waits before starting a new cycle. Larger values make the collector less aggressive. -Values smaller than 1 mean the collector will not wait to +Values smaller than 100 mean the collector will not wait to start a new cycle. -A value of 2 means that the collector waits for the total memory in use +A value of 200 means that the collector waits for the total memory in use to double before starting a new cycle. @@ -2013,17 +2023,15 @@ controls the relative speed of the collector relative to memory allocation. Larger values make the collector more aggressive but also increase the size of each incremental step. -Values smaller than 1 make the collector too slow and -may result in the collector never finishing a cycle. -The default, 2, means that the collector runs at "twice" +Values smaller than 100 make the collector too slow and +can result in the collector never finishing a cycle. +The default, 200, means that the collector runs at "twice" the speed of memory allocation.

    You can change these numbers by calling lua_gc in C or collectgarbage in Lua. -Both get percentage points as arguments -(so an argument of 100 means a real value of 1). With these functions you can also control the collector directly (e.g., stop and restart it). @@ -2100,7 +2108,7 @@ the values in the table are weak.

    After you use a table as a metatable, -you should not change the value of its field __mode. +you should not change the value of its __mode field. Otherwise, the weak behavior of the tables controlled by this metatable is undefined. @@ -2133,7 +2141,7 @@ it does not start the coroutine execution.

    When you first call coroutine.resume, passing as its first argument -the thread returned by coroutine.create, +a thread returned by coroutine.create, the coroutine starts its execution, at the first line of its main function. Extra arguments passed to coroutine.resume are passed on @@ -2383,7 +2391,7 @@ The first value associated with a function is at position lua_upvalueindex(1), and so on. Any access to lua_upvalueindex(n), where n is greater than the number of upvalues of the -current function, +current function (but not greater than 256), produces an acceptable (but invalid) index. @@ -2431,7 +2439,7 @@ any error jumps to the most recent active recover point.

    -Most functions in the API may throw an error, +Most functions in the API can throw an error, for instance due to a memory allocation error. The documentation for each function indicates whether it can throw errors. @@ -2459,7 +2467,7 @@ is how many elements the function pops from the stack. The second field, p, is how many elements the function pushes onto the stack. (Any function always pushes its results after popping its arguments.) -A field in the form x|y means the function may push (or pop) +A field in the form x|y means the function can push (or pop) x or y elements, depending on the situation; an interrogation mark '?' means that @@ -2544,7 +2552,7 @@ If an error happens outside any protected environment, Lua calls a panic function and then calls exit(EXIT_FAILURE), thus exiting the host application. -Your panic function may avoid this exit by +Your panic function can avoid this exit by never returning (e.g., doing a long jump). @@ -2589,7 +2597,7 @@ Any error inside the called function is propagated upwards

    -The following example shows how the host program may do the +The following example shows how the host program can do the equivalent to this Lua code:

    @@ -2858,13 +2866,13 @@ garbage-collection cycle.
     
     
     
  • LUA_GCSETPAUSE: -sets data/100 as the new value +sets data as the new value for the pause of the collector (see §2.10). The function returns the previous value of the pause.
  • LUA_GCSETSTEPMUL: -sets data/100 as the new value for the step multiplier of +sets data as the new value for the step multiplier of the collector (see §2.10). The function returns the previous value of the step multiplier.
  • @@ -3485,6 +3493,10 @@ associated with the function. lua_pushcclosure also pops these values from the stack. +

    +The maximum value for n is 255. + + @@ -3774,7 +3786,8 @@ The reader must return a pointer to a block of memory with a new piece of the chunk and set size to the block size. The block must exist until the reader function is called again. -To signal the end of the chunk, the reader must return NULL. +To signal the end of the chunk, +the reader must return NULL or set size to zero. The reader function may return pieces of any size greater than zero. @@ -4081,7 +4094,7 @@ when lua_tolstring is applied to keys to a string inside the Lua state. This string always has a zero ('\0') after its last character (as in C), -but may contain other zeros in its body. +but can contain other zeros in its body. Because Lua has garbage collection, there is no guarantee that the pointer returned by lua_tolstring will be valid after the corresponding value is removed from the stack. @@ -4112,7 +4125,7 @@ otherwise, lua_tonumber returns 0.

    Converts the value at the given acceptable index to a generic C pointer (void*). -The value may be a userdata, a table, a thread, or a function; +The value can be a userdata, a table, a thread, or a function; otherwise, lua_topointer returns NULL. Different objects will give different pointers. There is no way to convert the pointer back to its original value. @@ -4350,8 +4363,8 @@ When no line information is available, a reasonable name for the given function. Because functions in Lua are first-class values, they do not have a fixed name: -some functions may be the value of multiple global variables, -while others may be stored only in a table field. +some functions can be the value of multiple global variables, +while others can be stored only in a table field. The lua_getinfo function checks how the function was called to find a suitable name. If it cannot find a name, @@ -4581,7 +4594,7 @@ and LUA_HOOKCOUNT. Moreover, for line events, the field currentline is also set. To get the value of any other field in ar, the hook must call lua_getinfo. -For return events, event may be LUA_HOOKRET, +For return events, event can be LUA_HOOKRET, the normal value, or LUA_HOOKTAILRET. In the latter case, Lua is simulating a return from a function that did a tail call; @@ -5632,7 +5645,7 @@ Currently, Lua has the following standard libraries:

      -
    • basic library;
    • +
    • basic library,
    • which includes the coroutine sub-library;
    • package library;
    • @@ -5731,13 +5744,15 @@ Returns true if the step finished a collection cycle.
    • "setpause": -sets arg/100 as the new value for the pause of +sets arg as the new value for the pause of the collector (see §2.10). +Returns the previous value for pause.
    • "setstepmul": -sets arg/100 as the new value for the step multiplier of +sets arg as the new value for the step multiplier of the collector (see §2.10). +Returns the previous value for step.
    @@ -5842,7 +5857,7 @@ up to the first integer key absent from the table. Loads a chunk using function func to get its pieces. Each call to func must return a string that concatenates with previous results. -A return of nil (or no value) signals the end of the chunk. +A return of an empty string, nil, or no value signals the end of the chunk.

    @@ -6088,7 +6103,7 @@ The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. -In base 10 (the default), the number may have a decimal part, +In base 10 (the default), the number can have a decimal part, as well as an optional exponent part (see §2.1). In other bases, only unsigned integers are accepted. @@ -6335,7 +6350,7 @@ field b of global a.

    -This function may receive optional options after +This function can receive optional options after the module name, where each option is a function to be applied over the module. @@ -6442,7 +6457,7 @@ When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. -The function may return another function (the module loader) +The function can return another function (the module loader) or a string explaining why it did not find that module (or nil if it has nothing to say). Lua initializes this table with four functions. @@ -6618,6 +6633,10 @@ can be written as s:byte(i).

    +The string library assumes one-byte character encodings. + + +


    string.byte (s [, i [, j]])

    Returns the internal numerical codes of the characters s[i], s[i+1], ···, s[j]. @@ -6667,7 +6686,7 @@ where this occurrence starts and ends; otherwise, it returns nil. A third, optional numerical argument init specifies where to start the search; -its default value is 1 and may be negative. +its default value is 1 and can be negative. A value of true as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain "find substring" operation, @@ -6771,7 +6790,7 @@ Returns a copy of s in which all (or the first n, if given) occurrences of the pattern have been replaced by a replacement string specified by repl, -which may be a string, a table, or a function. +which can be a string, a table, or a function. gsub also returns, as its second value, the total number of matches that occurred. @@ -6869,7 +6888,7 @@ If pattern specifies no captures, then the whole match is returned. A third, optional numerical argument init specifies where to start the search; -its default value is 1 and may be negative. +its default value is 1 and can be negative. @@ -6893,7 +6912,7 @@ Returns a string that is the string s reversed.

    string.sub (s, i [, j])

    Returns the substring of s that starts at i and continues until j; -i and j may be negative. +i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length). In particular, @@ -6962,9 +6981,9 @@ when used to represent itself in a pattern.
  • [set]: represents the class which is the union of all characters in set. -A range of characters may be specified by +A range of characters can be specified by separating the end characters of the range with a '-'. -All classes %x described above may also be used as +All classes %x described above can also be used as components in set. All other characters in set represent themselves. For example, [%w_] (or [_%w]) @@ -7001,7 +7020,7 @@ In particular, the class [a-z] may not be equivalent to %lPattern Item:

    -A pattern item may be +A pattern item can be

      @@ -7070,7 +7089,7 @@ At other positions,

      Captures:

      -A pattern may contain sub-patterns enclosed in parentheses; +A pattern can contain sub-patterns enclosed in parentheses; they describe captures. When a match succeeds, the substrings of the subject string that match captures are stored (captured) for future use. @@ -7320,7 +7339,8 @@ Returns the largest integer smaller than or equal to x.

      -Returns the remainder of the division of x by y. +Returns the remainder of the division of x by y +that rounds the quotient towards zero. @@ -7657,7 +7677,7 @@ The mode string can be any of the following:

    • "a+": append update mode, previous data is preserved, writing is only allowed at the end of file.

    -The mode string may also have a 'b' at the end, +The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen. @@ -8115,6 +8135,22 @@ The file must be explicitly opened before its use and explicitly removed when no longer needed. +

    +On some systems (POSIX), +this function also creates a file with that name, +to avoid security risks. +(Someone else might create the file with wrong permissions +in the time between getting the name and creating the file.) +You still have to open the file to use it +and to remove it (even if you do not use it). + + +

    +When possible, +you may prefer to use io.tmpfile, +which automatically removes the file when the program ends. + + @@ -8207,7 +8243,7 @@ then getinfo returns nil.

    -The returned table may contain all the fields returned by lua_getinfo, +The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. @@ -8326,7 +8362,8 @@ When called without arguments,

    When the hook is called, its first parameter is a string describing the event that has triggered its call: -"call", "return" (or "tail return"), +"call", "return" (or "tail return", +when simulating a return from a tail call), "line", and "count". For line events, the hook also gets the new line number as its second parameter. @@ -8754,10 +8791,10 @@ Here is the complete syntax of Lua in extended BNF.


    Last update: -Fri Jan 18 22:32:24 BRST 2008 +Mon Aug 18 13:25:46 BRT 2008 diff --git a/com32/lua/doc/readme.html b/com32/lua/doc/readme.html index 972fadd..38be6db 100644 --- a/com32/lua/doc/readme.html +++ b/com32/lua/doc/readme.html @@ -12,7 +12,7 @@ Documentation -This is the documentation included in the source distribution of Lua 5.1.3. +This is the documentation included in the source distribution of Lua 5.1.4.
    • Reference manual @@ -33,7 +33,7 @@ especially the
      Last update: -Wed Dec 19 13:59:14 BRST 2007 +Tue Aug 12 14:46:07 BRT 2008 diff --git a/com32/lua/etc/lua.pc b/com32/lua/etc/lua.pc index 19a5c91..f52f55b 100644 --- a/com32/lua/etc/lua.pc +++ b/com32/lua/etc/lua.pc @@ -5,7 +5,7 @@ # grep '^V=' ../Makefile V= 5.1 # grep '^R=' ../Makefile -R= 5.1.3 +R= 5.1.4 # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' prefix= /usr/local diff --git a/com32/lua/src/Makefile b/com32/lua/src/Makefile index 72f3168..b89f59d 100644 --- a/com32/lua/src/Makefile +++ b/com32/lua/src/Makefile @@ -24,6 +24,7 @@ LNXLIBS = # Temporarily allow warnings not being treated as errors #GCCWARN += -Wno-error +CFLAGS += -DSYSLINUX MODULES = lua.c32 TESTFILES = diff --git a/com32/lua/src/lapi.c b/com32/lua/src/lapi.c index d7e8931..5d5145d 100644 --- a/com32/lua/src/lapi.c +++ b/com32/lua/src/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $ +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -93,15 +93,14 @@ void luaA_pushobject (lua_State *L, const TValue *o) { LUA_API int lua_checkstack (lua_State *L, int size) { - int res; + int res = 1; lua_lock(L); - if ((L->top - L->base + size) > LUAI_MAXCSTACK) + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) res = 0; /* stack overflow */ - else { + else if (size > 0) { luaD_checkstack(L, size); if (L->ci->top < L->top + size) L->ci->top = L->top + size; - res = 1; } lua_unlock(L); return res; @@ -930,10 +929,13 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { g->GCthreshold = g->totalbytes - a; else g->GCthreshold = 0; - while (g->GCthreshold <= g->totalbytes) + while (g->GCthreshold <= g->totalbytes) { luaC_step(L); - if (g->gcstate == GCSpause) /* end of cycle? */ - res = 1; /* signal it */ + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } break; } case LUA_GCSETPAUSE: { diff --git a/com32/lua/src/lauxlib.c b/com32/lua/src/lauxlib.c index 58d196c..dba49f2 100644 --- a/com32/lua/src/lauxlib.c +++ b/com32/lua/src/lauxlib.c @@ -552,9 +552,6 @@ static int errfile (lua_State *L, const char *what, int fnameindex) { LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { LoadF lf; int status, readstatus; -#if 0 - int c; -#endif int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ lf.extraline = 0; if (filename == NULL) { @@ -566,7 +563,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { lf.f = fopen(filename, "r"); if (lf.f == NULL) return errfile(L, "open", fnameindex); } -#if 0 +#ifndef SYSLINUX + int c; c = getc(lf.f); if (c == '#') { /* Unix exec. file? */ lf.extraline = 1; diff --git a/com32/lua/src/lbaselib.c b/com32/lua/src/lbaselib.c index eb06bce..2a4c079 100644 --- a/com32/lua/src/lbaselib.c +++ b/com32/lua/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $ +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -344,10 +344,12 @@ static int luaB_unpack (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); i = luaL_optint(L, 2, 1); e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ n = e - i + 1; /* number of elements */ - if (n <= 0) return 0; /* empty range */ - luaL_checkstack(L, n, "table too big to unpack"); - for (; i<=e; i++) /* push arg[i...e] */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ lua_rawgeti(L, 1, i); return n; } @@ -526,7 +528,7 @@ static int auxresume (lua_State *L, lua_State *co, int narg) { status = lua_resume(co, narg); if (status == 0 || status == LUA_YIELD) { int nres = lua_gettop(co); - if (!lua_checkstack(L, nres)) + if (!lua_checkstack(L, nres + 1)) luaL_error(L, "too many results to resume"); lua_xmove(co, L, nres); /* move yielded values */ return nres; diff --git a/com32/lua/src/ldebug.c b/com32/lua/src/ldebug.c index 9eac4a9..50ad3d3 100644 --- a/com32/lua/src/ldebug.c +++ b/com32/lua/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $ +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -275,12 +275,12 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { static int precheck (const Proto *pt) { check(pt->maxstacksize <= MAXSTACK); - lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); - lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) || + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || (pt->is_vararg & VARARG_HASARG)); check(pt->sizeupvalues <= pt->nups); check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); - check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); return 1; } @@ -346,9 +346,18 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { int dest = pc+1+b; check(0 <= dest && dest < pt->sizecode); if (dest > 0) { - /* cannot jump to a setlist count */ - Instruction d = pt->code[dest-1]; - check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)); + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); } } break; @@ -363,7 +372,11 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { } switch (op) { case OP_LOADBOOL: { - check(c == 0 || pc+2 < pt->sizecode); /* check its jump */ + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } break; } case OP_LOADNIL: { @@ -428,7 +441,10 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { } case OP_SETLIST: { if (b > 0) checkreg(pt, a + b); - if (c == 0) pc++; + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } break; } case OP_CLOSURE: { diff --git a/com32/lua/src/linit.c b/com32/lua/src/linit.c index 3f15fd0..74ca164 100644 --- a/com32/lua/src/linit.c +++ b/com32/lua/src/linit.c @@ -19,16 +19,19 @@ static const luaL_Reg lualibs[] = { {LUA_LOADLIBNAME, luaopen_package}, {LUA_TABLIBNAME, luaopen_table}, {LUA_IOLIBNAME, luaopen_io}, -// {LUA_OSLIBNAME, luaopen_os}, +#ifndef SYSLINUX + {LUA_OSLIBNAME, luaopen_os}, +#endif {LUA_STRLIBNAME, luaopen_string}, #if !defined LUA_NUMBER_INTEGRAL {LUA_MATHLIBNAME, luaopen_math}, #endif - {LUA_PCILIBNAME, luaopen_pci}, {LUA_DBLIBNAME, luaopen_debug}, +#ifdef SYSLINUX {LUA_DMILIBNAME, luaopen_dmi}, {LUA_SYSLINUXLIBNAME, luaopen_syslinux}, {LUA_VESALIBNAME, luaopen_vesa}, +#endif {NULL, NULL} }; diff --git a/com32/lua/src/liolib.c b/com32/lua/src/liolib.c index d979f45..9efa75f 100644 --- a/com32/lua/src/liolib.c +++ b/com32/lua/src/liolib.c @@ -180,7 +180,7 @@ static int io_popen (lua_State *L) { } -#if 0 +#ifndef SYSLINUX static int io_tmpfile (lua_State *L) { FILE **pf = newfile(L); *pf = tmpfile(); @@ -271,7 +271,7 @@ static int io_lines (lua_State *L) { ** ======================================================= */ -#if 0 +#ifndef SYSLINUX static int read_number (lua_State *L, FILE *f) { lua_Number d; if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { @@ -312,7 +312,7 @@ static int read_line (lua_State *L, FILE *f) { } } -#if 0 /* Not used */ +#ifndef SYSLINUX /* Not used */ static int read_chars (lua_State *L, FILE *f, size_t n) { size_t rlen; /* how much to read */ size_t nr; /* number of chars actually read */ @@ -329,9 +329,7 @@ static int read_chars (lua_State *L, FILE *f, size_t n) { luaL_pushresult(&b); /* close buffer */ return (n == 0 || lua_objlen(L, -1) > 0); } -#endif -#if 0 static int g_read (lua_State *L, FILE *f, int first) { int nargs = lua_gettop(L) - 1; int success; @@ -440,7 +438,7 @@ static int f_write (lua_State *L) { return g_write(L, tofile(L), 2); } -#if 0 +#ifndef SYSLINUX static int f_seek (lua_State *L) { static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; static const char *const modenames[] = {"set", "cur", "end", NULL}; @@ -455,10 +453,8 @@ static int f_seek (lua_State *L) { return 1; } } -#endif -#if 0 static int f_setvbuf (lua_State *L) { static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; static const char *const modenames[] = {"no", "full", "line", NULL}; @@ -489,8 +485,10 @@ static const luaL_Reg iolib[] = { {"open", io_open}, {"output", io_output}, {"popen", io_popen}, -/* {"read", io_read}, */ -/* {"tmpfile", io_tmpfile}, */ +#ifndef SYSLINUX + {"read", io_read}, + {"tmpfile", io_tmpfile}, +#endif {"type", io_type}, {"write", io_write}, {NULL, NULL} @@ -501,9 +499,11 @@ static const luaL_Reg flib[] = { {"close", io_close}, {"flush", f_flush}, {"lines", f_lines}, -/* {"read", f_read}, */ -/* {"seek", f_seek}, */ -/* {"setvbuf", f_setvbuf}, */ +#ifndef SYSLINUX + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, +#endif {"write", f_write}, {"__gc", io_gc}, {"__tostring", io_tostring}, diff --git a/com32/lua/src/llex.c b/com32/lua/src/llex.c index 73f01f1..8257e5e 100644 --- a/com32/lua/src/llex.c +++ b/com32/lua/src/llex.c @@ -6,7 +6,9 @@ #include -//#include +#ifndef SYSLINUX +#include +#endif #include #define llex_c @@ -176,9 +178,11 @@ static void buffreplace (LexState *ls, char from, char to) { static void trydecpoint (LexState *ls, SemInfo *seminfo) { /* format error: try to update decimal point separator */ - //struct lconv *cv = localeconv(); char old = ls->decpoint; - //ls->decpoint = (cv ? cv->decimal_point[0] : '.'); +#ifndef SYSLINUX + struct lconv *cv = localeconv(); + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); +#endif buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { /* format error with correct decimal point: no more options */ diff --git a/com32/lua/src/loadlib.c b/com32/lua/src/loadlib.c index b6f4cc6..81d78c7 100644 --- a/com32/lua/src/loadlib.c +++ b/com32/lua/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $ +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -506,8 +506,10 @@ static int ll_require (lua_State *L) { static void setfenv (lua_State *L) { lua_Debug ar; - lua_getstack(L, 1, &ar); - lua_getinfo(L, "f", &ar); + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); lua_pushvalue(L, -2); lua_setfenv(L, -2); lua_pop(L, 1); @@ -589,7 +591,11 @@ static int ll_seeall (lua_State *L) { static void setpath (lua_State *L, const char *fieldname, const char *envname, const char *def) { - const char *path = /*getenv(envname)*/ NULL; +#ifdef SYSLINUX + const char *path = NULL; +#else + const char *path = getenv(envname); +#endif (void)envname; /* Shut up gcc */ if (path == NULL) /* no environment variable? */ lua_pushstring(L, def); /* use default */ diff --git a/com32/lua/src/lobject.h b/com32/lua/src/lobject.h index e7199df..f1e447e 100644 --- a/com32/lua/src/lobject.h +++ b/com32/lua/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -208,7 +208,7 @@ typedef union TString { #define getstr(ts) cast(const char *, (ts) + 1) -#define svalue(o) getstr(tsvalue(o)) +#define svalue(o) getstr(rawtsvalue(o)) diff --git a/com32/lua/src/loslib.c b/com32/lua/src/loslib.c index 740ad0d..2d9b260 100644 --- a/com32/lua/src/loslib.c +++ b/com32/lua/src/loslib.c @@ -66,7 +66,11 @@ static int os_tmpname (lua_State *L) { static int os_getenv (lua_State *L) { - lua_pushstring(L, /*getenv(luaL_checkstring(L, 1))*/); /* if NULL push nil */ +#ifdef SYSLINUX + lua_pushstring(L, NULL); /* if NULL push nil */ +#else + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ +#endif return 1; } diff --git a/com32/lua/src/lstrlib.c b/com32/lua/src/lstrlib.c index 1613cc9..1b4763d 100644 --- a/com32/lua/src/lstrlib.c +++ b/com32/lua/src/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $ +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -35,7 +35,8 @@ static int str_len (lua_State *L) { static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { /* relative string position: negative means back from end */ - return (pos>=0) ? pos : (ptrdiff_t)len+pos+1; + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; } @@ -784,13 +785,11 @@ static int str_format (lua_State *L) { sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); break; } -#if !defined LUA_NUMBER_INTEGRAL case 'e': case 'E': case 'f': case 'g': case 'G': { sprintf(buff, form, (double)luaL_checknumber(L, arg)); break; } -#endif case 'q': { addquoted(L, &b, arg); continue; /* skip the 'addsize' at the end */ diff --git a/com32/lua/src/ltablib.c b/com32/lua/src/ltablib.c index 06f1c37..b6d9cb4 100644 --- a/com32/lua/src/ltablib.c +++ b/com32/lua/src/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $ +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -132,6 +132,15 @@ static int tremove (lua_State *L) { } +static void addfield (lua_State *L, luaL_Buffer *b, int i) { + lua_rawgeti(L, 1, i); + if (!lua_isstring(L, -1)) + luaL_error(L, "invalid value (%s) at index %d in table for " + LUA_QL("concat"), luaL_typename(L, -1), i); + luaL_addvalue(b); +} + + static int tconcat (lua_State *L) { luaL_Buffer b; size_t lsep; @@ -141,13 +150,12 @@ static int tconcat (lua_State *L) { i = luaL_optint(L, 3, 1); last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1)); luaL_buffinit(L, &b); - for (; i <= last; i++) { - lua_rawgeti(L, 1, i); - luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings"); - luaL_addvalue(&b); - if (i != last) - luaL_addlstring(&b, sep, lsep); + for (; i < last; i++) { + addfield(L, &b, i); + luaL_addlstring(&b, sep, lsep); } + if (i == last) /* add last value (if interval was not empty) */ + addfield(L, &b, i); luaL_pushresult(&b); return 1; } diff --git a/com32/lua/src/lua.c b/com32/lua/src/lua.c index 0d2d16c..daa73c1 100644 --- a/com32/lua/src/lua.c +++ b/com32/lua/src/lua.c @@ -4,13 +4,19 @@ ** See Copyright Notice in lua.h */ - -//#include +#ifndef SYSLINUX +#include +#else +#define signal(x,y) +#endif #include #include #include +#ifdef SYSLINUX #include +#endif + #define lua_c #include "lua.h" @@ -25,8 +31,7 @@ static lua_State *globalL = NULL; static const char *progname = LUA_PROGNAME; -#if 0 - +#ifndef SYSLINUX static void lstop (lua_State *L, lua_Debug *ar) { (void)ar; /* unused arg. */ lua_sethook(L, NULL, 0, 0); @@ -99,16 +104,15 @@ static int docall (lua_State *L, int narg, int clear) { int base = lua_gettop(L) - narg; /* function index */ lua_pushcfunction(L, traceback); /* push traceback function */ lua_insert(L, base); /* put it under chunk and args */ - /* signal(SIGINT, laction);*/ + signal(SIGINT, laction); status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); -/* signal(SIGINT, SIG_DFL);*/ + signal(SIGINT, SIG_DFL); lua_remove(L, base); /* remove traceback function */ /* force a complete garbage collection in case of errors */ if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0); return status; } - static void print_version (void) { l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); } @@ -322,7 +326,11 @@ static int runargs (lua_State *L, char **argv, int n) { static int handle_luainit (lua_State *L) { - const char *init = /*getenv(LUA_INIT)*/ NULL; +#ifndef SYSLINUX + const char *init = getenv(LUA_INIT); +#else + const char *init = NULL; +#endif if (init == NULL) return 0; /* status OK */ else if (init[0] == '@') return dofile(L, init+1); @@ -378,9 +386,9 @@ static int pmain (lua_State *L) { int main (int argc, char **argv) { int status; struct Smain s; - +#ifdef SYSLINUX openconsole(&dev_stdcon_r, &dev_stdcon_w); - +#endif lua_State *L = lua_open(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); diff --git a/com32/lua/src/lua.h b/com32/lua/src/lua.h index 3b325a9..5a98b6f 100644 --- a/com32/lua/src/lua.h +++ b/com32/lua/src/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $ +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -15,12 +15,13 @@ #include "luaconf.h" +#ifdef SYSLINUX #define feof(x) 0 #define ferror(x) 0 - +#endif #define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.3" +#define LUA_RELEASE "Lua 5.1.4" #define LUA_VERSION_NUM 501 #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" diff --git a/com32/lua/src/lualib.h b/com32/lua/src/lualib.h index e169a0f..4541550 100644 --- a/com32/lua/src/lualib.h +++ b/com32/lua/src/lualib.h @@ -33,15 +33,16 @@ LUALIB_API int (luaopen_string) (lua_State *L); #define LUA_MATHLIBNAME "math" LUALIB_API int (luaopen_math) (lua_State *L); -#define LUA_PCILIBNAME "pci" -LUALIB_API int (luaopen_pci) (lua_State *L); - #define LUA_DBLIBNAME "debug" LUALIB_API int (luaopen_debug) (lua_State *L); #define LUA_LOADLIBNAME "package" LUALIB_API int (luaopen_package) (lua_State *L); +#ifdef SYSLINUX +#define LUA_PCILIBNAME "pci" +LUALIB_API int (luaopen_pci) (lua_State *L); + #define LUA_SYSLINUXLIBNAME "syslinux" LUALIB_API int (luaopen_syslinux) (lua_State *L); @@ -50,7 +51,7 @@ LUALIB_API int (luaopen_dmi) (lua_State *L); #define LUA_VESALIBNAME "vesa" LUALIB_API int (luaopen_vesa) (lua_State *L); - +#endif /* open all previous libraries */ LUALIB_API void (luaL_openlibs) (lua_State *L); diff --git a/com32/lua/src/lundump.c b/com32/lua/src/lundump.c index 731c064..8010a45 100644 --- a/com32/lua/src/lundump.c +++ b/com32/lua/src/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.7.1.2 2008/01/18 16:39:11 roberto Exp $ +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -48,7 +48,6 @@ static void error(LoadState* S, const char* why) static void LoadBlock(LoadState* S, void* b, size_t size) { size_t r=luaZ_read(S->Z,b,size); - UNUSED(r); IF (r!=0, "unexpected end"); } @@ -115,7 +114,7 @@ static void LoadConstants(LoadState* S, Proto* f) setnilvalue(o); break; case LUA_TBOOLEAN: - setbvalue(o,LoadChar(S)); + setbvalue(o,LoadChar(S)!=0); break; case LUA_TNUMBER: setnvalue(o,LoadNumber(S)); @@ -161,7 +160,9 @@ static void LoadDebug(LoadState* S, Proto* f) static Proto* LoadFunction(LoadState* S, TString* p) { - Proto* f=luaF_newproto(S->L); + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); setptvalue2s(S->L,S->L->top,f); incr_top(S->L); f->source=LoadString(S); if (f->source==NULL) f->source=p; f->linedefined=LoadInt(S); @@ -175,6 +176,7 @@ static Proto* LoadFunction(LoadState* S, TString* p) LoadDebug(S,f); IF (!luaG_checkcode(f), "bad code"); S->L->top--; + S->L->nCcalls--; return f; } diff --git a/com32/lua/src/lvm.c b/com32/lua/src/lvm.c index e65ccc8..c52fa43 100644 --- a/com32/lua/src/lvm.c +++ b/com32/lua/src/lvm.c @@ -4,7 +4,9 @@ ** See Copyright Notice in lua.h */ - +#ifdef SYSLINUX +#define strcoll strcmp +#endif #include #include #include @@ -221,8 +223,7 @@ static int l_strcmp (const TString *ls, const TString *rs) { const char *r = getstr(rs); size_t lr = rs->tsv.len; for (;;) { -// int temp = strcoll(l, r); - int temp = strcmp(l, r); + int temp = strcoll(l, r); if (temp != 0) return temp; else { /* strings are equal up to a `\0' */ size_t len = strlen(l); /* index of first `\0' in both strings */ @@ -341,8 +342,8 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb, case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; - case TM_DIV: setnvalue(ra, luai_lnumdiv(nb, nc)); break; - case TM_MOD: setnvalue(ra, luai_lnummod(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; default: lua_assert(0); break; @@ -500,11 +501,11 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_DIV: { - arith_op(luai_lnumdiv, TM_DIV); + arith_op(luai_numdiv, TM_DIV); continue; } case OP_MOD: { - arith_op(luai_lnummod, TM_MOD); + arith_op(luai_nummod, TM_MOD); continue; } case OP_POW: { -- 2.7.4