Lua diffs-lua-5.4.3-lua-5.4.4


Makefile

49c49
< R= $V.3
> R= $V.4

README

2c2
< This is Lua 5.4.3, released on 15 Mar 2021.
> This is Lua 5.4.4, released on 16 Nov 2021.

doc/manual.html

1639,1640c1639,1642
< The assignment statement first evaluates all its expressions
< and only then the assignments are performed.
> If a variable is both assigned and read
> inside a multiple assignment,
> Lua ensures all reads get the value of the variable
> before the assignment.

1664a1667,1674
> Note that this guarantee covers only accesses
> syntactically inside the assignment statement.
> If a function or a metamethod called during the assignment
> changes the value of a variable,
> Lua gives no guarantees about the order of that access.
> 
> 
> <p>

5936c5946,5949
< you must call <a href="#lua_getinfo"><code>lua_getinfo</code></a>.
> you must call <a href="#lua_getinfo"><code>lua_getinfo</code></a> with an appropriate parameter.
> (Specifically, to get a field,
> you must add the letter between parentheses in the field's comment
> to the parameter <code>what</code> of <a href="#lua_getinfo"><code>lua_getinfo</code></a>.)

6113c6126,6129
< a value to be pushed on the stack:
> a value to be pushed on the stack.
> (These characters are also documented in the declaration of
> the structure <a href="#lua_Debug"><code>lua_Debug</code></a>,
> between parentheses in the comments following each field.)

6117c6133,6144
< <li><b>'<code>n</code>': </b> fills in the field <code>name</code> and <code>namewhat</code>;
> <li><b>'<code>f</code>': </b>
> pushes onto the stack the function that is
> running at the given level;
> </li>
> 
> <li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>;
> </li>
> 
> <li><b>'<code>n</code>': </b> fills in the fields <code>name</code> and <code>namewhat</code>;
> </li>
> 
> <li><b>'<code>r</code>': </b> fills in the fields <code>ftransfer</code> and <code>ntransfer</code>;

6125,6127d6151
< <li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>;
< </li>
< 

6135,6139d6158
< <li><b>'<code>f</code>': </b>
< pushes onto the stack the function that is
< running at the given level;
< </li>
< 

6141,6148c6160,6163
< pushes onto the stack a table whose indices are the
< numbers of the lines that are valid on the function.
< (A <em>valid line</em> is a line with some associated code,
< that is, a line where you can put a break point.
< Non-valid lines include empty lines and comments.)
< 
< 
< <p>
> pushes onto the stack a table whose indices are
> the lines on the function with some associated code,
> that is, the lines where you can put a break point.
> (Lines with no code include empty lines and comments.)

6151,6153d6165
< 
< 
< <p>

6511c6523
< <span class="apii">[-0, +0, <em>m</em>]</span>
> <span class="apii">[-?, +?, <em>m</em>]</span>

6565c6577
< <span class="apii">[-1, +?, <em>m</em>]</span>
> <span class="apii">[-?, +?, <em>m</em>]</span>

6719c6731
< <span class="apii">[-0, +0, &ndash;]</span>
> <span class="apii">[-0, +?, &ndash;]</span>

6757c6769
< <span class="apii">[-0, +0, &ndash;]</span>
> <span class="apii">[-?, +?, &ndash;]</span>

7559a7572,7576
> <p>
> A function with a <code>NULL</code> value represents a placeholder,
> which is filled with <b>false</b>.
> 
> 

7939c7956
< Raises an error (see <a href="#2.3">&sect;2.3</a>) with @{message} as the error object.
> Raises an error (see <a href="#2.3">&sect;2.3</a>) with <code>message</code> as the error object.

8114,8116c8131,8132
< The behavior of <code>next</code> is undefined if,
< during the traversal,
< you assign any value to a non-existent field in the table.
> You should not assign any value to a non-existent field in a table
> during its traversal.

8162c8178
< which is true if the call succeeds without errors.
> which is <b>true</b> if the call succeeds without errors.

8442c8458
< Returns true when the coroutine <code>co</code> can yield.
> Returns <b>true</b> when the coroutine <code>co</code> can yield.

8486c8502
< true when the running coroutine is the main one.
> <b>true</b> when the running coroutine is the main one.

9024c9040
< A value of <b>true</b> as a fourth, optional argument <code>plain</code>
> A <b>true</b> as a fourth, optional argument <code>plain</code>

9049c9065
< <code>*</code>, <code>h</code>, <code>L</code>, <code>l</code>, and <code>n</code> are not supported
> <code>F</code>, <code>n</code>, <code>*</code>, <code>h</code>, <code>L</code>, and <code>l</code> are not supported

9050a9067,9068
> Both width and precision, when present,
> are limited to two digits.

9074c9092
< This specifier does not support modifiers (flags, width, length).
> This specifier does not support modifiers (flags, width, precision).

