lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sorry about that.  Travelling today but I'll get your account set tonight.

On Jan 4, 2012 6:51 AM, "Reuben Thomas" <rrt@sc3d.org> wrote:
I just spent about 45 minutes reworking the LuaPowerPatches page, and
at the end of it, I get "Sorry, your change was not accepted". As I
made a smaller change to the power patches archive page in the same
editing session, I guess that it's to do with the size of my change? I
post the text of my new version of the page below, so you can see I
was not vandalising the page; but how can I get it into the Wiki?


A ''power patch'' is a small patch to a source code distribution that
makes some useful change.  Power patches are judged based on how few
lines of code are changed, general usefulness, and backwards
compatibility.  By limiting them to localized changes, the chance that
several such patches can work together is high.  It also keeps
maintenance work to a minimum as new versions of the source package
are released.  Truly good patches will have a short life, as the
authors of the original program will incorporate them into their code.
New power patches, ports of existing patches to different Lua
versions, and bug fixes are welcome.
If you apply a patch that changes the syntax or semantics of Lua, the
resulting language should not be called "Lua".
See LuaPowerPatchesArchive for patches for old versions of Lua. Where
a patch exists for multiple versions of Lua including the current one,
it will appear on this page.
== How to Apply a Patch ==
Unpack the correct Lua distribution into a clean directory.  Do a
{{cd}} to the top of the directory and run:     {{patch -p1 < patchfile}}
== Patch Tools ==
        * '''Unix, etc.''' users should have {{diff}} and {{patch}} in
