Commit Graph

5624 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
0acd55898d Added gcc option '-Wconversion'
No warnings for standard numerical types. Still pending alternative
numerical types.
2024-07-27 13:32:59 -03:00
Roberto Ierusalimschy
15231d4fb2 'nresults' moved into 'callstatus'
That gives us more free bits in 'callstatus', for future use.
2024-07-21 14:56:59 -03:00
Roberto Ierusalimschy
f407b3c4a1 Using CIST_CLSRET instead of trick with 'nresults'
The callstatus flag CIST_CLSRET is used in all tests for the
presence of variables to be closed in C functions.
2024-07-19 17:34:22 -03:00
Roberto Ierusalimschy
a546138d15 Explicit limit for number of results in a call
The parameter 'nresults' in 'lua_call' and similar functions has a
limit of 250. It already had an undocumented (and unchecked) limit of
SHRT_MAX, but it is seldom larger than 2.
2024-07-18 14:44:40 -03:00
Roberto Ierusalimschy
cd4de92762 Maximum stack size may not fit in unsigned short
Therefore, fields ftransfer/ntransfer in lua_Debug must have type
'int'. (Maximum stack size must fit in an 'int'.) Also, this commit
adds check that maximum stack size respects size_t for size in bytes.
2024-07-16 11:33:30 -03:00
Roberto Ierusalimschy
6b45ccf4ed Removed compatibility with "= exp" in the REPL 2024-07-05 15:19:11 -03:00
Roberto Ierusalimschy
93fd6892f8 Fixed bug in 'multiline'
'incomplete' was popping error message that should be used in case
there is no more lines to complete the input, that is, 'pushline'
returns NULL, due to end of file.
2024-07-05 15:13:46 -03:00
Roberto Ierusalimschy
193bf7919e 'printstack' (from ltests.c) made public
That function is useful for debugging the API.
2024-07-05 14:57:11 -03:00
Roberto Ierusalimschy
366c855648 lua.c loads 'readline' dynamically
(See comments in luaconf.h.) This change allows easier compilation,
as Lua compiles and works even if the package 'readline' is absent
from the system. Moreover, non-interactive uses don't load the library,
making the stand-alone slightly faster for small loads.
2024-07-04 17:11:58 -03:00
Roberto Ierusalimschy
781219dbe1 Small changes in casts from void* to functions
Macro moved to llimits.h, and casts from void* to lua_CFunction first
go through 'voidf' (a pointer to a function from void to void), a kind
of void* for functions.
2024-07-02 11:09:46 -03:00
Roberto Ierusalimschy
d71fbc3175 Updated dependencies in the make file
Mainly to include 'llimits.h' in the non-kernel files
2024-07-01 15:58:07 -03:00
Roberto Ierusalimschy
c403e456b6 New instruction format for SETLIST/NEWTABLE
New instruction format 'ivABC' (a variant of iABC where parameter vC has
10 bits) allows constructors of up to 1024 elements to be coded without
EXTRAARG.
2024-06-28 11:18:14 -03:00
Roberto Ierusalimschy
6ac7219da3 'isIT'/'isOT' turned from macros to functions 2024-06-27 15:01:57 -03:00
Roberto Ierusalimschy
9904c253da Flexible limit for use of registers by constructors
Instead of a fixed limit of 50 registers (which, in a bad worst case,
can limit the nesting of constructors to 5 levels), the compiler
computes an individual limit for each constructor based on how many
registers are available when it runs. This limit then controls the
frequency of SETLIST instructions.
2024-06-27 11:24:27 -03:00
Roberto Ierusalimschy
fb7e5b76c9 Clearer code for controlling maximum registers
Plus, added a test to check that limit.
2024-06-26 14:46:44 -03:00
Roberto Ierusalimschy
c1dc08e8e8 Length of external strings must fit in Lua integer
(As the length of any string in Lua.)
2024-06-24 12:03:59 -03:00
Roberto Ierusalimschy
0f7025dcae Details in the manual 2024-06-21 16:36:24 -03:00
Roberto Ierusalimschy
ef28e5f789 Removed 'int' size limit for string.rep 2024-06-21 16:26:49 -03:00
Roberto Ierusalimschy
ec65ab878e Removed 'int' size limit for pack/unpack 2024-06-21 14:55:12 -03:00
Roberto Ierusalimschy
e24ce8c2b3 lua_writestring & co. moved to llimits.h
They don't need to be visible by clients of Lua.
2024-06-21 12:29:08 -03:00
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
55ac40f859 Cleaning of llimits.h
Several definitions that don't need to be "global" (that is, that
concerns only specific parts of the code) moved out of llimits.h,
to more appropriate places.
2024-06-20 13:43:33 -03:00
Roberto Ierusalimschy
97ef8e7bd4 GC test was not restarting collector after pause 2024-06-18 17:14:23 -03:00
Roberto Ierusalimschy
aaf3533653 Tricky _PROMPT may trigger undefined behavior in lua.c 2024-06-12 16:04:25 -03:00
Roberto Ierusalimschy
b529aefc53 Bug: luaL_traceback may need more than 5 stack slots 2024-06-12 16:02:01 -03:00
Roberto Ierusalimschy
d51022bf9e Bug: overlapping assignments
ISO C forbids assignment of a union field to another field of the same
union.
2024-06-12 15:56:13 -03:00
Roberto Ierusalimschy
bb7bb5944c More disciplined use of 'errno'
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.
2024-06-12 15:50:31 -03:00
Roberto Ierusalimschy
94b503d95e Encoding of table indices (hres) must use C indices
As the encoding of array indices is (~index), 0 is encoded as -1 and
INT_MAX is encoded as INT_MIN.
2024-06-10 12:09:35 -03:00
Roberto Ierusalimschy
bdc85357aa Bug: Active-lines for stripped vararg functions
Lua seg. faults when asked to create the 'activelines' table for a
vararg function with no debug information.
2024-06-04 17:27:13 -03:00
Roberto Ierusalimschy
b291008cc2 Manual for 'string.format' lists what it accepts
Instead of listing what it does not accept, which is always relative.
2024-06-04 16:51:31 -03:00
Roberto Ierusalimschy
814213b65f utf8.offset returns also final position of character
'utf8.offset' returns two values: the initial and the final position
of the given character.
2024-05-27 11:29:39 -03:00
Roberto Ierusalimschy
cbdf4969ec Manual: errors in lua_toclose are not memory errors 2024-05-23 09:55:26 -03:00
Roberto Ierusalimschy
262dc5729a Details
Corrections in comments and manual. Added note in the manual about
local variables in the REPL.
2024-05-08 17:50:10 -03:00
Roberto Ierusalimschy
9d985db7bb New year (2024) 2024-05-02 12:03:30 -03:00
Roberto Ierusalimschy
0897c0a428 'getmode' renamed to 'getMode'
The name 'getmode' conficts with a function from BSD, defined
in <unistd.h>. Although 'lbaselib.c' cannot include that header,
'onelua.c' can.
2024-04-08 14:28:26 -03:00
Roberto Ierusalimschy
5edacafcfa Yet another representation for arrays
This "linear" representation (see ltable.h for details) has worse
locality than cells, but the simpler access code seems to compensate
that.
2024-04-05 15:35:11 -03:00
Roberto Ierusalimschy
3507c3380f Small simplification in 'findloader'
Instead of allways adding a prefix for the next message, and then
removing it if there is no message, add the prefix after each message.
2024-04-03 16:01:23 -03:00
Roberto Ierusalimschy
88a50ffa71 Fixed dangling 'StkId' in 'luaV_finishget'
Bug introduced in 05932567.
2024-03-29 15:10:50 -03:00
Roberto Ierusalimschy
86a8e74824 Details 2024-03-28 17:11:33 -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
0593256707 'luaH_get' functions return tag of the result
Undoing previous commit. Returning TValue increases code size without
any visible gains. Returning the tag is a little simpler than returning
a special code (HOK/HNOTFOUND) and the tag is useful by itself in
some cases.
2024-03-21 11:23:21 -03:00
Roberto Ierusalimschy
ce6f5502c9 'luaH_get' functions return 'TValue'
Instead of receiving a parameter telling them where to put the result
of the query, these functions return the TValue directly. (That is,
they return a structure.)
2024-03-18 15:56:32 -03:00
Roberto Ierusalimschy
ba71060381 Removed "bulk operations"
Negligible performance gains don't justify extra complexity.
2024-03-15 11:23:35 -03:00
Roberto Ierusalimschy
3823fc6c81 Added "bulk operations" to arrays
A few operations on arrays can be performed "in bulk", treating all
tags of a cell as a simple (or a few) word(s).
2024-03-15 11:01:34 -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
cc2b66c856 Removed type 'varint_t'
size_t should be big enough to count the number of strings in a dump.
(And, by definition, it is big enough to count the length of each
string.)
2024-03-13 09:16:51 -03:00
Roberto Ierusalimschy
65b07dd53d API asserts for illegal pops of to-be-closed variables 2024-03-11 14:05:06 -03:00
Roberto Ierusalimschy
7237eb3f1c Fixed warnings from different compilers 2024-02-15 11:18:34 -03:00
Roberto Ierusalimschy
165389b27b New interface to function 'luaL_openselectedlibs'
Instead of preloading all non-loaded libraries, there is another
mask to select which libraries to preload.
2024-02-15 11:17:39 -03:00
Roberto Ierusalimschy
c8121ce34b Revising code for Varint encoding in dumps
- Usign lua_Unsigned to count strings.
- Varint uses a type large enough both for size_t and lua_Unsigned.
- Most-Significant Bit 0 means last byte, to conform to common usage.
- (unrelated) Change in macro 'getaddr' so that multiplication is
  by constants.
2024-02-12 15:16:11 -03:00