aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Renaming two new functionsRoberto Ierusalimschy2025-01-271-3/+3
| | | | | 'lua_numbertostrbuff' -> 'lua_numbertocstring' 'lua_pushextlstring' -> 'lua_pushexternalstring'
* Debug information about extra arguments from __callRoberto Ierusalimschy2024-11-191-8/+16
| | | | | | 'debug.getinfo' can return number of extra arguments added to a call by a chain of __call metavalues. That information is being used to improve error messages about errors in these extra arguments.
* New function 'lua_numbertostrbuff'Roberto Ierusalimschy2024-10-231-4/+3
| | | | | It converts a Lua number to a string in a buffer, without creating a new Lua string.
* No errors in 'luaO_pushvfstring'Roberto Ierusalimschy2024-09-201-1/+1
| | | | | | Any call to 'va_start' must have a corresponding call to 'va_end'; so, functions called between them (luaO_pushvfstring in particular) cannot raise errors.
* GC back to controling pace counting bytesRoberto Ierusalimschy2024-09-191-0/+1
| | | | Memory is the resource we want to save. Still to be reviewed again.
* Added gcc option '-Wconversion'Roberto Ierusalimschy2024-07-271-4/+4
| | | | | No warnings for standard numerical types. Still pending alternative numerical types.
* Length of external strings must fit in Lua integerRoberto Ierusalimschy2024-06-241-3/+5
| | | | (As the length of any string in Lua.)
* lua_writestring & co. moved to llimits.hRoberto Ierusalimschy2024-06-211-6/+0
| | | | They don't need to be visible by clients of Lua.
* llimits.h being used by all Lua codeRoberto Ierusalimschy2024-06-201-0/+1
| | | | | | The definitions in llimits.h are useful not only for the core. That header only defines types and '#define's, so libs and core still do not share any real code/data.
* Bug: luaL_traceback may need more than 5 stack slotsRoberto Ierusalimschy2024-06-121-0/+1
|
* More disciplined use of 'errno'Roberto Ierusalimschy2024-06-121-4/+12
| | | | | | | | | Set errno to zero before calling any function where we may use its errno, and check errno for zero before using it (as functions may not set it even in error). The code assumes that no function will put garbage on errno (although ISO C allows that): If any function during an operation set errno, and the operation result in an error, assume that errno has something to say.
* Manual: errors in lua_toclose are not memory errorsRoberto Ierusalimschy2024-05-231-1/+1
|
* DetailsRoberto Ierusalimschy2024-05-081-1/+1
| | | | | Corrections in comments and manual. Added note in the manual about local variables in the REPL.
* Fixed warnings from different compilersRoberto Ierusalimschy2024-02-151-3/+6
|
* Merge branch 'master' into nextversionRoberto Ierusalimschy2024-01-251-2/+7
|\
| * Panic functions should not raise errorsRoberto Ierusalimschy2023-11-241-2/+7
| | | | | | | | | | The standard panic function was using 'lua_tostring', which may raise a memory-allocation error if error value is a number.
* | Clear interface between references and predefinesRoberto Ierusalimschy2024-01-151-16/+12
| | | | | | | | | | The reference system has a defined way to add initial values to the table where it operates.
* | Comments detailing the ages for generational GCRoberto Ierusalimschy2023-11-291-3/+2
| | | | | | | | Plus other comments and small details.
* | Buffer in 'luai_makeseed' measured in bytesRoberto Ierusalimschy2023-11-151-12/+13
| | | | | | | | | | In the (rare) cases when sizeof(void*) or sizeof(time_t) are not multiples of sizeof(int), we still can use all their bytes in the seed.
* | Auxiliary buffer uses external stringsRoberto Ierusalimschy2023-11-131-16/+38
| | | | | | | | | | The buffer system from the auxiliary library reuses its buffer as external memory when closing long strings.
* | Clock component removed from 'luaL_makeseed'Roberto Ierusalimschy2023-03-231-6/+4
| | | | | | | | 'clock' can be quite slow on some machines.
* | New function 'luaL_makeseed'Roberto Ierusalimschy2023-03-201-1/+49
|/ | | | | | This function unifies code from 'lua_newstate', 'math.randomseed', and 'table.sort' that tries to create a value with a minimum level of randomness.
* Changed the growth rate of string buffersRoberto Ierusalimschy2022-09-061-4/+4
| | | | | | | | The growth rate of string buffers was reduced from 2 to 1.5 (3/2). As string buffers start larger (256~1024 bytes), they don't need to grow that fast. Moreover, a lower rate allows multiplicative growth up to larger sizes (3/2 of the maximum). (After that, the growth becomes linear, which is mostly useless.)
* Simpler handling of Byte Order Mark (BOM)Roberto Ierusalimschy2022-08-231-21/+26
|
* Better documentation for 'multires' expressionsRoberto Ierusalimschy2022-08-191-2/+3
| | | | | | Manual has a new section explaining multires expressions, lists of expressions, and adjustments. This commit also corrects some comments in the code.
* Bug: luaL_tolstring may get confused with negative indexRoberto Ierusalimschy2021-07-221-0/+1
| | | | | When object has a '__name' metafield, 'luaL_tolstring' used the received index after pushing a string on the stack.
* Added assertions for proper use of string buffersRoberto Ierusalimschy2021-03-021-5/+17
|
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-11/+11
| | | | | | More uses of macros 'likely'/'unlikely' (renamed to 'l_likely'/'l_unlikely'), both in range (extended to the libraries) and in scope (extended to hooks, stack growth).
* New API function 'lua_closeslot'Roberto Ierusalimschy2021-01-111-5/+3
| | | | | | Closing a to-be-closed variable with 'lua_settop' is too restrictive, as it erases all slots above the variable. Moreover, it adds side effects to 'lua_settop', which should be a fairly basic function.
* Avoid "bad programming habits" in the reference systemRoberto Ierusalimschy2020-12-031-6/+18
| | | | | | References were using both 0 indices and nils as values in arrays. Both do not fit in the concept of a sequence, which is the kind of use that guides all Lua optimizations.
* 'luaL_newstate' should not allocate extra memoryRoberto Ierusalimschy2020-11-031-24/+48
| | | | | | | | The allocation of a userdata for the state of the warn system can cause a panic if it fails; 'luaL_ref' also can fail. This commit re-implements the warn system so that it does not need an explicit state. Instead, the system uses different functions to represent the different states.
* Keep memory errors as memory errorsRoberto Ierusalimschy2020-07-061-2/+4
| | | | | | | Allow memory errors to be raised through the API (throwing the error with the memory error message); error in external allocations raises a memory error; memory errors in coroutines are re-raised as memory errors.
* Avoid calling 'fprintf' with NULLRoberto Ierusalimschy2020-06-091-1/+3
| | | | | | Avoid undefined behavior in calls like «fprintf("%s", NULL)». ('lua_writestringerror' is implemented as 'fprintf', and 'lua_tostring' can return NULL if object is not a string.)
* Details (more uniformity in error messages)Roberto Ierusalimschy2020-05-271-1/+1
|
* 'luaL_execresult' does not assume -1 status as errorRoberto Ierusalimschy2020-05-221-1/+1
| | | | | | | | | | | ISO C is silent about the return of 'system'. Windows sets 'errno' in case of errors. Linux has several different error cases, with different return values. ISO C allows 'system' to set 'errno' even if there are no errors. Here we assume that a status==0 is success (which is the case on several platforms), otherwise it is an error. If there is an error number, gives the error based on it. (The worst a spurious 'errno' can do is to generate a bad error message.) Otherwise uses the normal results.
* Details in commentsRoberto Ierusalimschy2020-05-071-1/+1
|
* DetailsRoberto Ierusalimschy2020-02-271-1/+1
| | | | | Several details in code (e.g., moving a variable to the most inner scope that encloses its uses), comments, parameter names, extra tests.
* Default for warnings changed to "off"Roberto Ierusalimschy2019-08-201-1/+1
| | | | | Warnings are mostly a tool to help developers (e.g., by showing hidden error messages); regular users usually don't need to see them.
* Added macro 'luaL_pushfail'Roberto Ierusalimschy2019-08-161-3/+3
| | | | | | | | The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'.
* Supressed errors in '__close' generate warningsRoberto Ierusalimschy2019-08-161-2/+2
|
* Added control messages to warningsRoberto Ierusalimschy2019-08-151-10/+24
| | | | | | | Added the concept of control messages to the warning system, plus the implementation of the controls "@on"/"@off" to turn warnings on/off. Moreover, the warning system in the test library adds some other controls to ease the test of warnings.
* Details (typos in comments)Roberto Ierusalimschy2019-07-051-1/+1
|
* Improvements in 'luaL_traceback'Roberto Ierusalimschy2019-05-281-24/+29
| | | | | | | | 'luaL_traceback' changed to use an aux buffer instead of concats. This should reduce the quantity of garbage it generates (in the form of intermediate strings) while producing a trackback. It also added information about the number of levels skipped when skipping levels in a trace.
* DetailsRoberto Ierusalimschy2019-05-131-3/+7
| | | | | | - 'luaL_setfuncs' avoids creating closures for placeholders. - Fixed some warnings about unused values in comma expressions. - Comments.
* New function 'luaL_addgsub'Roberto Ierusalimschy2019-04-241-7/+13
| | | | | | | | Added a new function 'luaL_addgsub', similar to 'luaL_gsub' but that adds its result directly to a preexisting buffer, avoiding the creation of one extra intermediate string. Also added two simple macros, 'luaL_bufflen' and 'luaL_buffaddr', to query the current length and the contents address of a buffer.
* Changes in the warning systemRoberto Ierusalimschy2019-03-141-19/+15
| | | | | | | | - 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.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-281-1/+27
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* Better error messages for some polymorphic functionsRoberto Ierusalimschy2018-12-101-3/+3
| | | | | | | | | 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...)
* Auxiliary buffer cannot close box with 'lua_remove'Roberto Ierusalimschy2018-11-261-5/+7
| | | | | | | 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".)
* String buffer using to-be-closed variableRoberto Ierusalimschy2018-11-131-11/+15
| | | | | The string buffers in the C API now mark their boxes as to-be-closed variables, to release their buffers in case of errors.