the standard installation.  Some versions of patch (for example the
one that comes with Solaris) don't support Unified Context diffs
properly (the ones with + and - at the front of each line.  GNU patch
copes with this.        * '''Windows'''.                * There is a
version of the patch command for DOS (part of the DJGPP toolset)
[ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/pat21b.zip].  This
has been tested, and  works.                * Another, more general
solution for doing Unix tasks in Windows is Cygwin
[http://sources.redhat.com/cygwin/].            * UnxUtils
[http://sourceforge.net/projects/unxutils/] contains a working patch
utility.  This version of the patch utility expects files to be CRLF
line terminated, and will fail if they are not.  The "--binary"
command line option can be used to work around this.
== Patch Guidelines ==
       * '''adhere to style of surrounding code''' - This is important
because you want the original author to happily incorporate your patch
upstream.  Be sure to match the indenting style (both width and use of
real tabs or spaces).   * '''make patch adhering to guidelines in "NOTES
FOR PATCH SENDERS" section of {{patch}} man page''' - The patch is
made using the {{diff}} utility.  For example assume you have a
directory {{lua}} with the original Lua distribution, and adjacent to
that is a copy called {{lua_new}} which includes your patches.  Use
the following sequence to make the patch.  Be sure to look over the
resulting patch file in case you had some extraneous temporary files
in your patched tree.  Also beware of "false diffs" that can be caused
by lines with trailing spaces.          {{{cd luamake cleancd ../lua_newmake
cleancd ..diff -urN lua lua_new > mychange.patch}}}     * '''the patch
file should have unix line termination'''
----=== Lua 5.2 patches ===
== Advanced readline support (5.2, 5.1, 5.0) ==
This patch adds the following features to the existing readline
support in Lua 5.x:
        * Completion of keywords and global variable names.        *
Recursive and metatable-aware completion of variable names.        *
Context sensitive delimiter completion.        * Save/restore of the
history to/from a file ({{LUA_HISTORY}} env variable).        *
Setting a limit for the size of the history ({{LUA_HISTSIZE}} env
variable).        * Setting the app name to allow for {{$if lua ...
$endif}} in {{~/.inputrc}}.
After applying the patch start lua and try these (replace {{~}} with
the TAB key):        {{{~~fu~foo()
ret~fa~end<CR>io~~~s~~~o~~~w~"foo\n")<CR>}}}
It has been verified to work with Lua 5.0, 5.0.2, 5.1 and 5.2.
Compatible readline libraries include GNU readline 2.2.1, 4.0, 4.3,
5.0, 5.1, 6.0, 6.2; Mac OS X libedit 2.11; or NetBSD libedit 2.6.5,
2.6.9.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' ~250        *'''Lua authors' position:''' ?
      *'''Author:''' MikePall        *'''Maintainer:''' SeanBolton
   *'''Last update:''' 2011-Dec-14        *
[http://luajit.org/patches/lua-5.2.0-advanced_readline.patch download
(for Lua 5.2)]        *
[http://luajit.org/patches/lua-5.1.4-advanced_readline.patch download
(for Lua 5.1)]        *
[http://luajit.org/patches/lua-5.0-advanced-readline.patch download
(for Lua 5.0)]

=== Lua 5.1 patches ===
These are in order of Lua version, newest to oldest.
== Metatable Event '__iter' (5.1.4) ==
This patch adds a new event for metatables '__iter'. If this is
included in a metatable, its value must be a function with the same
signature as 'pairs' or 'ipairs'.
A simple usage case is as follows: t={"one","two"};
setmetatable(t,{__iter=ipairs}); for _,v in t do print(v) end;
Of course, a custom function or closure can be used in place of
'ipairs'. For lists, a closure could be used to avoid the need for the
dummy key variable for example.
The patch modifies the Lua Virtual Machine to test the type of the
first parameter of the TFORLOOP bytecode instruction. If it is a
function, the original code is used. If it is other than a function,
an attempt is made to access its '__iter' metamethod. If this attempt
yields a function, that function is called and its three return values
overwrite the original three parameters to TFORLOOP. The original code
is then used to process the Generic For with the iteration parameters
provided by the metamethod. Note that this introduces a subtle change
in the case when the metamethod is NOT used: The error case of the
iterator not being a function is detected before the first iteration
rather than during it, and it is a test for function type rather than
for callability. This may break some subtle code tricks such as using
the '__call' tag method for this purpose.
For this patch to be compiled, the symbol 'JH_LUA_ITER' must be defined.
        *'''Backwards compatible:''' unknown        *'''Lines
changed/added/deleted:''' 0/24/0        *'''Lua authors' position:'''
Tetchy, but just might come round.        *'''Author:''' JohnHind
  *'''Last update:''' 2010-January-15        *
[Files:wiki_insecure/power_patches/5.1/jh-lua-iter-5.1.4.patch
Download (5.1.4)]

== Set Syntax Shortcut for Table Constructors (5.1.4) ==
This patch adds a new syntax shortcut for constructing set-like
tables. If the value of a field is missing it is defaulted to boolean
true, so for example {["saturday"], ["sunday"]} constructs the same
table as {["saturday"] = true, ["sunday"] = true}.
For this patch to be compiled, the symbol 'JH_LUA_SETINIT' must be defined.
        *'''Backwards compatible:''' unknown        *'''Lines
changed/added/deleted:''' 0/14/0        *'''Lua authors' position:'''
Cold as the dry plains of Antarctica!        *'''Author:''' JohnHind
     *'''Last update:''' 2010-January-15        *
[Files:wiki_insecure/power_patches/5.1/jh-lua-setinit-5.1.4.patch
Download (5.1.4)]

== Octal and Binary Number Constants (5.1.4) ==
This simple patch adds octal and binary constants alongside
hexadecimal which is already supported. These will be recognised in
source code literals or in string contents converted implicitly or
explicitly by 'tonumber'.  Binary constants take the form '0b10101'.
Octal constants take the form '0o176'. Upper-case radix specifier is
also supported for consistency with the hexadecimal format but for
obvious reasons it is not recommended for octal!
For this patch to be compiled, the symbol 'JH_LUA_BINOCTAL' must be defined.
        *'''Backwards compatible:''' unknown        *'''Lines
changed/added/deleted:''' 0/6/0        *'''Lua authors' position:'''
Regard it as 'bloat' - probably!        *'''Author:''' JohnHind
*'''Last update:''' 2010-January-14        *
[Files:wiki_insecure/power_patches/5.1/jh-lua-binoctal-5.1.4.patch
Download (5.1.4)]

== Use NaN packing for TValue (5.1.4) ==
Use nan packing for TValue on x86 to reduce memory usage and tiny
performance gain (same as in LuaJIT 2).
It's fully ABI compatible with standard Lua libraries.
On one test script memory consumption reduced from 28Mb to 21Mb and
performance gain about 3.5-5%
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 5/138/2        *'''Lua authors' position:'''
?        *'''Author:''' Sokolov Yura aka funny_falcon        *'''Last
update:''' 2011-February-24        *
[http://lua-users.org/files/wiki_insecure/power_patches/5.1/pack_value.patch
download]

== Emergency Garbage Collector (5.1.4) ==
This patch is described in EmergencyGarbageCollector.
        *'''Backwards compatible:''' yes        *'''files
changed/added/deleted:''' 18/427/95        *'''Lua authors'
position:''' Implemented in Lua 5.2        *'''Author:'''
RobertGabrielJakabosky        *'''Last update:''' 2010-Dec-7        *
[Files:wiki_insecure/power_patches/5.1/emergency_gc-5.1.4-r6.patch
Download (5.1.4) release 6]

== Multi-dimensional Array Indexing with Comma Syntax (5.1.4) ==
Modifies the parser to support multi-dimensional array indexing with
comma syntax, i.e. m[1,2] istreated by the parser as being identical
to m[1][2], thus allowing for code such as the following:
       {{{   -- test multi-dimensional arrays with comma syntax. also test
-- constructors and multiple assignment to show they're not broken.
m = {[1]={}, [2]="foo"}   m[1,2] = "bar"   print(m[2], m[1][2],
m[1,2])  --> foo  bar bar   m.foo = {}   m.foo.bar = "baz"
print(m["foo","bar"])         --> baz}}}
The virtual machine is unchanged.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 1/7/2        *'''Lua authors' position:''' ?
       *'''Author:''' Mark Feldman (lua@ppl-pilot.com)        *'''Last
update:''' 2009-Nov-09        *
[Files:wiki_insecure/power_patches/5.1/mda.patch Download (5.1.4)]

== C Function Names in Traceback (5.1.4) ==
Currently GNU/Linux only, this patch will add the names of Lua C
functions to the traceback if debugging informationhas been compiled
into the shared library from which they were loaded.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/27/0        *'''Lua authors' position:'''
?        *'''Author:''' RobHoelz        *'''Last update:'''
2009-May-06        * [http://hoelzro.net/c-func-names.patch download]

== Allow underscores in numbers (5.1.4) ==
One thing I like about Perl is the ability to break up large numbers
using underscores, so instead of this:        {{{local num =
1000000000000}}}
you can do this:         {{{local num = 1_000_000_000_000}}}
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 3/4/0        *'''Lua authors' position:''' ?
       *'''Author:''' RobHoelz        *'''Last update:'''
2009-April-06        * [http://hoelzro.net/perl-numbers.patch
download]

== added bitwise operators, integer division and != (5.1.4) ==
        * Infix bitwise operators for AND (&, __and), OR (|, __or),
XOR (^^, __xor).         * Infix bitwise operators for SHIFT LEFT (<<,
__shl) and SHIFT RIGHT (>>, __shr).         * Unary bitwise negation
operator (~, __not).        * Infix arithmetic operator for INTEGER
DIVISION (\, __intdiv).        * accepts both ~= and != for
comparison.
All these features can be disabled with undefining
LUA_BITWISE_OPERATORS in luaconf.h.
Bitwise operators first convert a lua_Number to a lua_Integer and
convert back the result to a lua_Number.
        *'''Backwards compatible:''' no (new byte code)
*'''Lines changed/added/deleted:'''        *'''Lua authors'
position:'''        *'''Author:''' Thierry Grellier, darkmist (at)
mail.ru, Joshua Simmons        *'''Last update:''' 2009-Mar-29
* [Files:wiki_insecure/power_patches/5.1/bitwise_operators_5.1.4_1.patch
download (for Lua 5.1.4)]        *
[http://darkmist.newmail.ru/bitwise_operators_for_lua_5.1.3.patch
download (for Lua 5.1.3)]        *
[Files:wiki_insecure/power_patches/5.1/newluaoperators.patch download
(for Lua 5.1.1)]

== Better signal handling in the interpreter on POSIX systems (5.1.4) ==
Use {{sigaction}} instead of {{signal}}. This means that, for example,
you don't have to press Ctrl-C twice to quit a Lua script blocked on
I/O.
[But then you can no longer stop the process if a C function is stuck
in a loop. :-( ]
       *'''Backwards compatible:''' yes        *'''Lines changed/added/deleted:'''
-/12/4  *'''Lua authors' position:''' ? *'''Author:'''
ReubenThomas    *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/sig_catch.patch download (for
lua-5.1.4)]

== Remove auto string<->number conversion (5.1.4) ==
Prevent auto-conversion between strings and numbers in arithmetic and
concatenation. This is good because it prevents bugs; when
auto-conversion is a good idea (as in the print function) it can still
be done by calling the relevant conversion functions.
The current version does not scrupulously remove all undesirable
casting from the libraries; I have preferred correctness over
completeness. I now have a plan for this, and have started looking
through the sources.
       *'''Backwards compatible:''' no *'''Lines changed/added/deleted:'''
-/16/31 *'''Lua authors' position:''' Under discussion  *'''Author:'''
ReubenThomas    *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/no_auto_conversion.patch
download (for lua-5.1.4)]

== Print NULs (5.1.4) ==
Make print print NUL characters, by using fwrite instead of fputs.
Someone else tidied it up by patching luaconf.h to let the user supply
a luai_puts macro.
       *'''Backwards compatible:''' no *'''Lines changed/added/deleted:'''
-/14/7  *'''Lua authors' position:''' ? *'''Author:''' ReubenThomas /
Unknown *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/print_nuls.patch download (for
lua-5.1.4)]

== Save readline history (5.1.4) ==
>From the standalone interpreter, save the readline history in a
configurable file (defaults to .lua_history on POSIX, lua_history.txt
on Windows).
       *'''Backwards compatible:''' no *'''Lines changed/added/deleted:'''
-/23/-  *'''Lua authors' position:''' Under discussion  *'''Author:'''
ReubenThomas    *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/save_readline_history.patch
download (for lua-5.1.4)]