10365c10383
< true if and only if integer <code>m</code> is below integer <code>n</code> when
> <b>true</b> if and only if integer <code>m</code> is below integer <code>n</code> when

11927c11945
< Mon Mar 15 13:39:42 UTC 2021
> Tue Nov 16 18:30:51 UTC 2021

11930c11948
< Last change: revised for Lua 5.4.3
> Last change: revised for Lua 5.4.4

doc/readme.html

113c113
< the top-level directory, which is named <TT>lua-5.4.3</TT>.
> the top-level directory, which is named <TT>lua-5.4.4</TT>.

333c333
< Wed Mar  3 10:16:26 UTC 2021
> Thu Nov  4 16:26:26 UTC 2021

336c336
< Last change: revised for Lua 5.4.3
> Last change: revised for Lua 5.4.4

src/Makefile

82c82
< 	@echo "LDFLAGS= $(SYSLDFLAGS)"
> 	@echo "LDFLAGS= $(LDFLAGS)"

src/lapi.c

55a56,59
> /*
> ** Convert an acceptable index to a pointer to its respective value.
> ** Non-valid indices return the special nil value 'G(L)->nilvalue'.
> */

73,75c77
<     if (ttislcf(s2v(ci->func)))  /* light C function? */
<       return &G(L)->nilvalue;  /* it has no upvalues */
<     else {
>     if (ttisCclosure(s2v(ci->func))) {  /* C closure? */

79a82,85
>     else {  /* light C function or Lua function (through a hook)?) */
>       api_check(L, ttislcf(s2v(ci->func)), "caller not a C function");
>       return &G(L)->nilvalue;  /* no upvalues */
>     }

84c90,94
< static StkId index2stack (lua_State *L, int idx) {
> 
> /*
> ** Convert a valid actual index (not a pseudo-index) to its address.
> */
> l_sinline StkId index2stack (lua_State *L, int idx) {

88c98
<     api_check(L, o < L->top, "unacceptable index");
>     api_check(L, o < L->top, "invalid index");

221c231
< static void reverse (lua_State *L, StkId from, StkId to) {
> l_sinline void reverse (lua_State *L, StkId from, StkId to) {

441c451
< static void *touserdata (const TValue *o) {
> l_sinline void *touserdata (const TValue *o) {

633c643
< static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
> l_sinline int auxgetstr (lua_State *L, const TValue *t, const char *k) {

708c718
< static int finishrawget (lua_State *L, const TValue *val) {
> l_sinline int finishrawget (lua_State *L, const TValue *val) {

src/lauxlib.c

883a884
>   idx = lua_absindex(L,idx);

src/lauxlib.h

105c105
< LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
> LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s,

156a157,164
> /*
> ** Perform arithmetic operations on lua_Integer values with wrap-around
> ** semantics, as the Lua core does.
> */
> #define luaL_intop(op,v1,v2)  \
> 	((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2)))
> 
> 

src/lbaselib.c

263a264,268
> static int pairscont (lua_State *L, int status, lua_KContext k) {
>   (void)L; (void)status; (void)k;  /* unused */
>   return 3;
> }
> 

273c278
<     lua_call(L, 1, 3);  /* get 3 values from metamethod */
>     lua_callk(L, 1, 3, 0, pairscont);  /* get 3 values from metamethod */

283c288,289
<   lua_Integer i = luaL_checkinteger(L, 2) + 1;
>   lua_Integer i = luaL_checkinteger(L, 2);
>   i = luaL_intop(+, i, 1);

src/lcode.c

12a13
> #include <float.h>

583,585d583
< ** Integers use userdata as keys to avoid collision with floats with
< ** same value; conversion to 'void*' is used only for hashing, so there
< ** are no "precision" problems.

588,589c586
<   TValue k, o;
<   setpvalue(&k, cast_voidp(cast_sizet(n)));
>   TValue o;

591c588
<   return addk(fs, &k, &o);
>   return addk(fs, &o, &o);  /* use integer itself as key */

595c592,600
< ** Add a float to list of constants and return its index.
> ** Add a float to list of constants and return its index. Floats
> ** with integral values need a different key, to avoid collision
> ** with actual integers. To that, we add to the number its smaller
> ** power-of-two fraction that is still significant in its scale.
> ** For doubles, that would be 1/2^52.
> ** (This method is not bulletproof: there may be another float
> ** with that value, and for floats larger than 2^53 the result is
> ** still an integer. At worst, this only wastes an entry with
> ** a duplicate.)

598a604
>   lua_Integer ik;

600c606,618
<   return addk(fs, &o, &o);  /* use number itself as key */
>   if (!luaV_flttointeger(r, &ik, F2Ieq))  /* not an integral value? */
>     return addk(fs, &o, &o);  /* use number itself as key */
>   else {  /* must build an alternative key */
>     const int nbm = l_floatatt(MANT_DIG);
>     const lua_Number q = l_mathop(ldexp)(1.0, -nbm + 1);
>     const lua_Number k = (ik == 0) ? q : r + r*q;  /* new key */
>     TValue kv;
>     setfltvalue(&kv, k);
>     /* result is not an integral value, unless value is too large */
>     lua_assert(!luaV_flttointeger(k, &ik, F2Ieq) ||
>                 l_mathop(fabs)(r) >= l_mathop(1e6));
>     return addk(fs, &kv, &o);
>   }

src/lcorolib.c

81c81
<       lua_xmove(co, L, 1);  /* copy error message */
>       lua_xmove(co, L, 1);  /* move error message to the caller */

182c182
<         lua_xmove(co, L, 1);  /* copy error message */
>         lua_xmove(co, L, 1);  /* move error message */

src/ldebug.c

67c67
<     /* estimate must be a lower bond of the correct base */
>     /* estimate must be a lower bound of the correct base */

304c304,311
<     for (i = 0; i < p->sizelineinfo; i++) {  /* for all instructions */
>     if (!p->is_vararg)  /* regular function? */
>       i = 0;  /* consider all instructions */
>     else {  /* vararg function */
>       lua_assert(p->code[0] == OP_VARARGPREP);
>       currentline = nextline(p, currentline, 0);
>       i = 1;  /* skip first instruction (OP_VARARGPREP) */
>     }
>     for (; i < p->sizelineinfo; i++) {  /* for each instruction */

677a685,696
> static const char *formatvarinfo (lua_State *L, const char *kind,
>                                                 const char *name) {
>   if (kind == NULL)
>     return "";  /* no information */
>   else
>     return luaO_pushfstring(L, " (%s '%s')", kind, name);
> }
> 
> /*
> ** Build a string with a "description" for the value 'o', such as
> ** "variable 'x'" or "upvalue 'y'".
> */

679d697
<   const char *name = NULL;  /* to avoid warnings */

680a699
>   const char *name = NULL;  /* to avoid warnings */

688c707
<   return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : "";
>   return formatvarinfo(L, kind, name);

692c711,715
< l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
> /*
> ** Raise a type error
> */
> static l_noret typeerror (lua_State *L, const TValue *o, const char *op,
>                           const char *extra) {

694c717
<   luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o));
>   luaG_runerror(L, "attempt to %s a %s value%s", op, t, extra);

697a721,734
> /*
> ** Raise a type error with "standard" information about the faulty
> ** object 'o' (using 'varinfo').
> */
> l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
>   typeerror(L, o, op, varinfo(L, o));
> }
> 
> 
> /*
> ** Raise an error for calling a non-callable object. Try to find
> ** a name for the object based on the code that made the call
> ** ('funcnamefromcode'); if it cannot get a name there, try 'varinfo'.
> */

701,707c738,740
<   const char *what = (isLua(ci)) ? funcnamefromcode(L, ci, &name) : NULL;
<   if (what != NULL) {
<     const char *t = luaT_objtypename(L, o);
<     luaG_runerror(L, "%s '%s' is not callable (a %s value)", what, name, t);
<   }
<   else
<     luaG_typeerror(L, o, "call");
>   const char *kind = (isLua(ci)) ? funcnamefromcode(L, ci, &name) : NULL;
>   const char *extra = kind ? formatvarinfo(L, kind, name) : varinfo(L, o);
>   typeerror(L, o, "call", extra);

src/ldo.c

390,391c390,391
< void luaD_tryfuncTM (lua_State *L, StkId func) {
<   const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);
> StkId luaD_tryfuncTM (lua_State *L, StkId func) {
>   const TValue *tm;

392a393,394
>   checkstackGCp(L, 1, func);  /* space for metamethod */
>   tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);  /* (after previous GC) */

398a401
>   return func;

408c411
< static void moveresults (lua_State *L, StkId res, int nres, int wanted) {
> l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) {

475a479,513
> l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret,
>                                                 int mask, StkId top) {
>   CallInfo *ci = L->ci = next_ci(L);  /* new frame */
>   ci->func = func;
>   ci->nresults = nret;
>   ci->callstatus = mask;
>   ci->top = top;
>   return ci;
> }
> 
> 
> /*
> ** precall for C functions
> */
> l_sinline int precallC (lua_State *L, StkId func, int nresults,
>                                             lua_CFunction f) {
>   int n;  /* number of returns */
>   CallInfo *ci;
>   checkstackGCp(L, LUA_MINSTACK, func);  /* ensure minimum stack size */
>   L->ci = ci = prepCallInfo(L, func, nresults, CIST_C,
>                                L->top + LUA_MINSTACK);
>   lua_assert(ci->top <= L->stack_last);
>   if (l_unlikely(L->hookmask & LUA_MASKCALL)) {
>     int narg = cast_int(L->top - func) - 1;
>     luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
>   }
>   lua_unlock(L);
>   n = (*f)(L);  /* do the actual call */
>   lua_lock(L);
>   api_checknelems(L, n);
>   luaD_poscall(L, ci, n);
>   return n;
> }
> 
> 

479c517,518
< ** (so that it includes the function itself).
> ** (so that it includes the function itself). Return the number of
> ** results, if it was a C function, or -1 for a Lua function.

481,496c520,553
< void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) {
<   Proto *p = clLvalue(s2v(func))->p;
<   int fsize = p->maxstacksize;  /* frame size */
<   int nfixparams = p->numparams;
<   int i;
<   for (i = 0; i < narg1; i++)  /* move down function and arguments */
<     setobjs2s(L, ci->func + i, func + i);
<   checkstackGC(L, fsize);
<   func = ci->func;  /* moved-down function */
<   for (; narg1 <= nfixparams; narg1++)
<     setnilvalue(s2v(func + narg1));  /* complete missing arguments */
<   ci->top = func + 1 + fsize;  /* top for new function */
<   lua_assert(ci->top <= L->stack_last);
<   ci->u.l.savedpc = p->code;  /* starting point */
<   ci->callstatus |= CIST_TAIL;
<   L->top = func + narg1;  /* set top */
> int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
>                                     int narg1, int delta) {
>  retry:
>   switch (ttypetag(s2v(func))) {
>     case LUA_VCCL:  /* C closure */
>       return precallC(L, func, LUA_MULTRET, clCvalue(s2v(func))->f);
>     case LUA_VLCF:  /* light C function */
>       return precallC(L, func, LUA_MULTRET, fvalue(s2v(func)));
>     case LUA_VLCL: {  /* Lua function */
>       Proto *p = clLvalue(s2v(func))->p;
>       int fsize = p->maxstacksize;  /* frame size */
>       int nfixparams = p->numparams;
>       int i;
>       ci->func -= delta;  /* restore 'func' (if vararg) */
>       for (i = 0; i < narg1; i++)  /* move down function and arguments */
>         setobjs2s(L, ci->func + i, func + i);
>       checkstackGC(L, fsize);
>       func = ci->func;  /* moved-down function */
>       for (; narg1 <= nfixparams; narg1++)
>         setnilvalue(s2v(func + narg1));  /* complete missing arguments */
>       ci->top = func + 1 + fsize;  /* top for new function */
>       lua_assert(ci->top <= L->stack_last);
>       ci->u.l.savedpc = p->code;  /* starting point */
>       ci->callstatus |= CIST_TAIL;
>       L->top = func + narg1;  /* set top */
>       return -1;
>     }
>     default: {  /* not a function */
>       func = luaD_tryfuncTM(L, func);  /* try to get '__call' metamethod */
>       /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */
>       narg1++;
>       goto retry;  /* try again */
>     }
>   }

509d565
<   lua_CFunction f;

513,514c569,570
<       f = clCvalue(s2v(func))->f;
<       goto Cfunc;
>       precallC(L, func, nresults, clCvalue(s2v(func))->f);
>       return NULL;

516,535c572
<       f = fvalue(s2v(func));
<      Cfunc: {
<       int n;  /* number of returns */
<       CallInfo *ci;
<       checkstackGCp(L, LUA_MINSTACK, func);  /* ensure minimum stack size */
<       L->ci = ci = next_ci(L);
<       ci->nresults = nresults;
<       ci->callstatus = CIST_C;
<       ci->top = L->top + LUA_MINSTACK;
<       ci->func = func;
<       lua_assert(ci->top <= L->stack_last);
<       if (l_unlikely(L->hookmask & LUA_MASKCALL)) {
<         int narg = cast_int(L->top - func) - 1;
<         luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
<       }
<       lua_unlock(L);
<       n = (*f)(L);  /* do the actual call */
<       lua_lock(L);
<       api_checknelems(L, n);
<       luaD_poscall(L, ci, n);
>       precallC(L, func, nresults, fvalue(s2v(func)));

537d573
<     }

545,546c581
<       L->ci = ci = next_ci(L);
<       ci->nresults = nresults;
>       L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize);

548,550d582
<       ci->top = func + 1 + fsize;
<       ci->func = func;
<       L->ci = ci;

557,558c589,590
<       checkstackGCp(L, 1, func);  /* space for metamethod */
<       luaD_tryfuncTM(L, func);  /* try to get '__call' metamethod */
>       func = luaD_tryfuncTM(L, func);  /* try to get '__call' metamethod */
>       /* return luaD_precall(L, func, nresults); */

570c602
< static void ccall (lua_State *L, StkId func, int nResults, int inc) {
> l_sinline void ccall (lua_State *L, StkId func, int nResults, int inc) {

731c763
<     ccall(L, firstArg - 1, LUA_MULTRET, 1);  /* just call its body */
>     ccall(L, firstArg - 1, LUA_MULTRET, 0);  /* just call its body */

735d766
<     luaE_incCstack(L);  /* control the C stack */

785a817,819
>   if (getCcalls(L) >= LUAI_MAXCCALLS)
>     return resume_error(L, "C stack overflow", nargs);
>   L->nCcalls++;

src/ldo.h

61c61
< LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n);
> LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,                                                    int narg1, int delta);

65c65
< LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func);
> LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func);

src/llimits.h

168a169,182
> ** Inline functions
> */
> #if !defined(LUA_USE_C89)
> #define l_inline	inline
> #elif defined(__GNUC__)
> #define l_inline	__inline__
> #else
> #define l_inline	/* empty */
> #endif
> 
> #define l_sinline	static l_inline
> 
> 
> /*

src/lobject.h

71c71
< #define valraw(o)	(&val_(o))
> #define valraw(o)	(val_(o))

115c115
< /* main macro to copy values (from 'obj1' to 'obj2') */
> /* main macro to copy values (from 'obj2' to 'obj1') */

src/lopcodes.h

193c193,194
< ** grep "ORDER OP" if you change these enums
> ** Grep "ORDER OP" if you change these enums. Opcodes marked with a (*)
> ** has extra descriptions in the notes after the enumeration.

206c207
< OP_LFALSESKIP,/*A	R[A] := false; pc++				*/
> OP_LFALSESKIP,/*A	R[A] := false; pc++	(*)			*/

257c258
< OP_MMBIN,/*	A B C	call C metamethod over R[A] and R[B]		*/
> OP_MMBIN,/*	A B C	call C metamethod over R[A] and R[B]	(*)	*/

283c284
< OP_TESTSET,/*	A B k	if (not R[B] == k) then pc++ else R[A] := R[B]	*/
> OP_TESTSET,/*	A B k	if (not R[B] == k) then pc++ else R[A] := R[B] (*) */

317a319,330
> 
>   (*) Opcode OP_LFALSESKIP is used to convert a condition to a boolean
>   value, in a code equivalent to (not cond ? false : true).  (It
>   produces false and skips the next instruction producing true.)
> 
>   (*) Opcodes OP_MMBIN and variants follow each arithmetic and
>   bitwise opcode. If the operation succeeds, it skips this next
>   opcode. Otherwise, this opcode calls the corresponding metamethod.
> 
>   (*) Opcode OP_TESTSET is used in short-circuit expressions that need
>   both to jump and to produce a value, such as (a = b or c).
> 

src/lparser.c

419a420,430
> ** Mark that current block has a to-be-closed variable.
> */
> static void marktobeclosed (FuncState *fs) {
>   BlockCnt *bl = fs->bl;
>   bl->upval = 1;
>   bl->insidetbc = 1;
>   fs->needclose = 1;
> }
> 
> 
> /*

1602c1613
<   markupval(fs, fs->nactvar);  /* last control var. must be closed */
>   marktobeclosed(fs);  /* last control var. must be closed */

1706c1717
< static void checktoclose (LexState *ls, int level) {
> static void checktoclose (FuncState *fs, int level) {

1708,1710c1719
<     FuncState *fs = ls->fs;
<     markupval(fs, level + 1);
<     fs->bl->insidetbc = 1;  /* in the scope of a to-be-closed variable */
>     marktobeclosed(fs);

1754c1763
<   checktoclose(ls, toclose);
>   checktoclose(fs, toclose);

1778a1788
>   check_readonly(ls, &v);

src/lstate.c

169c169
<     luaD_throw(L, LUA_ERRERR);  /* error while handing stack error */
>     luaD_throw(L, LUA_ERRERR);  /* error while handling stack error */

272c272
<     luaC_freeallobjects(L);  /* jucst collect its objects */
>     luaC_freeallobjects(L);  /* just collect its objects */

332a333
>   L->status = LUA_OK;  /* so it can run __close metamethods */

339d339
<   L->status = cast_byte(status);

src/lstate.h

168c168
< ** returning from a C function;
> ** returning from a function;

src/lstrlib.c

1093,1094c1093,1109
< #if !defined(L_FMTFLAGS)
< #define L_FMTFLAGS	"-+ #0"
> #if !defined(L_FMTFLAGSF)
> 
> /* valid flags for a, A, e, E, f, F, g, and G conversions */
> #define L_FMTFLAGSF	"-+#0 "
> 
> /* valid flags for o, x, and X conversions */
> #define L_FMTFLAGSX	"-#0"
> 
> /* valid flags for d and i conversions */
> #define L_FMTFLAGSI	"-+0 "
> 
> /* valid flags for u conversions */
> #define L_FMTFLAGSU	"-0"
> 
> /* valid flags for c, p, and s conversions */
> #define L_FMTFLAGSC	"-"
> 

1099c1114,1117
< ** maximum size of each format specification (such as "%-099.99d")
> ** Maximum size of each format specification (such as "%-099.99d"):
> ** Initial '%', flags (up to 5), width (2), period, precision (2),
> ** length modifier (8), conversion specifier, and final '\0', plus some
> ** extra.

1192,1202c1210,1213
< static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
<   const char *p = strfrmt;
<   while (*p != '\0' && strchr(L_FMTFLAGS, *p) != NULL) p++;  /* skip flags */
<   if ((size_t)(p - strfrmt) >= sizeof(L_FMTFLAGS)/sizeof(char))
<     luaL_error(L, "invalid format (repeated flags)");
<   if (isdigit(uchar(*p))) p++;  /* skip width */
<   if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
<   if (*p == '.') {
<     p++;
<     if (isdigit(uchar(*p))) p++;  /* skip precision */
<     if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
> static const char *get2digits (const char *s) {
>   if (isdigit(uchar(*s))) {
>     s++;
>     if (isdigit(uchar(*s))) s++;  /* (2 digits at most) */

1204,1205c1215,1252
<   if (isdigit(uchar(*p)))
<     luaL_error(L, "invalid format (width or precision too long)");
>   return s;
> }
> 
> 
> /*
> ** Check whether a conversion specification is valid. When called,
> ** first character in 'form' must be '%' and last character must
> ** be a valid conversion specifier. 'flags' are the accepted flags;
> ** 'precision' signals whether to accept a precision.
> */
> static void checkformat (lua_State *L, const char *form, const char *flags,
>                                        int precision) {
>   const char *spec = form + 1;  /* skip '%' */
>   spec += strspn(spec, flags);  /* skip flags */
>   if (*spec != '0') {  /* a width cannot start with '0' */
>     spec = get2digits(spec);  /* skip width */
>     if (*spec == '.' && precision) {
>       spec++;
>       spec = get2digits(spec);  /* skip precision */
>     }
>   }
>   if (!isalpha(uchar(*spec)))  /* did not go to the end? */
>     luaL_error(L, "invalid conversion specification: '%s'", form);
> }
> 
> 
> /*
> ** Get a conversion specification and copy it to 'form'.
> ** Return the address of its last character.
> */
> static const char *getformat (lua_State *L, const char *strfrmt,
>                                             char *form) {
>   /* spans flags, width, and precision ('0' is included as a flag) */
>   size_t len = strspn(strfrmt, L_FMTFLAGSF "123456789.");
>   len++;  /* adds following character (should be the specifier) */
>   /* still needs space for '%', '\0', plus a length modifier */
>   if (len >= MAX_FORMAT - 10)
>     luaL_error(L, "invalid format (too long)");

1207,1210c1254,1256
<   memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char));
<   form += (p - strfrmt) + 1;
<   *form = '\0';
<   return p;
>   memcpy(form, strfrmt, len * sizeof(char));
>   *(form + len) = '\0';
>   return strfrmt + len - 1;

1232a1279
>   const char *flags;

1242,1244c1289,1291
<       int maxitem = MAX_ITEM;
<       char *buff = luaL_prepbuffsize(&b, maxitem);  /* to put formatted item */
<       int nb = 0;  /* number of bytes in added item */
>       int maxitem = MAX_ITEM;  /* maximum length for the result */
>       char *buff = luaL_prepbuffsize(&b, maxitem);  /* to put result */
>       int nb = 0;  /* number of bytes in result */

1247c1294
<       strfrmt = scanformat(L, strfrmt, form);
>       strfrmt = getformat(L, strfrmt, form);

1249a1297
>           checkformat(L, form, L_FMTFLAGSC, 0);

1254c1302,1309
<         case 'o': case 'u': case 'x': case 'X': {
>           flags = L_FMTFLAGSI;
>           goto intcase;
>         case 'u':
>           flags = L_FMTFLAGSU;
>           goto intcase;
>         case 'o': case 'x': case 'X':
>           flags = L_FMTFLAGSX;
>          intcase: {

1255a1311
>           checkformat(L, form, flags, 1);

1260a1317
>           checkformat(L, form, L_FMTFLAGSF, 1);

1270a1328
>           checkformat(L, form, L_FMTFLAGSF, 1);

1276a1335
>           checkformat(L, form, L_FMTFLAGSC, 0);

1297c1356,1357
<             if (!strchr(form, '.') && l >= 100) {
>             checkformat(L, form, L_FMTFLAGSC, 1);
>             if (strchr(form, '.') == NULL && l >= 100) {

1355,1363d1414
< /* dummy structure to get native alignment requirements */
< struct cD {
<   char c;
<   union { double d; void *p; lua_Integer i; lua_Number n; } u;
< };
< 
< #define MAXALIGN	(offsetof(struct cD, u))
< 
< 

1437a1489,1490
>   /* dummy structure to get native alignment requirements */
>   struct cD { char c; union { LUAI_MAXALIGN; } u; };

1468c1521,1525
<     case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break;
>     case '!': {
>       const int maxalign = offsetof(struct cD, u);
>       h->maxalign = getnumlimit(h, fmt, maxalign);
>       break;
>     }

src/ltable.c

87,88d86
< #define hashint(t,i)		hashpow2(t, i)
< 

103a102,115
> /*
> ** Hash for integers. To allow a good hash, use the remainder operator
> ** ('%'). If integer fits as a non-negative int, compute an int
> ** remainder, which is faster. Otherwise, use an unsigned-integer
> ** remainder, which uses all bits and ensures a non-negative result.
> */
> static Node *hashint (const Table *t, lua_Integer i) {
>   lua_Unsigned ui = l_castS2U(i);
>   if (ui <= (unsigned int)INT_MAX)
>     return hashmod(t, cast_int(ui));
>   else
>     return hashmod(t, ui);
> }
> 

141c153
< static Node *mainposition (const Table *t, int ktt, const Value *kvl) {
> static Node *mainposition (const Table *t, int ktt, const Value kvl) {

144c156
<       lua_Integer key = ivalueraw(*kvl);
>       lua_Integer key = ivalueraw(kvl);

148c160
<       lua_Number n = fltvalueraw(*kvl);
>       lua_Number n = fltvalueraw(kvl);

152c164
<       TString *ts = tsvalueraw(*kvl);
>       TString *ts = tsvalueraw(kvl);

156c168
<       TString *ts = tsvalueraw(*kvl);
>       TString *ts = tsvalueraw(kvl);

164c176
<       void *p = pvalueraw(*kvl);
>       void *p = pvalueraw(kvl);

168c180
<       lua_CFunction f = fvalueraw(*kvl);
>       lua_CFunction f = fvalueraw(kvl);

172c184
<       GCObject *o = gcvalueraw(*kvl);
>       GCObject *o = gcvalueraw(kvl);

682c694
<     othern = mainposition(t, keytt(mp), &keyval(mp));
>     othern = mainposition(t, keytt(mp), keyval(mp));

src/ltablib.c

62d61
<   lua_Integer e = aux_getn(L, 1, TAB_RW) + 1;  /* first empty element */

63a63,64
>   lua_Integer e = aux_getn(L, 1, TAB_RW);
>   e = luaL_intop(+, e, 1);  /* first empty element */

150c151
<                   luaL_typename(L, -1), i);
>                   luaL_typename(L, -1), (LUAI_UACINT)i);

src/lua.c

92,99c92,100
<   "  -e stat  execute string 'stat'\n"
<   "  -i       enter interactive mode after executing 'script'\n"
<   "  -l name  require library 'name' into global 'name'\n"
<   "  -v       show version information\n"
<   "  -E       ignore environment variables\n"
<   "  -W       turn warnings on\n"
<   "  --       stop handling options\n"
<   "  -        stop handling options and execute stdin\n"
>   "  -e stat   execute string 'stat'\n"
>   "  -i        enter interactive mode after executing 'script'\n"
>   "  -l mod    require library 'mod' into global 'mod'\n"
>   "  -l g=mod  require library 'mod' into global 'g'\n"
>   "  -v        show version information\n"
>   "  -E        ignore environment variables\n"
>   "  -W        turn warnings on\n"
>   "  --        stop handling options\n"
>   "  -         stop handling options and execute stdin\n"

210,211c211
< ** Calls 'require(name)' and stores the result in a global variable
< ** with the given name.
> ** Receives 'globname[=modname]' and runs 'globname = require(modname)'.

213c213
< static int dolibrary (lua_State *L, const char *name) {
> static int dolibrary (lua_State *L, char *globname) {

214a215,221
>   char *modname = strchr(globname, '=');
>   if (modname == NULL)  /* no explicit name? */
>     modname = globname;  /* module name is equal to global name */
>   else {
>     *modname = '\0';  /* global name ends here */
>     modname++;  /* module name starts after the '=' */
>   }

216,217c223,224
<   lua_pushstring(L, name);
<   status = docall(L, 1, 1);  /* call 'require(name)' */
>   lua_pushstring(L, modname);
>   status = docall(L, 1, 1);  /* call 'require(modname)' */

219c226
<     lua_setglobal(L, name);  /* global[name] = require return */
>     lua_setglobal(L, globname);  /* globname = require(modname) */

330c337
<         const char *extra = argv[i] + 2;  /* both options need an argument */
>         char *extra = argv[i] + 2;  /* both options need an argument */

src/lua.h

21c21
< #define LUA_VERSION_RELEASE	"3"
> #define LUA_VERSION_RELEASE	"4"

24c24
< #define LUA_VERSION_RELEASE_NUM		(LUA_VERSION_NUM * 100 + 0)
> #define LUA_VERSION_RELEASE_NUM		(LUA_VERSION_NUM * 100 + 4)

src/luac.c

157a158
>   luaM_freearray(L,f->lineinfo,f->sizelineinfo);

603c604
< 	printf("%d %d %d",a,b,c);
> 	printf("%d %d %d%s",a,b,c,ISK);

607c608
< 	printf("%d %d %d",a,b,c);
> 	printf("%d %d %d%s",a,b,c,ISK);

622c623
< 	printf(COMMENT "to %d",pc+bx+2);
> 	printf(COMMENT "exit to %d",pc+bx+3);

src/luaconf.h

488d487
< @@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.

509,511d507
< #define LUA_UNSIGNEDBITS	(sizeof(LUA_UNSIGNED) * CHAR_BIT)
< 
< 

src/lutf8lib.c

227,232c227,229
<   lua_Integer n = lua_tointeger(L, 2) - 1;
<   if (n < 0)  /* first iteration? */
<     n = 0;  /* start from here */
<   else if (n < (lua_Integer)len) {
<     n++;  /* skip current byte */
<     while (iscont(s + n)) n++;  /* and its continuations */
>   lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2);
>   if (n < len) {
>     while (iscont(s + n)) n++;  /* skip continuation bytes */

234c231
<   if (n >= (lua_Integer)len)
>   if (n >= len)  /* (also handles original 'n' being negative) */

src/lvm.c

409c409
< static int LTintfloat (lua_Integer i, lua_Number f) {
> l_sinline int LTintfloat (lua_Integer i, lua_Number f) {

426c426
< static int LEintfloat (lua_Integer i, lua_Number f) {
> l_sinline int LEintfloat (lua_Integer i, lua_Number f) {

443c443
< static int LTfloatint (lua_Number f, lua_Integer i) {
> l_sinline int LTfloatint (lua_Number f, lua_Integer i) {

460c460
< static int LEfloatint (lua_Number f, lua_Integer i) {
> l_sinline int LEfloatint (lua_Number f, lua_Integer i) {

476c476
< static int LTnum (const TValue *l, const TValue *r) {
> l_sinline int LTnum (const TValue *l, const TValue *r) {

498c498
< static int LEnum (const TValue *l, const TValue *r) {
> l_sinline int LEnum (const TValue *l, const TValue *r) {

769c769,770
< #define luaV_shiftr(x,y)	luaV_shiftl(x,-(y))
> #define luaV_shiftr(x,y)	luaV_shiftl(x,intop(-, 0, y))
> 

850c851
<     case OP_CLOSE:  case OP_RETURN: {  /* yielded closing variables */
>     case OP_CLOSE: {  /* yielded closing variables */

853a855,863
>     case OP_RETURN: {  /* yielded closing variables */
>       StkId ra = base + GETARG_A(inst);
>       /* adjust top to signal correct number of returns, in case the
>          return is "up to top" ('isIT') */
>       L->top = ra + ci->u2.nres;
>       /* repeat instruction to close other vars. and complete the return */
>       ci->u.l.savedpc--;
>       break;
>     }

1102c1112
< ** Protect code that can only raise errors. (That is, it cannnot change
> ** Protect code that can only raise errors. (That is, it cannot change

1159,1160c1169,1172
< // low-level line tracing for debugging Lua
< // printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
>     #if 0
>       /* low-level line tracing for debugging Lua */
>       printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
>     #endif

1628d1639
<           ci->callstatus = 0;  /* call re-uses 'luaV_execute' */

1634a1646
>         int n;  /* number of results when calling a C function */

1648,1656c1660,1662
<         while (!ttisfunction(s2v(ra))) {  /* not a function? */
<           luaD_tryfuncTM(L, ra);  /* try '__call' metamethod */
<           b++;  /* there is now one extra argument */
<           checkstackGCp(L, 1, ra);
<         }
<         if (!ttisLclosure(s2v(ra))) {  /* C function? */
<           luaD_precall(L, ra, LUA_MULTRET);  /* call it */
<           updatetrap(ci);
<           updatestack(ci);  /* stack may have been relocated */
>         if ((n = luaD_pretailcall(L, ci, ra, b, delta)) < 0)  /* Lua function? */
>           goto startfunc;  /* execute the callee */
>         else {  /* C function? */

1658c1664
<           luaD_poscall(L, ci, cast_int(L->top - ra));  /* finish caller */
>           luaD_poscall(L, ci, n);  /* finish caller */

1662,1664d1667
<         ci->func -= delta;  /* restore 'func' (if vararg) */
<         luaD_pretailcall(L, ci, ra, b);  /* prepare call frame */
<         goto startfunc;  /* execute the callee */

1672a1676
>           ci->u2.nres = n;  /* save number of returns */