diff --git a/liolib.c b/liolib.c index fa6a0939..1484676d 100644 --- a/liolib.c +++ b/liolib.c @@ -504,17 +504,17 @@ static int test_eof (lua_State *L, FILE *f) { static int read_line (lua_State *L, FILE *f, int chop) { luaL_Buffer b; - int c = '\0'; + int c; luaL_buffinit(L, &b); - while (c != EOF && c != '\n') { /* repeat until end of line */ - char *buff = luaL_prepbuffer(&b); /* preallocate buffer */ + do { /* may need to read several chunks to get whole line */ + char *buff = luaL_prepbuffer(&b); /* preallocate buffer space */ int i = 0; l_lockfile(f); /* no memory errors can happen inside the lock */ while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') - buff[i++] = c; + buff[i++] = c; /* read up to end of line or buffer limit */ l_unlockfile(f); luaL_addsize(&b, i); - } + } while (c != EOF && c != '\n'); /* repeat until end of line */ if (!chop && c == '\n') /* want a newline and have one? */ luaL_addchar(&b, c); /* add ending newline to result */ luaL_pushresult(&b); /* close buffer */ diff --git a/lobject.c b/lobject.c index ce14059f..979a6889 100644 --- a/lobject.c +++ b/lobject.c @@ -419,9 +419,9 @@ typedef struct BuffFS { static void pushstr (BuffFS *buff, const char *str, size_t l) { lua_State *L = buff->L; setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); - L->top++; + L->top++; /* may use one extra slot */ buff->pushed++; - if (buff->pushed > 1 && L->top + 2 > L->stack_last) { + if (buff->pushed > 1 && L->top + 1 >= L->stack_last) { luaV_concat(L, buff->pushed); /* join all partial results into one */ buff->pushed = 1; } diff --git a/lparser.c b/lparser.c index 7c23710a..045efd93 100644 --- a/lparser.c +++ b/lparser.c @@ -264,7 +264,7 @@ static void check_readonly (LexState *ls, expdesc *e) { Vardesc *vardesc = getvardesc(ls->fs, e); if (vardesc && vardesc->ro) { /* is variable local and const? */ const char *msg = luaO_pushfstring(ls->L, - "assignment to const variable '%s'", getstr(vardesc->name)); + "attempt to assign to const variable '%s'", getstr(vardesc->name)); luaK_semerror(ls, msg); /* error */ } } diff --git a/lstate.h b/lstate.h index e35f8962..3bd52973 100644 --- a/lstate.h +++ b/lstate.h @@ -26,6 +26,22 @@ ** 'fixedgc': all objects that are not to be collected (currently ** only small strings, such as reserved words). ** +** For the generational collector, some of these lists have marks for +** generations. Each mark points to the first element in the list for +** that particular generation; that generation goes until the next mark. +** +** 'allgc' -> 'survival': new objects; +** 'survival' -> 'old': objects that survived one collection; +** 'old' -> 'reallyold': objects that became old in last collection; +** 'reallyold' -> NULL: objects old for more than one cycle. +** +** 'finobj' -> 'finobjsur': new objects marked for finalization; +** 'finobjsur' -> 'finobjold': survived """"; +** 'finobjold' -> 'finobjrold': just old """"; +** 'finobjrold' -> NULL: really old """". +*/ + +/* ** Moreover, there is another set of lists that control gray objects. ** These lists are linked by fields 'gclist'. (All objects that ** can become gray have such a field. The field is not the same diff --git a/luaconf.h b/luaconf.h index 66dca6bf..39840e39 100644 --- a/luaconf.h +++ b/luaconf.h @@ -344,8 +344,8 @@ /* @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated ** functions in the mathematical library. -** (These functions were already officially removed in 5.3, but -** nevertheless they are available by default there.) +** (These functions were already officially removed in 5.3; +** nevertheless they are still available here.) */ #define LUA_COMPAT_MATHLIB @@ -353,23 +353,25 @@ @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, ** luaL_checkint, luaL_checklong, etc.) +** (These macros were also officially removed in 5.3, but they are still +** available here.) */ #define LUA_COMPAT_APIINTCASTS + /* @@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod ** using '__lt'. */ #define LUA_COMPAT_LT_LE -#endif /* } */ - - /* @@ The following macros supply trivial compatibility for some ** changes in the API. The macros themselves document how to ** change your code to avoid using them. +** (Once more, these macros were officially removed in 5.3, but they are +** still available here.) */ #define lua_strlen(L,i) lua_rawlen(L, (i)) @@ -378,6 +380,8 @@ #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) +#endif /* } */ + /* }================================================================== */ diff --git a/manual/manual.of b/manual/manual.of index 6cac8c6c..ff69cd2c 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -8774,10 +8774,18 @@ is a more portable solution. Here we list the incompatibilities that you may find when moving a program from @N{Lua 5.3} to @N{Lua 5.4}. + You can avoid some incompatibilities by compiling Lua with appropriate options (see file @id{luaconf.h}). However, all these compatibility options will be removed in the future. +More often than not, +compatibility issues arise when these compatibility options +are removed. +So, whenever you have the chance, +you should try to test your code with a version of Lua compiled +with all compatibility options turned off. +That will ease transitions to newer versions of Lua. Lua versions can always change the C API in ways that do not imply source-code changes in a program, @@ -8825,11 +8833,6 @@ over integers changed in some details. In particular, the control variable never wraps around. } -@item{ -When a coroutine finishes with an error, -its stack is unwound (to run any pending closing methods). -} - @item{ A label for a @Rw{goto} cannot be declared where a label with the same name is visible, even if this other label is declared in an enclosing diff --git a/testes/constructs.lua b/testes/constructs.lua index b91e0979..fe4db2cb 100644 --- a/testes/constructs.lua +++ b/testes/constructs.lua @@ -215,7 +215,7 @@ do -- testing constants checkload(prog, "unknown attribute 'XXX'") checkload([[local xxx = 20; xxx = 10]], - ":1: assignment to const variable 'xxx'") + ":1: attempt to assign to const variable 'xxx'") checkload([[ local xx; @@ -225,12 +225,12 @@ do -- testing constants local abc = xx + yyy + xxx; return function () return function () xxx = yyy end end end - ]], ":6: assignment to const variable 'xxx'") + ]], ":6: attempt to assign to const variable 'xxx'") checkload([[ local x = nil x = io.open() - ]], ":2: assignment to const variable 'x'") + ]], ":2: attempt to assign to const variable 'x'") end f = [[ diff --git a/testes/locals.lua b/testes/locals.lua index c176f506..e59ab95a 100644 --- a/testes/locals.lua +++ b/testes/locals.lua @@ -452,7 +452,6 @@ do end) assert(co() == 100) local st, msg = pcall(co) -print(msg) -- should get last error raised assert(not st and string.find(msg, "%w+%.%w+:%d+: XXX")) end diff --git a/testes/strings.lua b/testes/strings.lua index 3e32f2c4..1b2b570e 100644 --- a/testes/strings.lua +++ b/testes/strings.lua @@ -3,7 +3,8 @@ print('testing strings and string library') -local maxi, mini = math.maxinteger, math.mininteger +local maxi = math.maxinteger +local mini = math.mininteger local function checkerror (msg, f, ...)