Details

Comments + manual + identation + asserts about stack limits that were
not allowing the use of the full stack
diff --git a/ldo.c b/ldo.c
index a48e35f..8e4faf0 100644
--- a/ldo.c
+++ b/ldo.c
@@ -213,7 +213,7 @@
 
 
 /*
-** Try to grow the stack by at least 'n' elements. when 'raiseerror'
+** Try to grow the stack by at least 'n' elements. When 'raiseerror'
 ** is true, raises any error; otherwise, return 0 in case of errors.
 */
 int luaD_growstack (lua_State *L, int n, int raiseerror) {
@@ -247,6 +247,10 @@
 }
 
 
+/*
+** Compute how much of the stack is being used, by computing the
+** maximum top of all call frames in the stack and the current top.
+*/
 static int stackinuse (lua_State *L) {
   CallInfo *ci;
   int res;
@@ -254,7 +258,7 @@
   for (ci = L->ci; ci != NULL; ci = ci->previous) {
     if (lim < ci->top) lim = ci->top;
   }
-  lua_assert(lim <= L->stack_last);
+  lua_assert(lim <= L->stack_last + EXTRA_STACK);
   res = cast_int(lim - L->stack) + 1;  /* part of stack in use */
   if (res < LUA_MINSTACK)
     res = LUA_MINSTACK;  /* ensure a minimum size */
diff --git a/loadlib.c b/loadlib.c
index 6f9fa37..d792dff 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -708,8 +708,13 @@
 
 
 static void createsearcherstable (lua_State *L) {
-  static const lua_CFunction searchers[] =
-    {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL};
+  static const lua_CFunction searchers[] = {
+    searcher_preload,
+    searcher_Lua,
+    searcher_C,
+    searcher_Croot,
+    NULL
+  };
   int i;
   /* create 'searchers' table */
   lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0);
diff --git a/lvm.c b/lvm.c
index f3a5662..e8c2e96 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1177,7 +1177,7 @@
       printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
     #endif
     lua_assert(base == ci->func + 1);
-    lua_assert(base <= L->top && L->top < L->stack_last);
+    lua_assert(base <= L->top && L->top <= L->stack_last);
     /* invalidate top for instructions not expecting it */
     lua_assert(isIT(i) || (cast_void(L->top = base), 1));
     vmdispatch (GET_OPCODE(i)) {
diff --git a/manual/manual.of b/manual/manual.of
index 15f207f..bd648c6 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -3981,6 +3981,7 @@
 
 Similar to @Lid{lua_gettable}, but does a raw access
 (i.e., without metamethods).
+The value at @id{index} must be a table.
 
 }
 
@@ -4027,6 +4028,7 @@
 
 Similar to @Lid{lua_settable}, but does a raw assignment
 (i.e., without metamethods).
+The value at @id{index} must be a table.
 
 }
 
@@ -7280,7 +7282,7 @@
 
 @LibEntry{string.packsize (fmt)|
 
-Returns the size of a string resulting from @Lid{string.pack}
+Returns the length of a string resulting from @Lid{string.pack}
 with the given format.
 The format string cannot have the variable-length options
 @Char{s} or @Char{z} @see{pack}.