aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* '-Wconversion' extended to all options of Lua numbersRoberto Ierusalimschy2024-07-271-4/+5
|
* Added gcc option '-Wconversion'Roberto Ierusalimschy2024-07-271-63/+69
| | | | | No warnings for standard numerical types. Still pending alternative numerical types.
* Removed 'int' size limit for string.repRoberto Ierusalimschy2024-06-211-12/+2
|
* Removed 'int' size limit for pack/unpackRoberto Ierusalimschy2024-06-211-29/+38
|
* lua_writestring & co. moved to llimits.hRoberto Ierusalimschy2024-06-211-2/+0
| | | | They don't need to be visible by clients of Lua.
* llimits.h being used by all Lua codeRoberto Ierusalimschy2024-06-201-26/+23
| | | | | | 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.
* Cleaner protocol between 'lua_dump' and writer functionRoberto Ierusalimschy2023-12-141-7/+12
| | | | | 'lua_dump' signals to the writer function the end of a dump, so that is has more freedom when using the stack.
* Merge branch 'master' into nextversionRoberto Ierusalimschy2023-06-221-1/+1
|\
| * Detailsv5.4.5Roberto Ierusalimschy2023-04-181-1/+1
| | | | | | | | Typos in comments and details in the manual.
* | Dump/undump reuse stringsRoberto Ierusalimschy2022-12-151-0/+1
|/ | | | | A repeated string in a dump is represented as an index to its first occurence, instead of another copy of the string.
* DocumentationRoberto Ierusalimschy2021-10-111-1/+1
| | | | | Better explanation about the guaranties of multiple assignment in the manual.
* Revamp of format validation in 'string.format'Roberto Ierusalimschy2021-09-031-26/+86
| | | | | When calling 'sprintf', not all conversion specifiers accept all flags; some combinations are undefined behavior.
* DetailsRoberto Ierusalimschy2021-05-241-10/+7
| | | | | - Removed unused (and trivial) definition LUA_UNSIGNEDBITS - Alignment structure in pack/unpack moved to a narrower scope
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-19/+22
| | | | | | 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).
* Cleaner handling of floats in pack/unpackRoberto Ierusalimschy2020-12-161-29/+41
|
* No need for 'volatile' in string.pack/unpackRoberto Ierusalimschy2020-10-121-10/+7
| | | | Type punning an address to 'char *' should be always safe.
* Wrong cast in 'str_unpack'Roberto Ierusalimschy2020-09-301-1/+1
|
* Fixed bug in 'string.format("%p")'Roberto Ierusalimschy2020-03-161-2/+4
| | | | | The string "(null)" used for non-collectable values must be printed as a string, not as a pointer. (Bug introduced in commit e0cbaa50fa7).
* Corrected direct use of 'snprintf' in 'lstrlib.c'Roberto Ierusalimschy2020-02-281-1/+1
|
* Added test for NULL in string.format("%p")Roberto Ierusalimschy2019-12-171-0/+2
| | | | | | ISO C states that standard library functions should not be called with NULL arguments, unless stated otherwise. 'sprintf' does not state otherwise, and it doesn't hurt to be on the safe side.
* 'l_mathlim' renamed to 'l_floatatt'Roberto Ierusalimschy2019-12-051-2/+2
| | | | That macro is applied to float attributes, not to limits.
* More pious implementation of 'string.dump'Roberto Ierusalimschy2019-10-231-8/+24
| | | | | | | In 'str__dump', the call to 'lua_dump' assumes the function is on the top of the stack, but the manual allows 'luaL_buffinit' to push stuff on the stack (although the current implementation does not). So, the call to 'luaL_buffinit' must come after the call to 'lua_dump'.
* Easy redefinition of valid flags for 'string.format'Roberto Ierusalimschy2019-10-171-3/+6
|
* No coercion string->number in arithmetic with LUA_NOCVTS2NRoberto Ierusalimschy2019-10-081-0/+13
|
* Added macro 'luaL_pushfail'Roberto Ierusalimschy2019-08-161-2/+2
| | | | | | | | 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'.
* Fixed bug in 'string.format' with option '%f'Roberto Ierusalimschy2019-07-231-8/+6
| | | | | | | | | | | As an example, 'print(string.format("%.99f", 1e70))' may have a lot of garbage after the number. The old test to ensure that 'string.format("%.99f", n)' was not too large, 'fabs(n) < 1e100', assumes that the number will fit in the 99 bytes; but the 99 is not the space for the number, it is the added extra zeros. The option worked for smaller numbers because of the extra space added to MAX_ITEM.
* Avoid using large buffers in 'string.format'Roberto Ierusalimschy2019-04-121-12/+28
| | | | | | | 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-111-46/+84
| | | | | | | | | | | 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).
* New conversion specifier '%p' for 'string.format'Roberto Ierusalimschy2019-03-131-0/+5
| | | | | The call 'string.format("%p", val)' gives a Lua equivalent to the C API function 'lua_topointer'.
* DetailsRoberto Ierusalimschy2019-03-131-2/+4
| | | | | | | | | | 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)
* Optional 'init' argument to 'string.gmatch'Roberto Ierusalimschy2019-01-081-24/+52
| | | | | | | | | 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.
* DetailRoberto Ierusalimschy2018-12-271-2/+1
| | | | Slightly better error message for invalid conversions in 'string.format'.
* Better error messages for some polymorphic functionsRoberto Ierusalimschy2018-12-101-2/+2
| | | | | | | | | 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...)
* Removed extra information from RCS keyword stringsRoberto Ierusalimschy2018-08-231-1/+1
| | | | | Version numbers and dates (mostly wrong) from RCS keyword strings removed from all source files; only the file name are kept.
* avoid possible overflows when checking sizes in 'string.unpack'Roberto Ierusalimschy2018-05-251-11/+8
|
* removed coercion string->number in bitwise operationsRoberto Ierusalimschy2018-02-211-59/+1
| | | | (can be done with a Lua module)
* using new 'lua_newuserdatauv' instead of 'lua_newuserdata'Roberto Ierusalimschy2018-02-211-2/+2
|
* detail (typo in comments)Roberto Ierusalimschy2017-11-231-2/+2
|
* detail ('signal' -> 'sign' in comments)Roberto Ierusalimschy2017-11-161-2/+2
|
* new function 'luaV_flttointeger' to convert floats to integers (withoutRoberto Ierusalimschy2017-11-081-9/+71
| | | | | string coercions) + string operands to bitwise operations handled by string metamethods
* coercion string->number in arithmetic operations moved to stringRoberto Ierusalimschy2017-07-071-2/+86
| | | | library
* handling of inf, -inf, and NaN by string.format'%q'Roberto Ierusalimschy2017-05-191-14/+28
|
* added 'return' to calls to 'luaL_error' (to signal to the compilerRoberto Ierusalimschy2017-03-141-4/+4
| | | | that the function cannot continue past that call)
* detail (removing spaces at end of lines)Roberto Ierusalimschy2016-12-221-2/+2
|
* Using LUAI_UAC* types more consistently on vararg callsRoberto Ierusalimschy2016-12-201-7/+9
|
* small corrections for C++ complianceRoberto Ierusalimschy2016-06-271-2/+2
|
* 'string.format("%q")' writes 'math.mininteger' in hexa, to ensureRoberto Ierusalimschy2016-05-201-14/+19
| | | | it is read back as an integer
* 'string.pack("cn")' does not accept strings longer than 'n'Roberto Ierusalimschy2016-05-181-8/+6
|
* comment (FALLTHROUGH)Roberto Ierusalimschy2016-05-131-3/+3
|
* 'string.format("%q", number)' ensures a dot as decimal pointRoberto Ierusalimschy2016-05-021-7/+21
|