Changelog
1.8.0 (2020-08-05)
New features
pretty.debugquickly dumps a set of values to stdout for debug purposes
Changes
pretty.write: now also sorts non-string keys #319stringx.counthas an extra option to allow overlapping matches #326- added an extra changelog entry for
types.is_emptyon the 1.6.0 changelog, due to additional fixed behaviour not called out appropriately #313 path.packagepathnow returns a proper error message with names tried if it fails
Fixes
- Fix:
stringx.rfindnow properly works with overlapping matches #314 - Fix:
package.searchpath(in modulepl.compat) #328 - Fix:
path.isabsnow reports drive + relative-path asfalse, eg. "c:some/path" (Windows only) - Fix: OpenResty coroutines, used by
dir.dirtree,pl.lexer,pl.permute. If available the original coroutine functions are now used #329 - Fix: in
pl.strictalso predefine global_PROMPT2 - Fix: in
pl.strictapplytostringto the given name, in case it is not a string. - Fix: the lexer would not recognize numbers without leading zero; "-.123". See #315
1.7.0 (2019-10-14)
New features
utils.quote_argwill now optionally take an array of arguments and escape them all into a single string.app.parse_argsnow accepts a 3rd parameter with a list of valid flags and aliassesapp.script_namereturns the name of the current script (previously a private function)
Changes
- Documentation updates
utils.quit: exit message is no longer required, and closes the Lua state (on 5.2+).utils.assert_argandutils.assert_string: now return the validated valuepl.compat: now exports thejitandjit52flagspretty.write: now sorts the output for easier diffs #293
Fixes
utils.raisechanged the globalon_error-level when passing in bad argumentsutils.writefilenow checks and returns errors when writingcompat.executenow handles the Windows exitcode -1 properlytypes.is_emptywould return true on spaces always, independent of the parametertypes.to_boolwill now compare case-insensitive for the extra passed stringsapp.require_herewill now properly handle an absolute base pathstringx.splitwill no longer append an empty match if the number of requested elements has already been reached #295path.common_prefixandpath.relpathreturn the result in the original casing (only impacted Windows) #297dir.copyfile,dir.movefile, anddir.makepathcreate the new file/path with the requested casing, and no longer force lowercase (only impacted Windows) #297- added a missing assertion on
path.getmtime#291 stringx.rpartitionreturned bad results on a not-found #299
1.6.0 (2018-11-23)
New features
pl.compatnow providesunpackastable.unpackon Lua 5.1
Changes
utils.unpackis now documented and respects.nfield of its argument.tablex.deepcopyandtablex.deepcompareare now cycle aware (#262)- Installing through LuaRocks will now include the full rendered documentation
Fixes
- Fixed
seq.lastreturningnilinstead of an empty list when given an empty iterator (#253). pl.templatenow appliestostringwhen substituting values in templates, avoiding errors when they are not strings or numbers (#256).- Fixed
pl.import_intonot importing some Penlight modules (#268). - Fixed version number stuck at 1.5.2 (#260).
- Fixed
types.is_emptyreturningtrueon tables containingfalsekey (#267). - Fixed
types.is_emptyreturningfalseif not a nil/table/string - Fixed
test.assertraisethrowing an error when passed an array with a function to call plus its arguments (#272). - Fixed
test.assertraisenot throwing an error when given function does not error but instead returns a string matching given error pattern. - Fixed placeholder expressions being evaluated with wrong precedence of binary and unary negation.
- Fixed placeholder expressions being evaluated assuming wrong binary operator associativity (e.g.
_1-(_2+_3)was evaluated as(_1-_2)+_3. - Fixed placeholder expressions being evaluated as if unary operators take precedence over power operator (e.g.
(-_1)^_2) was evaluated as-(_1^2)). - Fixed vulnerable backtracking pattern in
pl.stringx.strip(#275)
1.5.4 (2017-07-17)
Fixes
- Fixed
compat.executebehaving differently on Lua 5.1 and 5.1+. - Fixed
lapp.process_options_stringsetting globalsuccessvariable.
1.5.3 (2017-07-16)
Changes
- Added
template.compilefunction that allows caching compiled template and rendering it multiple times. - Added special
_debugfield to environment table argument intemplate.substitutefor printing generated template code upon render error.
Fixes
- Fixed error (
attempt to concatenate a nil value (local 'vtype')) inlapp.process_options_string.
1.5.2 (2017-04-08)
Fixes
- Removed leftover debug pring in
lapp.process_options_string.
1.5.1 (2017-04-02)
Fixes
- Fixed
dir.getfilesmatching given pattern against full paths from base directory instead of file names.
1.5.0 (2017-04-01)
Changes
stringx.splitlinesconsiders\r\na single line ending.stringx.splitlinesreturns an empty list for an empty string.
Fixes
tablex.count_mapno longer raises an error.strict.modulecorrectly handles existing__indexmetamethod returningfalse.app.parse_argsaccepts colon as a separator between option name and value, as advertised.pretty.loadhandles case where a C hook is present. 'os.executehad issue with LuaJIT in 5.2 compat mode.
Features
templatesupports customizing inline escape character and chunk name.seqconstructor supports iterators with a state object as the second argument.stringx.splitlineshaskeep_endsargument.tablex.reducecan take an optional initial value.
1.4.1 (2016-08-16)
Changes
- All functions that return instances of
pl.List,pl.Mapandpl.Setnow require corresponding modules, so that their methods always work right away.
Fixes
- Fixed
dir.getallfilesreturning an empty array when called withoutpatternargument.
Features
1.4.0 (2016-08-14)
Changes
Fixes
pl.pathcovers edge cases better (e.gpath.normpathwas broken)p.dirshell patterns fixedos.tmpnamebroken on modern Windows/MSVC14- (likewise for
utils.executeexwhich depends on it) pretty.writemore robust and does not lose floating-point precision; saves and restores debug hooks when loading.pl.lexerfixes:cpplexer now filters space by defaulttablex.sortvno longer assumes that the values are all uniquestringx.centeris now consistent with Python;stringx.rfindandstring.quote_stringfixed.data.writehad a problem with default delimiter, properly returns error now.pl.Set+and-now have correct semantics
Features
pl.tablexhasunionandmergeconvenience functionspl.lappunderstands '--' meaning end of parsed argumentsutils.quote_argquotes command arguments foros.execute, correctly handling all special characters.utils.writefilehas optionalis_binargument- 'pl.lexer' supports line numbers with string argument
stringx.endswithmay be passed an array of possible suffixes.data.read- in CSV mode, assume empty fields are numerical zero
1.3.2 (2015-05-10)
Changes
- now works and passes tests with Lua 5.3
- utils.import will NOT override global symbols (import 'math' caused global type() to be clobbered)
- Updated pl.dir.file_op to return true on success and false on failure...
- workaround for issues with pl.lapp with amalg.lua - will look at global LAPP_SCRIPT if arg[0] is nil
Fixes
- func was broken: do NOT use ipairs to iterate if __index is overriden!
- issue #133 pretty.read (naively) confused by unbalanced brackets
- xml attribute underscore fix for simple parser
- Fix path.normpath
- lexer: fix parsing block comments/string. fix hang on empty string.
- Fixed utils.execute returning different values for Lua 5.1 and Lua 5.2
- Issue #97; fixed attempt to put a month into a day
- problem with tablex.count_map with custom comparison
- tablex.pairmap overwrites result if key already exists; instead, upon detection that key already exists for a returned value, we modify the key's value to be a table and insert values into that table
Features
- Add Python style url module for quote and unquote.
- stringx.quote_string, which scans for embedded long-string quote matches and escapes them by creating a long-string quote.
- issue #117: tablex.range now works with decreasing numbers, consistent with numerical for loop
- utils.import will NOT override global symbols (import 'math' caused global type() to be clobbered)
- issue #125: DOCTYPE ignored in xml documents as well
- Allow XML tostring() function to customize the default prefacing with
<?xml...> - More Robust Quoted Strings
- lapp: improved detection of unsupported short flags
1.3.1 (2013-09-24)
1.3.0 (2013-09-14)
Changes
- class: RIP base method - not possible to implement correctly
- lapp: short flags can now always be followed directly by their value, for instance,
-I/usr/include/lua/5.1 - Date: new explicit
Date.Intervalclass;toUTC/toLocalreturn new object;Date.__tostringalways returns ISO 8601 times for exact serialization.+/-explicit operators. Date objects are explicitly flagged as being UTC or not.
Fixes
- class: super method fixed.
- Date: DST is now accounted for properly.
- Date: weekday calculation borked.
Features
- All tests pass with no-5.1-compatible Lua 5.2; now always uses
utils.loadandutils.unpackis always available. - types: new module containing
utils.is_xxxmethods plus newto_bool. - class: can be passed methods in a table (see
test=klass.lua). This is particularly convenient for using from Moonscript. - general documentation improvements, e.g
class
1.2.1 (2013-06-21)
Changes
- utils.set(get)fenv always defined (not set as globals for 5.2 anymore!). These are defined in new module pl.compat, but still available through utils.
- class.Frodo now puts 'Frodo' in current environment
Fixes
- lapp.add_type was broken (Pete Kazmier)
- class broke with classes that redefined __newindex
- Set.isdisjoint was broken because of misspelling; default ctor Set() now works as expected
- tablex.transform was broken; result now has same keys as original (CoolistheName007)
- xml match not handling empty matches (royalbee)
- pl.strict: assigning nil to global declares it, as God intended. (Pierre Chapuis)
- tests all work with pl.strict
- 5.2 compatible load now respects mode
- tablex.difference thought that a value of
falsemeant 'not present' (Andrew Starke)
Features
- tablex.sort(t) iterates over sorted keys, tablex.sortv(t) iterates over sorted values (Pete Kazmier)
- tablex.readonly(t) creates a read-only proxy for a table (John Schember)
- utils.is_empty(o) true if o==nil, o is an empty table, or o is an empty string (John Schember)
- utils.executeex(cmd,bin) returns true if successful, return code, plus stdout and stderr output as strings. (tieske)
- class method base for calling inherited methods (theypsilon)
- class supports pre-constructor _create for making a custom self (used in pl.List)
- xml HTML mode improvements - can parse non-trivial well-formed HTML documents. xml.parsehtml is a parse function, no longer a flag
- if a LOM document has ordered attributes, use these when stringifying
- xml.tostring has yet another extra parm to force prefacing with
<?xml...> - lapp boolean flags may have
truedefault - lapp slack mode where 'short' flags can be multi-char
- test.asserteq etc take extra arg, which is extra level where error must be reported at
- path.currentdir,chdir,rmdir,mkdir and dir as alias to lfs are exported; no dependencies on luafilesystem outside pl.path, making it easier to plug in different implementations.
1.2.0 (2013-05-28)
1.1.1 (2013-05-14)
1.1.0 (2013-03-18)
1.0.3 (2012-12-07)
1.0.2 (2012-05-12)
1.0.1 (2012-05-26)
1.0.0 (2012-04-26)
0.9.8 (2011-11-27)
0.9.7 (2011-11-27)
Lua 5.2 compatibility
(These are all now defined in pl.utils)
- setfenv, getfenv defined for Lua 5.2 (by Sergey Rozhenko)
Changes
- array2d.flatten is new
- OrderedMap:insert is new
Fixes
- seq.reduce re-implemented to give correct order (Carl Ådahl)
- seq.unique was broken: new test
- tablex.icopy broken for last argument; new test
- utils.function_arg last parm 'msg' was missing
- array2d.product was broken; more sensible implementation
- array2d.range, .slice, .write were broken
- text optional operator % overload broken for 'fmt % fun'; new tests
- a few occurances of non-existent function utils.error removed
0.9.6 (2011-09-11)
Lua 5.2 compatibility
- Bad string escape in tests fixed
Changes
- LuaJIT FFI used on Windows for Copy/MoveFile functionality
Fixes
- Issue 13 seq.sort now calls seq.copy
- issue 14 bad pattern to escape trailing separators in path.abspath
- lexer: string tokens broken with some combinations
- lexer: long comments broken for Lua and C
- stringx.split behaves according to Python spec; extra parm meaning 'max splits'
- stringx.title behaves according to Python spec
- stringx.endswith broken for 2nd arg being table of postfixes
- OrderedMap.set broken when value was nil and key did not exist in map; ctor throws error if unhappy
0.9.5 (2011-07-05)
Lua 5.2 compatibility
- defines Lua 5.2 beta compatible load()
- defines table.pack()
New functions
- stringx.title(): translates "a dog's day" to "A Dog's Day"
- path.normpath(): translates 'A//B','A/./B' and 'A/C/../B' to 'A/B'
- utils.execute(): returns ok,return-code: compatible with 5.1 and 5.2
Fixes
- pretty.write() always returns a string, but will return also an error string if the argument is not a table. Non-integer indices between 1 and #t are no longer falsely considered part of the array
- stringx.expandtabs() now works like the Python string method; it will expand each field up to the next tab stop
- path.normcase() was broken, because of a misguided attempt to normalize the path.
- UNC specific fix to path.abspath()
- UNC paths recognized as absolute; dir.makedir() works here
- utils.quit() varargs broken, e.g. utils.quit("answer was %d",42)
- some stray globals caused trouble with 'strict'
0.9.4 (2011-04-08)
0.9.3 (2011-03-05)
0.9.2 (2011-02-16)
0.9.1 (2011-02-12)
0.9.0 (2010-12-20)
0.8.5 (2010-12-16)
What's new with 0.8b ?
Features:
pl.app provides useful stuff like simple command-line argument parsing and require_here(), which makes subsequent require() calls look in the local directory by preference.
p.file provides useful functions like copy(),move(), read() and write(). (These are aliases to dir.copyfile(),movefile(),utils.readfile(),writefile())
Custom error trace will only show the functions in user code.
More robust argument checking.
In function arguments, now supports 'string lambdas', e.g. '|x| 2*x'
utils.readfile,writefile now insist on being given filenames. This will cause less confusion.
tablex.search() is new: will look recursively in an arbitrary table; can specify tables not to follow. tablex.move() will work with source and destination tables the same, with overlapping ranges.
Bug Fixes:
dir.copyfile() now works fine without Alien on Windows
dir.makepath() and rmtree() had problems.
tablex.compare_no_order() is now O(NlogN), as expected. tablex.move() had a problem with source size
What's New with 0.7.0b?
Features:
utils.is_type(v,tp) can say is_type(s,'string') and is_type(l,List).
utils.is_callable(v) either a function, or has a __call metamethod.
Sequence wrappers: can write things like this:
seq(s):last():filter('<'):copy()
seq:mapmethod(s,name) - map using a named method over a sequence.
seq:enum(s) If s is a simple sequence, then for i,v in seq.enum(s) do print(i,v) end
seq:take(s,n) Grab the next n values from a (possibly infinite) sequence.
In a related change suggested by Flemming Madsden, the in-place List methods like reverse() and sort() return the list, allowing for method chaining.
list.join() explicitly converts using tostring first.
tablex.count_map() like seq.count_map(), but takes an equality function.
tablex.difference() set difference tablex.set() explicit set generator given a list of values
Template.indent_substitute() is a new Template method which adjusts for indentation and can also substitute templates themselves.
pretty.read(). This reads a Lua table (as dumped by pretty.write) and attempts to be paranoid about its contents.
sip.match_at_start(). Convenience function for anchored SIP matches.
Bug Fixes:
tablex.deepcompare() was confused by false boolean values, which it thought were synonymous with being nil.
pretty.write() did not handle cycles, and could not display tables with 'holes' properly (Flemming Madsden)
The SIP pattern '$(' was not escaped properly. sip.match() did not pass on options table.
seq.map() was broken for double-valued sequences. seq.copy_tuples() did not use default_iter(), so did not e.g. like table arguments.
dir.copyfile() returns the wrong result for *nix operations. dir.makepath() was broken for non-Windows paths.
What's New with 0.6.3?
The map and reduce functions now take the function first, as Nature intended.
The Python-like overloading of '*' for strings has been dropped, since it is silly. Also, strings are no longer callable; use 's:at(1)' instead of 's(1)' - this tended to cause Obscure Error messages.
Wherever a function argument is expected, you can use the operator strings like '+','==',etc as well as pl.operator.add, pl.operator.eq, etc. (see end of pl/operator.lua for the full list.)
tablex now has compare() and compare_no_order(). An explicit set() function has been added which constructs a table with the specified keys, all set to a value of true.
List has reduce() and partition() (This is a cool function which separates out elements of a list depending on a classifier function.)
There is a new array module which generalizes tablex operations like map and reduce for two-dimensional arrays.
The famous iterator over permutations from PiL 9.3 has been included.
David Manura's list comprehension library has been included.
Also, utils now contains his memoize function, plus a useful function args which captures the case where varargs contains nils.
There was a bug with dir.copyfile() where the flag was the wrong way round.
config.lines() had a problem with continued lines.
Some operators were missing in pl.operator; have renamed them to be consistent with the Lua metamethod names.