Lua libraries ------------- by Reuben Thomas (rrt@sc3d.org) This archive contains two additional libraries for Lua 4.0, documented below. To use them, unpack this archive on top of a Lua 4.0 source tree and rebuild. The interpreter (lua) will now have the libraries available. The libraries are (c) Reuben Thomas 2000, and released under the LGPL version 2.1, or, at your option, any later version. There is no warranty. bitlib ------ Provides bitwise logical operations: band(a,b) returns the bitwise and of a and b bor(a,b) returns the bitwise or of a and b bxor(a,b) returns the bitwise exclusive or of a and b bnot(a) returns the one's complement of a lshift(a,b) returns a shifted left b places rshift(a,b) returns a shifted logically right b places arshift(a,b) returns a shifted arithmetically right b places imod(a,b) returns the integer remainder of a divided by b The arguments to all functions should be integral numbers. The number of bits available for logical operations depends on the data type used to represent Lua numbers; this is typically 8-byte IEEE floats, which give 53 bits (the size of the mantissa). rexlib ------ Provides POSIX regular expression matching: regex(r) returns a compiled regular expression (calls regcomp) match(s, r) returns the start and end point of the first match of the compiled regexp r in the string s (calls regexec). If the regex contains substring matches (captures in Lua terminology), these are returned as a third result, in a table It may be useful to define: function rstrfind(s, r) return match(s, regex(r)) end If rexlib is compiled against Henry Spencer's regex library, then regular expressions and the strings to match them against may contain NULs. For anyone who's wondering why regfree isn't mentioned above, that's because it's called automatically by the gc tag method of the userdata type that holds regexs.