diff -u -Nr lua-5.4.0/Makefile lua-5.4.1/Makefile --- lua-5.4.0/Makefile 2020-04-15 09:55:07.000000000 -0300 +++ lua-5.4.1/Makefile 2020-09-30 06:41:43.000000000 -0300 @@ -46,7 +46,7 @@ # Lua version and release. V= 5.4 -R= $V.0 +R= $V.1 # Targets start here. all: $(PLAT) diff -u -Nr lua-5.4.0/README lua-5.4.1/README --- lua-5.4.0/README 2020-06-18 13:11:05.000000000 -0300 +++ lua-5.4.1/README 2020-09-30 06:57:11.000000000 -0300 @@ -1,5 +1,5 @@ -This is Lua 5.4.0, released on 18 Jun 2020. +This is Lua 5.4.1, released on 30 Sep 2020. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff -u -Nr lua-5.4.0/doc/contents.html lua-5.4.1/doc/contents.html --- lua-5.4.0/doc/contents.html 2020-05-30 08:22:19.000000000 -0300 +++ lua-5.4.1/doc/contents.html 2020-09-30 06:45:11.000000000 -0300 @@ -95,6 +95,7 @@
  • 4.2 – C Closures
  • 4.3 – Registry @@ -664,10 +665,10 @@ diff -u -Nr lua-5.4.0/doc/manual.html lua-5.4.1/doc/manual.html --- lua-5.4.0/doc/manual.html 2020-06-18 13:10:16.000000000 -0300 +++ lua-5.4.1/doc/manual.html 2020-09-30 06:46:31.000000000 -0300 @@ -2973,7 +2973,8 @@

    Whenever Lua calls C, it ensures that the stack has space for -at least LUA_MINSTACK extra slots. +at least LUA_MINSTACK extra elements; +that is, you can safely push up to LUA_MINSTACK values into it. LUA_MINSTACK is defined as 20, so that usually you do not have to worry about stack space unless your code has loops pushing elements onto the stack. @@ -2984,7 +2985,7 @@ without a fixed number of results (see lua_call), Lua ensures that the stack has enough space for all results, but it does not ensure any extra space. -So, before pushing anything in the stack after such a call +So, before pushing anything on the stack after such a call you should use lua_checkstack. @@ -3044,6 +3045,48 @@ +

    4.1.3 – Pointers to strings

    + +

    +Several functions in the API return pointers (const char*) +to Lua strings in the stack. +(See lua_pushfstring, lua_pushlstring, +lua_pushstring, and lua_tolstring. +See also luaL_checklstring, luaL_checkstring, +and luaL_tolstring in the auxiliary library.) + + +

    +In general, +Lua's garbage collection can free or move internal memory +and then invalidate pointers to internal strings. +To allow a safe use of these pointers, +The API guarantees that any pointer to a string in a stack index +is valid while the value at that index is neither modified nor popped. +When the index is a pseudo-index (referring to an upvalue), +the pointer is valid while the corresponding call is active and +the corresponding upvalue is not modified. + + +

    +Some functions in the debug interface +also return pointers to strings, +namely lua_getlocal, lua_getupvalue, +lua_setlocal, and lua_setupvalue. +For these functions, the pointer is guaranteed to +be valid while the caller function is active and +the given closure (if one was given) is in the stack. + + +

    +Except for these guarantees, +the garbage collector is free to invalidate +any pointer to internal strings. + + + + +

    4.2 – C Closures

    @@ -3389,7 +3432,7 @@ an interrogation mark '?' means that we cannot know how many elements the function pops/pushes by looking only at its arguments. -(For instance, they may depend on what is on the stack.) +(For instance, they may depend on what is in the stack.) The third field, x, tells whether the function may raise errors: '-' means the function never raises any error; @@ -3678,7 +3721,7 @@
    int lua_checkstack (lua_State *L, int n);

    -Ensures that the stack has space for at least n extra slots, +Ensures that the stack has space for at least n extra elements, that is, that you can safely push up to n values into it. It returns false if it cannot fulfill the request, either because it would cause the stack @@ -3686,7 +3729,7 @@ (typically at least several thousand elements) or because it cannot allocate memory for the extra space. This function never shrinks the stack; -if the stack already has space for the extra slots, +if the stack already has space for the extra elements, it is left unchanged. @@ -4443,6 +4486,10 @@

    The function returns the address of the block of memory. +Lua ensures that this address is valid as long as +the corresponding userdata is alive (see §2.5). +Moreover, if the userdata is marked for finalization (see §2.5.3), +its address is valid at least until the call to its finalizer. @@ -4688,7 +4735,7 @@

    Pushes onto the stack a formatted string -and returns a pointer to this string. +and returns a pointer to this string (see §4.1.3). It is similar to the ISO C function sprintf, but has two important differences. First, @@ -4788,7 +4835,7 @@

    -Returns a pointer to the internal copy of the string. +Returns a pointer to the internal copy of the string (see §4.1.3). @@ -4829,7 +4876,7 @@

    -Returns a pointer to the internal copy of the string. +Returns a pointer to the internal copy of the string (see §4.1.3).

    @@ -5399,7 +5446,7 @@


    lua_toclose

    -[-0, +0, v] +[-0, +0, m]

    void lua_toclose (lua_State *L, int index);

    @@ -5423,11 +5470,19 @@

    -This function can raise an out-of-memory error. -In that case, the value in the given index is immediately closed, +In the case of an out-of-memory error, +the value in the given index is immediately closed, as if it was already marked. +

    +Note that, both in case of errors and of a regular return, +by the time the __close metamethod runs, +the C stack was already unwound, +so that any automatic C variable declared in the calling function +will be out of scope. + + @@ -5482,18 +5537,12 @@

    lua_tolstring returns a pointer -to a string inside the Lua state. +to a string inside the Lua state (see §4.1.3). This string always has a zero ('\0') after its last character (as in C), but can contain other zeros in its body. -

    -Because Lua has garbage collection, -there is no guarantee that the pointer returned by lua_tolstring -will be valid after the corresponding Lua value is removed from the stack. - - @@ -5944,7 +5993,7 @@

  • ftransfer: -the index on the stack of the first value being "transferred", +the index in the stack of the first value being "transferred", that is, parameters in a call or return values in a return. (The other values are in consecutive indices.) Using this index, you can access and modify these values @@ -6141,7 +6190,7 @@ of the function executing at a given level. Level 0 is the current running function, whereas level n+1 is the function that has called level n -(except for tail calls, which do not count on the stack). +(except for tail calls, which do not count in the stack). When called with a level greater than the stack depth, lua_getstack returns 0; otherwise it returns 1. @@ -6259,8 +6308,7 @@