summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Revamp of 'lua_pushfstring' / 'luaO_pushvfstring'Roberto Ierusalimschy2019-04-244-44/+177
| | | | | | | | | The function 'luaO_pushvfstring' now uses an internal buffer to concatenate small strings, instead of pushing all pieces on the stack. This avoids the creation of several small Lua strings for each piece of the result. (For instance, a format like "n: '%d'" used to create three intermediate strings: "n: '", the numeral, and "'". Now it creates none.)
* Small correction in test about 'isdst'Roberto Ierusalimschy2019-04-221-1/+1
| | | | | The field 'isdst' can be false, so we cannot test its absence with 'if not D.isdst'; we must compare with nil for a correct test.
* 'require' returns where module was foundRoberto Ierusalimschy2019-04-174-34/+66
| | | | | The function 'require' returns the *loader data* as a second result. For file searchers, this data is the path where they found the module.
* Avoid using large buffers in 'string.format'Roberto Ierusalimschy2019-04-122-20/+29
| | | | | | | The result of "string.format("%.99f", -1e308) is 410 characters long, but all other formats have much smaller limits (at most 99 plus a fex extras). This commit avoids 'string.format' asking for a buffer ~400 chars large when ~100 will do.
* Small optimizations in 'string.gsub'Roberto Ierusalimschy2019-04-113-47/+115
| | | | | | | | | | | Avoid creating extra strings when possible: - avoid creating new resulting string when subject was not modified (instead, return the subject itself); - avoid creating strings representing the captured substrings when handling replacements like '%1' (instead, add the substring directly to the buffer).
* Added an optional parameter to 'coroutine.isyieldable'Roberto Ierusalimschy2019-04-103-6/+11
|
* 'print' does not call 'tostring' to format its argumentsRoberto Ierusalimschy2019-04-103-28/+16
|
* Thorough revision of the reference manualRoberto Ierusalimschy2019-04-101-341/+351
|
* Corrected tests around non-portable 'isdst' in datesRoberto Ierusalimschy2019-04-091-3/+7
| | | | | The field 'isdst' in date tables may not be present; portable tests should not assume it is.
* Syntax should not allow numbers touching identifiersRoberto Ierusalimschy2019-04-092-0/+11
| | | | Code like 'a = 1print()' should not be accepted.
* Fixed wrong error message in 'return math.seed(0)'Roberto Ierusalimschy2019-04-043-5/+11
| | | | | | Bug introduced in commit 28d829c8: OP_TAILCALL might raise an error without saving 'pc'. (This commit also fixes a detail in 'testes/uf8.lua'.)
* Added field 'srclen' to structure 'lua_Debug'Roberto Ierusalimschy2019-04-046-20/+31
| | | | | | This new field gets the length of 'source' in the same structure. Unlike the other strings in that structure, 'source' can be relatively large, and Lua already has its length readily available.
* Avoid moving the collector while in 'GCSenteratomic' stateRoberto Ierusalimschy2019-04-011-2/+2
| | | | | | The 'GCSenteratomic' is just an auxiliary state for transitioning to 'GCSatomic'. All GC traversals should be done either on the 'GCSpropagate' state or the 'GCSatomic' state.
* Small optimizations in range checksRoberto Ierusalimschy2019-03-274-11/+20
| | | | | | | | Checks of the form '1 <= x && x <= M' were rewritten in the form '(unsigned)x - 1 < (unsigned)M', which is usually more efficient. (Other similar checks have similar translations.) Although some compilers do these optimizations, that does not happen for all compilers or all cases.
* LUAI_MAXCCALLS renamed LUAI_MAXCSTACKRoberto Ierusalimschy2019-03-255-21/+27
| | | | | | | The limit LUAI_MAXCCALLS was renamed LUAI_MAXCSTACK, which better represents its meaning. Moreover, its definition was moved to 'luaconf.h', given its importance now that Lua does not use a "stackless" implementation.
* Year in copyright notice updated to 2019Roberto Ierusalimschy2019-03-252-3/+3
|
* Fixed small bugs/issuesRoberto Ierusalimschy2019-03-252-5/+9
| | | | | | | | | | | | | - In 'readutf8esc' (llex.c), the overflow check must be done before shifting the accumulator. It was working because tests were using 64-bit longs. Failed with 32-bit longs. - In OP_FORPREP (lvm.c), avoid negating an unsigned value. Visual Studio gives a warning for that operation, despite being well defined in ISO C. - In 'luaV_execute' (lvm.c), 'cond' can be defined only when needed, like all other variables.
* Keep correct type for immediate operands in comparisonsRoberto Ierusalimschy2019-03-2213-134/+237
| | | | | | | | | | | | When calling metamethods for things like 'a < 3.0', which generates the opcode OP_LTI, the C register tells that the operand was converted to an integer, so that it can be corrected to float when calling a metamethod. This commit also includes some other stuff: - file 'onelua.c' added to the project - opcode OP_PREPVARARG renamed to OP_VARARGPREP - comparison opcodes rewritten through macros
* Details in the implementation of the integer 'for' loopRoberto Ierusalimschy2019-03-212-44/+49
| | | | | | | | Changed some implementation details; in particular, it is back using an internal variable to keep the index, with the control variable being only a copy of that internal variable. (The direct use of the control variable demands a check of its type for each access, which offsets the gains from the use of a single variable.)
* Small changes in the header of binary filesRoberto Ierusalimschy2019-03-194-31/+34
| | | | | | | | | - LUAC_VERSION is equal to LUA_VERSION_NUM, and it is stored as an int. - 'sizeof(int)' and 'sizeof(size_t)' removed from the header, as the binary format does not depend on these sizes. (It uses its own serialization for unsigned integer values.)
* Name 'nonstrict' in the UTF-8 library changed to 'lax'Roberto Ierusalimschy2019-03-192-13/+13
| | | | | It is not a good idea to use negative words to describe boolean values. (When we negate that boolean we create a double negative...)
* New semantics for the integer 'for' loopRoberto Ierusalimschy2019-03-1910-187/+215
| | | | | | | | | | | The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
* Changes in the validation of UTF-8Roberto Ierusalimschy2019-03-156-72/+164
| | | | | | | | | | | All UTF-8 encoding functionality (including the escape sequence '\u') accepts all values from the original UTF-8 specification (with sequences of up to six bytes). By default, the decoding functions in the UTF-8 library do not accept invalid Unicode code points, such as surrogates. A new parameter 'nonstrict' makes them accept all code points up to (2^31)-1, as in the original UTF-8 specification.
* Finalizers must be callableRoberto Ierusalimschy2019-03-142-5/+20
| | | | | Non-function __gc metamethods are not ignored; if present, the metamethod will be called even if it is not a function.
* Changes in the warning systemRoberto Ierusalimschy2019-03-1412-98/+79
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* 'math.randomseed()' sets a somewhat random seedRoberto Ierusalimschy2019-03-133-20/+36
| | | | | | When called with no arguments, 'math.randomseed' uses time and ASLR to generate a somewhat random seed. the initial seed when Lua starts is generated this way.
* Strings inside Lua are not fully alignedRoberto Ierusalimschy2019-03-132-10/+2
| | | | | | Removed code to ensure that strings inside Lua (as returned by 'lua_tolstring') always start in fully aligned addresses. Since version 5.3 the documentation does not ensure that.
* New conversion specifier '%p' for 'string.format'Roberto Ierusalimschy2019-03-133-3/+31
| | | | | The call 'string.format("%p", val)' gives a Lua equivalent to the C API function 'lua_topointer'.
* DetailsRoberto Ierusalimschy2019-03-138-51/+87
| | | | | | | | | | Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard)
* After a "bad collections", avoid switching back back to generationalRoberto Ierusalimschy2019-01-306-50/+134
| | | | | | | After a major bad collection (one that collects too few objects), next collection will be major again. In that case, avoid switching back to generational mode (as it will have to switch again to incremental to do next major collection).
* Optional 'init' argument to 'string.gmatch'Roberto Ierusalimschy2019-01-086-52/+116
| | | | | | | | | The function 'string.gmatch' now has an optional 'init' argument, similar to 'string.find' and 'string.match'. Moreover, there was some reorganization in the manipulation of indices in the string library. This commit also includes small janitorial work in the manual and in comments in the interpreter loop.
* No more to-be-closed functionsRoberto Ierusalimschy2019-01-048-68/+97
| | | | | | | | | | | | | | | | | | | To-be-closed variables must contain objects with '__toclose' metamethods (or nil). Functions were removed for several reasons: * Functions interact badly with sandboxes. If a sandbox raises an error to interrupt a script, a to-be-closed function still can hijack control and continue running arbitrary sandboxed code. * Functions interact badly with coroutines. If a coroutine yields and is never resumed again, its to-be-closed functions will never run. To-be-closed objects, on the other hand, will still be closed, provided they have appropriate finalizers. * If you really need a function, it is easy to create a dummy object to run that function in its '__toclose' metamethod. This comit also adds closing of variables in case of panic.
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-0110-111/+145
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-2810-15/+173
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* Changes in the control of C-stack overflowRoberto Ierusalimschy2018-12-2712-74/+170
| | | | | | | | | | * unification of the 'nny' and 'nCcalls' counters; * external C functions ('lua_CFunction') count more "slots" in the C stack (to allow for their possible use of buffers) * added a new test script specific for C-stack overflows. (Most of those tests were already present, but concentrating them in a single script easies the task of checking whether 'LUAI_MAXCCALLS' is adequate in a system.)
* DetailRoberto Ierusalimschy2018-12-272-3/+2
| | | | Slightly better error message for invalid conversions in 'string.format'.
* 'all' script automatically 'make's everythingRoberto Ierusalimschy2018-12-193-6/+10
| | | | | | The script 'all', to run all tests, automatically ensures that the Lua interpreter and the test C libraries (in 'testes/libs/') are updated with any changes in 'luaconf.h'.
* Added directory 'testes/libs/P1' to the repositoryRoberto Ierusalimschy2018-12-171-0/+2
| | | | | This directory is used for some tests. As standard Lua has no command to create directories, it must be present before running tests.
* DetailsRoberto Ierusalimschy2018-12-173-20/+22
| | | | | A few details in the makefile and in the manual. (In particular, it updates the dependency lists in the makefile.)
* Added file 'testes/heavy.lua'Roberto Ierusalimschy2018-12-141-0/+173
| | | | | | | | | | | | | | | | | | This file is not part of the regular tests. It tests error conditions that demand too much memory or too much time to create: * string with too many characters * control structure with body too large * chunk with too many lines * identifier with too many characters * chunks with too many instructions * function with too many constants * too many strings internalized * table with too many entries In machines with limited memory (less than 150 GB), many tests run up to a "not enough memory" error. We need some memory (~256 GB) to run all tests up to their intrinsic limits.
* Bug: Long brackets with a huge number of '=' causes overflowRoberto Ierusalimschy2018-12-142-14/+35
| | | | | | | A long bracket with too many equal signs can overflow the 'int' used for the counting and some arithmetic done on the value. Changing the counter to 'size_t' avoids that. (Because what is counted goes to a buffer, an overflow in the counter will first raise a buffer-overflow error.)
* New functions 'lua_resetthread' and 'coroutine.kill'Roberto Ierusalimschy2018-12-1311-32/+195
| | | | | | New functions to reset/kill a thread/coroutine, mainly (only?) to close any pending to-be-closed variable. ('lua_resetthread' also allows a thread to be reused...)
* DetailsRoberto Ierusalimschy2018-12-112-17/+14
| | | | | | | | - in 'luaB_tonumber', do not need to "checkany" when argument is a number. - in 'lua_resume', the call to 'luaD_rawrunprotected' cannot return a status equal to -1.
* 'math.rand()' uses higher bits to produce float valueRoberto Ierusalimschy2018-12-112-26/+46
| | | | | | | The call 'math.rand()' converts the higher bits of the internal unsigned integer random to a float, instead of its lower bits. That ensures that Lua compiled with different float precisions always generates equal (up to the available precision) random numbers when given the same seed.
* Better error messages for some polymorphic functionsRoberto Ierusalimschy2018-12-107-12/+41
| | | | | | | | | New auxiliary functions/macros 'luaL_argexpected'/'luaL_typeerror' ease the creation of error messages such as bad argument #2 to 'setmetatable' (nil or table expected, got boolean) (The novelty being the "got boolean" part...)
* Calls cannot be tail in the scope of a to-be-closed variableRoberto Ierusalimschy2018-12-044-16/+21
| | | | | | A to-be-closed variable must be closed when a block ends, so even a 'return foo()' cannot directly returns the results of 'foo'; the function must close the scope before returning.
* A to-be-closed variable must have a closable value (or be nil)Roberto Ierusalimschy2018-11-299-39/+83
| | | | | | | It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
* Auxiliary buffer cannot close box with 'lua_remove'Roberto Ierusalimschy2018-11-263-23/+49
| | | | | | | To remove a to-be-closed variable from the stack in the C API a function must use 'lua_settop' or 'lua_pop'. Previous implementation of 'luaL_pushresult' was not closing the box. (This commit also added tests to check that box is being closed "as soon as possible".)
* Some bugs with stack reallocation by 'luaF_close'Roberto Ierusalimschy2018-11-244-17/+17
| | | | | | | (Long time without testing with '-DHARDSTACKTESTS'...) With the introduction of to-be-closed variables, calls to 'luaF_close' can move the stack, but some call sites where keeping pointers to the stack without correcting them.
* Added opcodes for arithmetic with K operandsRoberto Ierusalimschy2018-11-2311-87/+228
| | | | | | | | Added opcodes for all seven arithmetic operators with K operands (that is, operands that are numbers in the array of constants of the function). They cover the cases of constant float operands (e.g., 'x + .0.0', 'x^0.5') and large integer operands (e.g., 'x % 10000').