Commit Graph

274 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
b7dfd18612 make buffer for format specification a little larger (length modifier
can be larger than 2, e.g. "I64")
2015-02-04 10:54:31 -02:00
Roberto Ierusalimschy
8efcd411fe own implementation for 'string.format("%a")' for C89 platforms 2015-02-04 10:52:57 -02:00
Roberto Ierusalimschy
3509914916 BUG (when compiled with long double): buffer overflow when formatting
string.format("%.99f", 1e4930)
2015-01-13 15:18:25 -02:00
Roberto Ierusalimschy
57e91b4159 correct computation for limit in 'getnum' 2014-12-11 12:03:07 -02:00
Roberto Ierusalimschy
ef7d29c666 better limits for 'sting.rep' and 'string.packsize' 2014-12-11 11:40:40 -02:00
Roberto Ierusalimschy
5c519a69d3 new function 'string.packsize' 2014-12-10 09:36:03 -02:00
Roberto Ierusalimschy
32a1f54b9a no more default size for option 'c' in pack/unpack 2014-12-04 14:25:40 -02:00
Roberto Ierusalimschy
b401d37188 detail (to avoid a "to avoid warnings" return) 2014-11-11 17:40:20 -02:00
Roberto Ierusalimschy
74e10b9c3b details (error messages) 2014-11-08 16:12:53 -02:00
Roberto Ierusalimschy
50b18f60cb detail 2014-11-05 16:55:43 -02:00
Roberto Ierusalimschy
ad73e5156e more direct way to fill sign-extension extra bytes when packing
integers with sizes larger than lua_Integer + added comments
2014-11-05 16:50:29 -02:00
Roberto Ierusalimschy
cfabcbfb17 added macro for configuring padding value in 'string.pack' 2014-11-04 12:34:43 -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
dcfc3c9405 new option '=' (native endian) for pack/unpack 2014-10-31 13:53:31 -02:00
Roberto Ierusalimschy
4542fb9f78 comments (a few extra quotes around identifiers) 2014-10-30 16:53:28 -02:00
Roberto Ierusalimschy
61c3c80177 detail 2014-10-28 16:23:31 -02:00
Roberto Ierusalimschy
fa4d5c8689 pack/unpack do not handle final '\0' as an "option" (it streches
unnecessarily the switch range)
2014-10-27 11:30:24 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
ff9ca88aa6 added some casts to avoid warnings in some compilers 2014-10-24 09:42:29 -02:00
Roberto Ierusalimschy
57559547a3 in 'pack'/'unpack', endianness and alignment treated like options +
small changes in names and handling of internal options ('KOption')
2014-10-20 14:44:54 -02:00
Roberto Ierusalimschy
f97c64d7bf macros 'LUA_QL'/'LUA_QL' deprecated 2014-10-17 13:28:21 -03:00
Roberto Ierusalimschy
c172a4f7c2 'dumpint' and related functions replaced by 'string.pack'/'string.unpack' 2014-10-17 07:55:28 -03:00
Roberto Ierusalimschy
798660c9cd deprecated "cast macros" ('luaL_checkint', 'luaL_optint', etc.) 2014-10-01 08:54:56 -03:00
Roberto Ierusalimschy
4fba117433 [un]'dumpint' -> [un]'dumpinteger' 2014-08-20 19:06:41 -03:00
Roberto Ierusalimschy
1aa5262634 do not assume numbers are coercible to strings 2014-07-30 10:59:24 -03:00
Roberto Ierusalimschy
3ccbae84d2 added some casts between integral types (to avoid warnings) 2014-07-29 13:01:00 -03:00
Roberto Ierusalimschy
68616c6669 using lua_Unsigned (instead of lua_Integer) for bit manipulation 2014-04-27 11:42:26 -03:00
Roberto Ierusalimschy
3d4913f703 back to larger sizes for 'dumpint/undumpint' (small Lua should
be able to dump/undump long-long integers)
2014-04-16 15:48:31 -03:00
Roberto Ierusalimschy
a2c094fe2d size of strings in 'string.rep' should be limited by the size of
lua_Integer, not of 'int'
2014-04-14 13:59:46 -03:00
Roberto Ierusalimschy
ef789d4161 new global macro 'LUA_MAXUNSIGNED' 2014-04-12 11:45:10 -03:00
Roberto Ierusalimschy
115fa77009 maximum size for dump of integers is size of lua_Integer (which
means that there is no overflows when undumping)
2014-04-10 16:45:43 -03:00
Roberto Ierusalimschy
561030c211 pack/unpack functions renamed dump/undump 2014-04-10 15:24:12 -03:00
Roberto Ierusalimschy
48c745a611 avoid constant overflow when shifting left signed integers until
their last bit
2014-04-03 10:29:24 -03:00
Roberto Ierusalimschy
8ef9117924 fancier way to do sign extension 2014-03-31 15:38:26 -03:00
Roberto Ierusalimschy
420cc62fac missplelling in comments/function names (endianess -> endianness) 2014-03-27 12:58:05 -03:00
Roberto Ierusalimschy
2d5e2212d4 native lua_Number may be neither float nor double (in pack/unpackfloat) 2014-03-21 11:26:44 -03:00
Roberto Ierusalimschy
da4811238a details (typos in comments) 2014-03-21 10:52:33 -03:00
Roberto Ierusalimschy
ad40bb1181 detail in string.rep: allow large repetitions of the empty string (no
possibility of overflows)
2014-03-12 15:09:06 -03:00
Roberto Ierusalimschy
6318de80d3 added 'strip' parameter to lua_dump/string.dump 2014-02-25 11:30:21 -03:00
Roberto Ierusalimschy
916bd874ad added explicit default options to string.pack/unpack functions 2014-01-09 14:21:28 -02:00
Roberto Ierusalimschy
cd848cab6b first implementation for string.pack/unpackfloat + try not to assume
that chars have 8 bits
2014-01-08 16:34:34 -02:00
Roberto Ierusalimschy
29256e8960 first implementation of string.packint/string.unpackint 2014-01-05 12:05:58 -02:00
Roberto Ierusalimschy
7c4cc505db added "reasonable" limit for 'string.rep' (otherwise it is too easy
to crash the machine)
2013-06-20 12:06:51 -03:00
Roberto Ierusalimschy
55f566bd22 use lua_Integer for integer parameters to avoid truncation 2013-06-19 11:29:01 -03:00
Roberto Ierusalimschy
c5069528e1 details ('Type* id' -> 'Type *id') 2013-06-07 11:51:10 -03:00
Roberto Ierusalimschy
944709c77b more definitions to support integer formatting 2013-04-25 10:52:13 -03:00
Roberto Ierusalimschy
53480f1163 details (remove of some extra spaces) 2012-08-14 15:12:34 -03:00
Roberto Ierusalimschy
6625cbecd1 Bug: Some patterns can overflow the C stack, due to recursion
(Took the opportunity to refactor function 'match')
2012-07-31 14:48:42 -03:00
Roberto Ierusalimschy
054c20cd5b spaces -> tabs in #defines 2012-05-23 12:37:09 -03:00
Roberto Ierusalimschy
048be9cf27 different scheme to check arguments to '%d', '%x', etc. Old scheme
did not work well when lua_Number is an integer.
2012-04-20 10:16:48 -03:00
Roberto Ierusalimschy
462375ba47 'if' to avoid empty 'memcpy' (may be expensive) 2012-04-03 16:06:19 -03:00
Roberto Ierusalimschy
f1d2ac3a98 allow non-integer arguments to integer formats (%d, %x, etc.),
but check range
2011-11-30 16:24:56 -02:00
Roberto Ierusalimschy
5a568a3b01 detail (comment) 2011-10-25 10:01:20 -02:00
Roberto Ierusalimschy
b5bf7d9ef4 'string.format' checks whether values for integer formats are
actually integers
2011-08-09 17:58:29 -03:00
Roberto Ierusalimschy
17526ed2fe no more errors on accesses to 'string' and strings 2011-06-28 14:13:52 -03:00
Roberto Ierusalimschy
817f8674af avoid warning about -unsigned value 2011-06-16 11:14:31 -03:00
Roberto Ierusalimschy
c9d1d9f9c6 better way to test overflows with string indices 2011-06-09 15:22:47 -03:00
Roberto Ierusalimschy
ad2531a0ee more complete (and hopefuly more correct) handling of 'sizeof(char)' 2011-05-03 13:01:57 -03:00
Roberto Ierusalimschy
bad231c481 'LUA_USELONGLONG' -> 'LUA_USE_LONGLONG' 2011-04-20 13:36:28 -03:00
Roberto Ierusalimschy
a25416a8d5 use of 'luaL_tolstring' for option '%s' in 'string.format' 2011-03-18 16:02:33 -03:00
Roberto Ierusalimschy
e7a9c45a48 trying to avoid assumption that sizeof(char)==1 2011-02-07 17:15:24 -02:00
Roberto Ierusalimschy
c4ea0c3b29 detail (cleaning trailing spaces) 2011-01-26 14:30:02 -02:00
Roberto Ierusalimschy
7106c491dd 'sep' argument to 'string.rep' + 'string.rep' preallocates entire
buffer before creating resulting string
2011-01-12 18:36:01 -02:00
Roberto Ierusalimschy
8980c630bf error when indexing strings with invalid keys 2010-12-20 15:25:36 -02:00
Roberto Ierusalimschy
af119c8b55 official support for floating hexa numerals 2010-12-10 17:03:46 -02:00
Roberto Ierusalimschy
a2eaad5d81 'gfind' was deprecated in 5.1 2010-11-19 14:25:51 -02:00
Roberto Ierusalimschy
24baa919c1 small bug: 'find' did not detect magic chars after a \0 in a pattern
and did a plain search in those cases
2010-11-16 18:39:41 -02:00
Roberto Ierusalimschy
43ec354722 added support for conditional use of %Lg when using long double 2010-11-08 15:38:37 -02:00
Roberto Ierusalimschy
fdd5f2f7a3 comment typos 2010-10-29 15:52:46 -02:00
Roberto Ierusalimschy
4590a89b32 corrected warnings from different compilers (mostly casts and small
details)
2010-10-25 17:01:37 -02:00
Roberto Ierusalimschy
7192afafee new module policy: C modules do not create globals and do not register
themselves with 'require' (let 'require' do its work); new auxiliary
functions luaL_newlib/luaL_newlibtable/luaL_setfuncs/luaL_requiref.
Old luaL_register will be deprecated.
2010-07-02 08:38:13 -03:00
Roberto Ierusalimschy
5a7dee0c5d added class '%g' in patterns (for graphical characters) 2010-05-24 16:34:57 -03:00
Roberto Ierusalimschy
658ea8752b no need to handle '\0' differently from other control chars in
format '%q'
2010-05-04 14:20:33 -03:00
Roberto Ierusalimschy
fc6203ee43 BUG: 'string.format' may get buffer when there are missing arguments 2010-04-12 13:13:02 -03:00
Roberto Ierusalimschy
4541243355 patterns now accept '\0' as a regular character 2010-04-12 09:00:50 -03:00
Roberto Ierusalimschy
9100f7479a new implementation for Generic Buffer manipulation (using userdata as
temporary buffer space)
2010-04-09 13:14:46 -03:00
Roberto Ierusalimschy
1fd4c482a0 reorganization of switch in function 'match' (details) 2010-01-04 14:37:19 -02:00
Roberto Ierusalimschy
46f1429936 more options moved from luaconf.h into internal files 2009-12-17 10:50:20 -02:00
Roberto Ierusalimschy
de6fc75d63 several configuration options that do not change often moved out of
luaconf.h and into more internal files
2009-12-17 10:26:09 -02:00
Roberto Ierusalimschy
9107dd115c no more compatibility code for 'string.gfind' 2009-11-26 14:49:28 -02:00
Roberto Ierusalimschy
a6f465f558 new mark LUAMOD_API for all luaopen_* functions 2009-11-24 10:05:44 -02:00
Roberto Ierusalimschy
f4eed60ca9 better treatment of integer formats in string.format 2009-06-18 13:51:03 -03:00
Roberto Ierusalimschy
cbf0c7a103 check for invalid use of '%' in replacement string in 'string.gsub' 2009-02-03 17:39:19 -02:00
Roberto Ierusalimschy
b1203e036d 'posrelat' avoids problems with -(-2^31) 2008-06-12 11:21:18 -03:00
Roberto Ierusalimschy
24359ae294 'string.find' cannot find things after subject's end 2008-04-14 12:54:59 -03:00
Roberto Ierusalimschy
788506dd58 detail 2007-11-12 12:10:09 -02:00
Roberto Ierusalimschy
c06cc60946 BUG: 'gsub' may go wild when wrongly called without its third
> argument and with a large subject.
2007-10-29 13:51:10 -02:00
Roberto Ierusalimschy
7a78495f31 avoid problems with 'ptrdiff_t' 2007-10-25 17:30:36 -02:00
Roberto Ierusalimschy
d62a21b9d3 when formatting with '%q', all control characters are coded
as \nnn.
2007-02-07 15:53:08 -02:00
Roberto Ierusalimschy
93d3c8450c bug: string.format("%") reads past the string 2006-09-18 13:33:14 -03:00
Roberto Ierusalimschy
a7c9e45c64 avoid trailing white spaces 2006-09-11 11:07:24 -03:00
Roberto Ierusalimschy
ee41bc03ab details 2006-06-22 13:12:59 -03:00
Roberto Ierusalimschy
fe8f4c06f1 detail (better error message for invalid format) 2006-04-26 17:41:19 -03:00
Roberto Ierusalimschy
8487913697 BUG: option '%q' for string.format does not handle '\r' correctly 2006-04-12 17:13:52 -03:00
Roberto Ierusalimschy
bfdcbbcd76 small optimizations (lua_newtable -> lua_createtable) 2005-12-29 14:23:32 -02:00
Roberto Ierusalimschy
428325baec detail 2005-12-21 10:59:43 -02:00
Roberto Ierusalimschy
9fbefdf69c integer formats in 'string.format' may need to operate with larger-than-int
types
2005-12-15 16:53:34 -02:00
Roberto Ierusalimschy
88f9843eee better error message 2005-10-26 11:28:19 -02:00
Roberto Ierusalimschy
62367dda44 string.gsub accepts a table as the replacement value 2005-10-23 15:46:30 -02:00
Roberto Ierusalimschy
ed7039024d avoid some warnings 2005-10-19 11:05:11 -02:00