Commit Graph

114 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
a08d82eb13 llimits.h being used by all Lua code
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.
2024-06-20 14:46:06 -03:00
Roberto Ierusalimschy
9fa63a6268 Some 'unsigned int' changed to 'unsigned'
'unsigned int' is too long sometimes. (We already write 'long' instead
of 'long int'...)
2024-03-22 14:06:11 -03:00
Roberto Ierusalimschy
52aa2b5d24 Details
- 'unsigned int' -> 'unsigned'
- Some explicit casts to avoid warnings
- Test avoids printing the value of 'fail' (which may not be nil)
2024-03-13 09:20:34 -03:00
Roberto Ierusalimschy
0c9bec0d38 Better handling of size limit when resizing a table
Avoid silent conversions from int to unsigned int when calling
'luaH_resize'; avoid silent conversions from lua_Integer to int in
'table.create'; MAXASIZE corrected for the new implementation of arrays;
'luaH_resize' checks explicitly whether new size respects MAXASIZE.
(Even constructors were bypassing that check.)
2024-02-07 13:39:54 -03:00
Roberto Ierusalimschy
3e9dbe143d New function 'table.create'
Creates a table preallocating memory. (It just exports to Lua the API
function 'lua_createtable'.)
2024-01-18 15:16:26 -03:00
Roberto Ierusalimschy
86e8039a72 Clock component removed from 'luaL_makeseed'
'clock' can be quite slow on some machines.
2023-03-23 16:01:16 -03:00
Roberto Ierusalimschy
5a04f1851e New function 'luaL_makeseed'
This function unifies code from 'lua_newstate', 'math.randomseed',
and 'table.sort' that tries to create a value with a minimum level
of randomness.
2023-03-20 16:13:17 -03:00
Roberto Ierusalimschy
cd56f222b7 Corrected error message in 'table.remove' 2022-09-07 12:21:46 -03:00
Roberto Ierusalimschy
deac067ed3 Avoid overflows when incrementing parameters in C
Any C function can receive maxinteger as an integer argument, and
therefore cannot increment it without some care (e.g., doing unsigned
arithmetic as the core does).
2021-09-22 13:10:39 -03:00
Roberto Ierusalimschy
bef250eb8d Details
Comments and small improvements in the manual.
2021-03-29 11:47:12 -03:00
Roberto Ierusalimschy
59c88f846d Broadening the use of branch hints
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).
2021-02-24 11:14:44 -03:00
Roberto Ierusalimschy
c03c527fd2 Bug: 'string.concat' error message uses wrong format 2021-02-15 13:31:45 -03:00
Roberto Ierusalimschy
e888976bc6 Details (typos in comments) 2019-07-05 15:03:15 -03:00
Roberto Ierusalimschy
2c68e66570 Details
Several small changes from feedback on 5.4 alhpa rc1 (warnings,
typos in the manual, and the like)
2019-06-03 11:36:42 -03:00
Roberto Ierusalimschy
0b63d79b36 Details
- 'luaL_setfuncs' avoids creating closures for placeholders.
- Fixed some warnings about unused values in comma expressions.
- Comments.
2019-05-13 16:20:40 -03:00
Roberto Ierusalimschy
d12262068d Small optimizations in range checks
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.
2019-03-27 14:56:10 -03:00
Roberto Ierusalimschy
f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy
03c6a05ec8 no more nil-in-table 2018-04-04 11:23:41 -03:00
Roberto Ierusalimschy
89da4168df avoid functions named 'pack'
(name too common, may collide when doing 'onelua.c')
2018-03-16 11:18:18 -03:00
Roberto Ierusalimschy
34b00c16e2 removed compatibility code with older versions 2018-02-27 15:47:32 -03:00
Roberto Ierusalimschy
d766e2ae17 first (parcial) implementation of 'keyin'/'removekey'
(still no metamethods, no raw verssions)
2018-02-25 09:48:16 -03:00
Roberto Ierusalimschy
7d6b78ee79 in 'table.move', destination table can be source table even if
given as an explicit extra argument
2016-02-25 16:41:54 -03:00
Roberto Ierusalimschy
f79b4568ae details (removed silly use of 'luaL_opt' + better error messages
in cases of "table expected")
2016-02-08 10:55:19 -02:00
Roberto Ierusalimschy
e383941652 in 'table.sort': 'typedef' for type of indices + removed stack check
(recursion is in the C stack, not in the Lua stack!)
2015-12-14 09:57:38 -02:00
Roberto Ierusalimschy
5936eb16d8 randomness in 'table.sort' used only when needed (big imbalance in
partition result) + small refactoring
2015-11-25 10:48:57 -02:00
Roberto Ierusalimschy
7dc3ca7b8e handling 'clock_t' and 'time_t' correctly in ISO C point of view 2015-11-24 14:54:32 -02:00
Roberto Ierusalimschy
c231a5e2b6 using unsigned int (instead of int) in 'table.sort' to avoid overflows
(when computing the pivot and in original table size)
2015-11-23 09:17:31 -02:00
Roberto Ierusalimschy
dc9ac5b8c2 details (merging declarations with initialization) 2015-11-23 09:09:27 -02:00
Roberto Ierusalimschy
146508b28e randomness in pivot for 'table.sort' done by a macro (easier to change) 2015-11-20 10:30:20 -02:00
Roberto Ierusalimschy
bde03eeb48 in 'table.sort': tighter checks for invalid order function +
"random" pivot for larger intervals (to avoid attacks with
bad data)
2015-11-12 16:07:25 -02:00
Roberto Ierusalimschy
02340375be janitor work on 'table.sort': added comments, partition code moved
to a separated function, code conventions updated, etc. No changes
at all in the logic/algorithm
2015-11-06 14:07:14 -02:00
Roberto Ierusalimschy
0f1f51be4b 'table.move' tries to copy elements in increasing order
whenever possible
2015-09-17 12:53:50 -03:00
Roberto Ierusalimschy
bda83e22c0 'tablib' does not try to use raw operations when possible: fast
track should make standard operations fast enough to forgo
raw accesses
2015-09-09 12:42:30 -03:00
Roberto Ierusalimschy
8217e0d4fe avoid subtle possibility of arithmetic overflow 2015-07-04 13:31:42 -03:00
Roberto Ierusalimschy
ae27be40c9 better check for overflows in 'table.move' (removes restriction that
initial position should be positive)
2015-01-13 14:27:29 -02:00
Roberto Ierusalimschy
28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
f97c64d7bf macros 'LUA_QL'/'LUA_QL' deprecated 2014-10-17 13:28:21 -03:00
Roberto Ierusalimschy
6384475ec4 'luaL_getmetafield' returns type of metafield (instead of a boolean) 2014-09-22 03:42:15 -03:00
Roberto Ierusalimschy
7f1a2ad699 new functions 'lua_geti/lua_seti' (non raw) 2014-08-21 17:07:56 -03:00
Roberto Ierusalimschy
a1ab5ab396 'table.copy' -> 'table.move' + optional parameter moved to the end +
several functions operate on "virtual" tables too
2014-08-21 16:13:55 -03:00
Roberto Ierusalimschy
3ccbae84d2 added some casts between integral types (to avoid warnings) 2014-07-29 13:01:00 -03:00
Roberto Ierusalimschy
03bbe1baf1 first implementation for 'table.copy' 2014-07-25 15:46:00 -03:00
Roberto Ierusalimschy
a9af12bbe7 Table library now respects '__index'/'__newindex' metamethods 2014-07-16 09:44:52 -03:00
Roberto Ierusalimschy
17159b491c more direct implementation of 'table.pack' 2014-05-16 15:53:25 -03:00
Roberto Ierusalimschy
b390d7c168 detail (avoid "casting down" in case lua_Integer is smaller than int) 2014-04-12 11:43:50 -03:00
Roberto Ierusalimschy
9737832641 'int' -> 'lua_Integer' in several functions 2014-04-04 13:38:11 -03:00
Roberto Ierusalimschy
315c5bf7b7 bug: compiler could optimize away overflow check (+ changing indices
from 'int' to 'lua_Integer')
2014-04-01 15:50:34 -03:00
Roberto Ierusalimschy
da4811238a details (typos in comments) 2014-03-21 10:52:33 -03:00
Roberto Ierusalimschy
15a3738b49 no need to handle 0 as a special case in 'table.remove' 2013-03-07 15:17:24 -03:00