== Use defaults for LUA_INIT, LUA_PATH and LUA_CPATH (5.1.4) ==
Adds a -t switch to the standalone interpreter that uses the default
values for the above variables, making it easier to run Lua in a
controlled way.
       *'''Backwards compatible:''' no *'''Lines changed/added/deleted:'''
-/20/5  *'''Lua authors' position:''' Under discussion  *'''Author:'''
ReubenThomas    *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/no_init_or_paths.patch download
(for lua-5.1.4)]

== No varargs (5.1.4) ==
Varargs are arguably a needless complication. This patch removes them.
       *'''Backwards compatible:''' no *'''Lines changed/added/deleted:'''
-/9/106 *'''Lua authors' position:''' ? *'''Author:'''
ReubenThomas    *'''Last update:''' 2009-Aug-20 *
[Files:wiki_insecure/power_patches/5.1/no_vararg.patch download (for
lua-5.1.4)]

== Interpreter Bailout Flag (5.1.3) ==
At [http://www.simopsstudios.com Sim Ops Studios], we embedded Lua by
spawning a kernel-supported thread that called a Lua script using the
C API. In that configuration, a script could hang forever, making it
impossible to cleanly escape from the thread without killing it
outright. This script provides an alternative: the "bailout" state
flag, and two commands (luaL_getbailout and luaL_setbailout) to manage
the flag. When the flag is true, every opcode is interpreted as a
return operation, forcing the Lua interpreter unconditionally back to
the top level. The C code can then check the status of the flag and
cleanly exit the thread if the bailout flag is true. Using this flag
makes it impossible to write a script that can run without
interruption (although it is possible that a script could be
terminated in an unexpected place).
        *'''Backwards compatible:''' unknown        *'''Lines
changed/added/deleted:''' -/-/-        *'''Lua authors' position:''' ?
       *'''Author:''' MarkTomczak        *'''Last update:'''
2008-July-16        *
[Files:wiki_insecure/power_patches/5.1/interpreter-bailout-5.1.3.patch
Download (5.1.3)]        *'''Note''' This patch is missing two vital
stages. It should add "int bailout;" to lua_State in lstate.h:127 and
"L->bailout = 0;" to preinit_state in lstate.c:101.

== "checkglobals": Check for Undefined Globals (5.1.3) ==
This patch is described in DetectingUndefinedVariables.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 0/38/0        *'''Lua authors' position:'''
?        *'''Author:''' DavidManura        *'''Last update:'''
2008-Mar-22        *
[Files:wiki_insecure/power_patches/5.1/checkglobals-5.1.3.patch
Download (5.1.3)]

== Continue Statement (5.1.3) ==
A "continue" statement is added to the parser.  The virtual machine is
unchanged.Revised to the current Lua version with a small test suite.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/26/- (without tests)        *'''Lua
authors' position:''' ?        *'''Author:''' Leszek Buczkowski,
Wolfgang Oertl, AskoKauppi        *'''Last update:''' 2008-Mar-10
  * [Files:wiki_insecure/power_patches/5.1/continue-5.1.3.patch
Download (5.1.3)]
Instead of patching Lua, one might consider luaSub, which contains a
syntax mod for this same purpose.

== Table Scope patch (5.1.3) ==
Allows table constructs to enclose a scope so that variables used
inside the table have special meaning.  See TableScope.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 0/39/0        *'''Lua authors' position:'''
open        *'''Author:''' DavidManura        *'''Last update:'''
2008-Feb-2        *Patch for 5.1.3 is in TableScope.
== LNUM - number mode patch ("integer patch") (5.1.3) ==
Allows Lua built-in numbers to be a combination of any of the
following:    LNUM_DOUBLE / LNUM_FLOAT / LNUM_LDOUBLE (long double)
LNUM_INT32 / LNUM_INT64    LNUM_COMPLEX
AKa 19-Mar-08: Revised for Lua 5.1.3, see LuaForge.AKa 3-Oct-07:
Revised, see [http://luaforge.net/forum/forum.php?forum_id=1343 News]
Uses: 32- or 64-bit integer accuracy internally for any Lua numbers.
Intensively (40-500%) boosts Lua performance on non-FPU
platforms.Totally transparent to the application (script) level, as
well as existing Lua/C API. Even the use of complex numbers is.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 252/1616/207        *'''Lua authors'
position:''' open        *'''Author:''' AskoKauppi        *'''Last
update:''' 2008-Mar-19
Latest svn (with test suite):{{{svn export
svn://slugak.dyndns.org/public/2008/LuaPatches/LNUM2}}}
Latest release:[http://luaforge.net/frs/?group_id=214 LuaForge LNUM Files]
Real-world testing and performance data from true applications are
still appreciated. The patch is essentially "ready"; apart from
LDOUBLE mode there are no known bugs; if you find any, please share
the info.
The patch leaves integer realm graciously, falling into floating point
accuracy if results won't fit in integers. The revise of 2008 boost
speed further by no longer reducing speed of floating point
calculations.
For performance results, there is a spreadsheet and easy to use
"make-plain/float/double/ldouble/complex" targets to run on your own
system.
== Integer ASCII values (5.1.2) ==
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 0/8/0        *'''Author:''' Karel Tuma
 *'''Last update:''' 2007-Sep-25        *
[http://blua.leet.cz/asciival.patch Download for 5.1.2]
Yet another syntactic bloat for the lexer: {{{print(#'a',#'\n')97      10}}}
note that this could be probably done via token filter as well, but ..
useful for various ascii value mangling (base64,obscure protocol
parsing..) .. i just wanted something more expressive than if
c>=b2a("A") and c<=b2a("Z"). there was no way to get ascii value as a
constant in lua to this point.
''This syntax already has a meaning (string length) because strings
can be given inside single quotes. --lhf''
== Yieldable For Loop (5.1.2) ==
        *'''Backwards compatible:''' yes if LUA_COMPAT_TFORLOOP
defined        *'''Lines changed/added/deleted:'''
*'''Author:''' RiciLake        *'''Last update:''' 2007-Sep-01
* [http://primero.ricilake.net/lua/lua-5.1.2-for.patch Download for
5.1.2]
Modifies the code generator so that the iterator in {{for ... in}}
loops can call {{yield}}. Details and test code are available at
YieldableForLoops.
Note that the current version of the patch orders op codes so as to
maintain binary compatibility with compiled Lua scripts, if
LUA_COMPAT_TFORLOOP is defined in luaconf.h. This adds a few
instructions to the VM, and quite a bit of complexity to the patch,
which would otherwise only be about 25 lines modified.
== Module Execution Proposal (5.1.2) ==
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' -/116/31        *'''Lua authors'
position:''' ?        *'''Author:''' DavidManura        *'''Last
update:''' 2007-Sep-01
Provides a new command-line switch ({{-p}}) that loads a function with
the given package name via the searchers in {{package.loaded}} and
then executes that function as a script, passing the command-line
arguments to the function as arguments.  Patch and description are in
ModuleExecutionProposal.

== Concise anonymous functions (5.1.2) ==
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 3/26/0        *'''Lua authors' position:'''
?        *'''Author:''' Brian Palmer        *'''Last update:'''
2007-Jun-10        *
[http://svn.codekitchen.net/lua_patches/lambda.patch Download Patch]
(Patched against Lua 5.1.2)
Some syntactic sugar for writing more concise anonymous functions,
very useful when passing arguments to higher-order functions.
Completely backwards compatible and only modifies the parser, emits
the same bytecode as the old syntax. See
[http://svn.codekitchen.net/lua_patches/lambda.readme.txt The Readme]
for details.

== Extend table constructor syntax to allow multiple expansion of
multireturn functions (5.1.1) ==
As discussed several times on the mailing list, and implemented in
Aranha, here is a patch whichmodifies table constructor syntax so that
{{;}} allows the preceding list item to be expanded.
        *'''Backwards compatible:''' no (modifies arguments to
{{OP_SETLIST}})        *'''Lines changed/added/deleted:''' 21/73/86
    *'''Lua authors' position:''' ?        *'''Author:''' RiciLake
   *'''Last update:''' 2007-Feb-08        *
[http://primero.ricilake.net/lua/newtable.patch Download for Lua
5.1.1]
With this patch,{{ {foo(); bar()} }}creates a table with all the
return values of {{foo}} followed by all the return values of {{bar}},
while{{ {foo(), bar()} }}continues to have the same semantics as
current Lua. To be more precise,  if a list-item is followed by a
comma,then it is truncated to one return value; otherwise it
representsall the return values (possibly none). Consequently, {{
{foo(),} }} truncates, but {{ {foo();} }} and {{ {foo()} }} do not.
The patch also makes the order of field definitions precisely left to
right, unlike the current Lua implementation in which {{ {[3] = "foo",
1, 2, 3} }} has undefined behaviour. That may lead to performance
problems with very large tables which are defined like this:
{{{!Luat = {  "a", a = 1,  "b", b = 2,  "c", c = 3,  -- etc}}}}
Other than that, the performance implications are minimal; sometimes
it is a bit faster, sometimes it is a bit slower, but there is little
difference. Personally, I prefer the precise ordering guarantee, but
the patch can be easily modified to come closer to current semantics.
Contact me for more details.
The implementation is straight-forward. When a semi-colon is
encountered, the compiler emits code to append the current list of
expressions, leaving the last one as multi-return. In order to do
this, it's necessary to keep the current table array insertion point
on the stack, instead of hard-coding it into the vm code, so the
opcode to create a new table is modified to use two stack slots,
putting the table in the first one and initializing the second one to
1. The opcode which adds array values to a table uses the second stack
slot as the starting index, and updates it to the next starting index.
Although this uses one extra stack slot, it is roughly the same speed
as the existing code.

== Let files combined with luac access arguments (5.1.1) ==
When {{luac}} combines multiple files into a single bytecode chunk,
the resulting chunk does notaccept any arguments. This small patch
passes {{...}} into all files in the combined chunk
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 3/2/0        *'''Lua authors' position:''' ?
       *'''Author:''' RiciLake        *'''Last update:''' 2007-Jan-18
      * [http://primero.ricilake.net/lua/luac.patch Download for Lua
5.1.1] (Should work on 5.1 but untested)

== Autotoolized Lua (5.1.1) ==
This patch autotoolizes Lua distribution, i.e. makes it use autoconf,
automake, and libtool. For Lua 5.1 and 5.1.1.
        *'''Backwards compatible:''' no        *'''Lines
changed/added/deleted:''' unknown        *'''Lua authors' position:'''
?        *'''Author:''' Petri Lehtinen        *'''Last update:'''
2007-Jan-05        *
[http://www.digip.org/akheron/lua/lua-5.1.1-autotoolize-r1.patch.bz2
download (for Lua 5.1.1)]        *
[http://www.digip.org/akheron/lua/lua-5.1-autotoolize-r2.patch.bz2
download (for Lua 5.1)]
You must unpack the file before patching:        {{{bunzip2
lua-X.Y.Z-autotoolize-rW.patch.bz2}}}
Next, apply the patch.
After the patching you need to add executable flag to some files:
  {{{chmod u+x autogen.sh config.guess config.sub configure depcomp
install-sh missing}}}
Now you are ready to run {{./configure}}.

== __usedindex metamethod (5.1.1) ==
__usedindex behaves exactly like __newindex but when the indexed key
actually exists (value is overwritten). this allows
simpleimplementation of read-only tables, mirroring C structures etc
without slow/lengthy/fragile table proxying constructs.Known to be
broken with LuaJIT, fixes are welcome.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/3/0        *'''Lua authors' position:'''
     *'''Author:''' [http://blua.leet.cz/ Karel Tuma] (original patch
by Christopher Dunn - LuaPowerPatchesArchive)        *'''Last
update:''' 2006-Nov-14        *
[http://blua.leet.cz/sep/USEDINDEX_PATCH.patch download (for Lua
5.1.1)]
== experimental php-like 'break N' to break across multiple loops
==allows syntax like:while foo do  while bar do    if baz then
eek()      break 2    end  endend
if "foo and bar and baz" condition holds, 'break 2' escapes loops
imediately. the number is counted towards breakable scopes (thus "if",
"do" etc are left out)
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/3/1        *'''Lua authors' position:'''
     *'''Author:''' Karel Tuma        *'''Last update:''' 2006-Oct-31
      * [http://blua.leet.cz/sep/BREAKN_PATCH.patch download (for Lua
5.1.1)]

== string.format %s patched to use __tostring (5.1.1) ==
  Changes string.format %s to apply __tostring to non-string %s arguments.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 1/6/-        *'''Lua authors' position:'''
seated        *'''Author:''' DougCurrie        *'''Last update:'''
2006-Oct-03        *
[Files:wiki_insecure/power_patches/5.1/sformat511.patch download (for
Lua 5.1.1)]        * See
[http://lua-users.org/lists/lua-l/2006-10/msg00001.html mail] for
details on this patch.

== Enum/bit operations patch (5.1.1) ==
Adds C API functions (toenum, isenum, ..) for handling unsigned 32-bit
bitfields. Such enum values have overloaded [], () operations for
performing bitwise operations on the Lua side.Enums are grouped in
'families', to prevent accidential use of wrong bitmask in wrong
function.
The implementation uses negative 'tt' (Lua type) values for enums, and
they are not garbage collectable (= should be fast). 'type()' function
returns two values: "enum" and the family name. Documentation is
lacking.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 51/740/-        *'''Lua authors'
position:''' ?        *'''Author:''' AskoKauppi        *'''Last
update:''' 2006-Oct-1
{{{svn cat svn://slugak.dyndns.org/public/lua-bitwise/lua-5.1.1-enum-patch.diffsvn
cat svn://slugak.dyndns.org/public/lua-bitwise/test.luasvn cat
svn://slugak.dyndns.org/public/lua-bitwise/README}}}

== Go Long Lua! (5.1) ==
This patch removes floating point operations used by Lua 5.1 by
changing the type of Lua numbers from double to long.  It implements
division and modulus so that x == (x / y) * y + x % y.  The
exponentiation function returns zero for negative exponents.  The
patch removes the difftime function, and the math module should not be
used.  The string.format function no longer handles the floating point
directives %e, %E, %f, %g, and %G.  By removing the definition of
LUA_NUMBER_INTEGRAL in src/luaconf.h, one obtains a Lua number
implementation based on doubles.
        *'''Backwards compatible:''' purges math functions and the
behavior of exponentiation changed        *'''Lines
changed/added/deleted:''' -/64/6        *'''Lua authors' position:'''
?        *'''Author:''' John D. Ramsdell        *'''Last update:'''
2006-Apr-17        *
[http://www.ccs.neu.edu/home/ramsdell/tools/lua-5.1-no-fp.patch
download (for Lua 5.1)]
== Unpack Tables by Name (5.1) ==
Enhancement to the assignment statement to unpack named values from
tables using the {{in}} keyword.  (See lua-l message "patch: local a,b
from t" [LuaList:/2005-09/msg00219.html].)        {{{    local a, b, c
in some_table_expression}}}is syntactic sugar for        {{{    local
t = some_table_expression    local a, b, c = t.a, t.b, t.c}}}
       *'''Backwards compatible:''' yes        *'''Lines changed/added/deleted:'''
12/73/0 *'''Lua authors' position:''' ? *'''Author:'''
PeterShook      *'''Last update:''' 2006-Feb-18 *
[Files:wiki_insecure/power_patches/5.1/basic-from.patch download (for
lua-5.1)]       * [Files:wiki_insecure/power_patches/5.0/basic-from.patch
download (for lua-5.0.2)]
== Custom error object support (5.1) ==
This patch improves Lua's support for custom error objects.  Changes:
        * Uncaught error handler in standard Lua interpreter calls
tostring() on error object.  This ensures that a call stack is
displayed even for non-string error objects.  It also allows use of
the __tostring hook for human-readable error messages.
        * Base library error() will set the _WHERE field of any table
error object to the value of luaL_where().  Uncaught error handler in
the standard Lua interpreter will use this, so that for custom error
object the error location is shown in the call stack.  This is a bit
of a hack and implies that any thrown table should be a unique
instance of the error (since it will be mutated).  Rather than this
scheme, the ideal solution would be to have the Lua core manage the
location separate from the error object.
See "Exception Patterns in
Lua"[http://memebeam.org/john/lua/exception_patterns.pdf] for more
information.
       *'''Backwards compatible:''' yes        *'''Lines changed/added/deleted:'''
~20     *'''Lua authors' position:'''  "Where's the pcall/coroutine
patch?" *'''Author:''' JohnBelmonte     *'''Last update:''' 2006-Sep-8  *
[http://memebeam.org/john/lua/custom_errors.patch download]
 == CNUMBER patch (5.1) ==
  Provides a more efficient mechanism for accessing numeric C
variables from Lua.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/121/- (not including test suite)
*'''Lua authors' position:''' ?        *'''Author:''' DavidManura
  *'''Last update:''' 2006-Feb-18
*[Files:wiki_insecure/power_patches/5.1/cnumber.patch download (for
Lua 5.1)]        * See CnumberPatch for details on this patch.

== Kilobyte/Megabyte Number Suffix (5.1) ==
Add 'K' and 'M' suffixes for numbers (e.g. 150K or 12M); binary
(K=2^10) not metric (K=10^3).
Useful when using Lua as a configuration language in some domains (in
our case, a build process).
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 2/16/0        *'''Lua authors' position:'''
?        *'''Author:''' EricTetz        *'''Last update:'''
2007-Dec-14        *
[Files:wiki_insecure/power_patches/5.1/k-m-number-suffix.patch
download (for Lua 5.1)]

== Do patch (5.1 beta) ==
Makes "= do ... end" be syntactic sugar for "= function() ... end"
(handy with simple callbacks).
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' -/40/1        *'''Lua authors' position:'''
?        *'''Author:''' AskoKauppi        *'''Last update:'''
2006-Jan-12
{{{svn cat svn://slugak.dyndns.org/public/lua-patches/do.patchsvn cat
svn://slugak.dyndns.org/public/lua-patches/do.txt}}}
Instead of patching Lua, one might consider luaSub, which contains a
syntax mod for this same purpose.

== Literals (hex, UTF-8) (5.1 beta) ==
Allows \x00..\xFFFF (hex) and \u0000..\uFFFF (UTF-8 encoded)
characters within strings.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' -/94/1        *'''Lua authors' position:'''
?        *'''Author:''' AskoKauppi        *'''Last update:'''
2006-Jan-12
{{{svn cat svn://slugak.dyndns.org/public/lua-patches/literals.patchsvn
cat svn://slugak.dyndns.org/public/lua-patches/literals.txt}}}

== Equality operators that work like arithmetic operators (5.1 alpha) ==
This modifies the behavior of the equality operator functions so they
are able to handle values with dissimilar types. For instance, in
standard Lua if the left operand is a userdata and the right is a
number, the equality test will fail. This patch causes the __eq
metamethod of the userdata to be used, if available. But note, one
reason Lua does not support this is because the __eq, __lt and __le
metamethods are used for ~=, > and >= as well, by reversing the
operands. Therefore, if both the right and left operands have
metamethods, you might be surprised by which one gets chosen. As it
is, the left metamethod is preferred. But of course, this is the RIGHT
metamethod for the ~=, > and >= tests! A good solution to this might
be to add __ne, __gt and __ge metamethods. Then the equality operators
would truly behave exactly like the arithmetic operators.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' 14/7/8        *'''Lua authors' position:'''
?        *'''Author:''' Chris Marrin        *'''Last update:'''
2005-Sep-20        *
[Files:wiki_insecure/power_patches/5.1-alpha/UniformCompare.patch
download (for Lua 5.1-alpha)]

== Mutate Operators (5.1-work6) ==
This patch adds mutate operators to Lua.  Specifically, the ":="
operator can now be used for value assignment (or whatever else you
wish) by attaching a "__mutate_asn" metamethod to a Lua object.
Adding additional mutate operators (such as +=, or << for example) is
straightforward.
        *'''Backwards compatible:''' yes        *'''Lines
changed/added/deleted:''' ~70        *'''Lua authors' position:''' ?
     *'''Author:''' AndrewLauritzen        *'''Last update:'''
2005-Jun-23        *
[Files:wiki_insecure/power_patches/5.1-work6/mutate.patch download
(for Lua 5.1-work6)]