summaryrefslogtreecommitdiff
path: root/lstrlib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* no more time limits to pattern matching (at least for now)Roberto Ierusalimschy2016-04-221-38/+1
|
* match time limit defined by variable 'string.pattlimit'Roberto Ierusalimschy2016-04-191-16/+36
|
* 'string.format"%q"' now works for all basic types (nil, boolean,Roberto Ierusalimschy2016-04-081-6/+36
| | | | numbers, and strings)
* LUA_PACKPADBYTE -> LUAL_PACKPADBYTE (it is an internal libraryRoberto Ierusalimschy2016-04-071-6/+6
| | | | name, not something to be usually configured)
* new way to avoid infinite loops in empty matches: "Python rule"Roberto Ierusalimschy2016-03-311-8/+8
| | | | | ("Empty matches for the pattern are replaced only when not adjacent to a previous match")
* commentsRoberto Ierusalimschy2016-03-231-12/+12
|
* bug: 'gmatch' iterator fails when called from a coroutine differentRoberto Ierusalimschy2016-03-231-5/+4
| | | | from the one that created it
* '\0' is a control character, no need to check it explicitlyRoberto Ierusalimschy2016-02-251-2/+2
|
* format "%s" in 'string.format' accepts embedded zeros when itv5.3.2Roberto Ierusalimschy2015-11-251-9/+12
| | | | has no modifiers
* ensure argument to 'string.format("%s")' does not contain zerosRoberto Ierusalimschy2015-11-231-1/+2
|
* corrected comparisons of signed (int) with unsigned (size_t)Roberto Ierusalimschy2015-10-291-3/+3
|
* option 'c' in 'string.pack' accepts any string size (truncatingRoberto Ierusalimschy2015-10-281-3/+8
| | | | if larger and padding if smaller)
* detail (removed unreacheable 'break')Roberto Ierusalimschy2015-10-081-2/+2
|
* 'gmatch' keeps its state in a userdata (keeping the same 'MatchState'Roberto Ierusalimschy2015-09-281-20/+26
| | | | across calls)
* implemented counter to abort non-linear behavior in pattern matchingRoberto Ierusalimschy2015-09-261-26/+46
|
* in 'lua_number2strx', use the call to 'l_sprintf' to add exponentRoberto Ierusalimschy2015-07-201-4/+3
| | | | to result directly
* buffer size changed from size_t to int (it is always small) +Roberto Ierusalimschy2015-06-241-7/+10
| | | | comments + assert that printf result fits in given buffer