Forráskód Böngészése

several small details

Roberto Ierusalimschy 20 éve
szülő
commit
67578ec51f
20 módosított fájl, 152 hozzáadás és 137 törlés
  1. 3 3
      lapi.c
  2. 5 5
      lauxlib.c
  3. 5 5
      lbaselib.c
  4. 4 4
      ldblib.c
  5. 2 2
      ldebug.c
  6. 4 3
      ldump.c
  7. 2 2
      llex.c
  8. 12 12
      loadlib.c
  9. 3 3
      loslib.c
  10. 7 7
      lparser.c
  11. 6 5
      lstrlib.c
  12. 2 2
      ltable.c
  13. 2 2
      ltablib.c
  14. 8 7
      lua.c
  15. 21 22
      lua.h
  16. 55 42
      luaconf.h
  17. 2 2
      lundump.h
  18. 4 4
      lvm.c
  19. 2 2
      lzio.c
  20. 3 3
      lzio.h

+ 3 - 3
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 2.39 2005/05/05 15:34:03 roberto Exp roberto $
+** $Id: lapi.c,v 2.40 2005/05/16 19:21:11 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -846,7 +846,7 @@ LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
 }
 
 
-LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
+LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
                       const char *chunkname) {
   ZIO z;
   int status;
@@ -859,7 +859,7 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
 }
 
 
-LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) {
+LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
   int status;
   TValue *o;
   lua_lock(L);

+ 5 - 5
lauxlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.131 2005/05/16 19:21:11 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.132 2005/05/16 21:19:00 roberto Exp roberto $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -47,12 +47,12 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
   if (strcmp(ar.namewhat, "method") == 0) {
     narg--;  /* do not count `self' */
     if (narg == 0)  /* error is in the self argument itself? */
-      return luaL_error(L, "calling " LUA_SM " on bad self (%s)",
+      return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
                            ar.name, extramsg);
   }
   if (ar.name == NULL)
     ar.name = "?";
-  return luaL_error(L, "bad argument #%d to " LUA_SM " (%s)",
+  return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
                         narg, ar.name, extramsg);
 }
 
@@ -245,7 +245,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname,
       luaL_setfield(L, LUA_GLOBALSINDEX, libname);
     }
     else if (!lua_istable(L, -1))
-      luaL_error(L, "name conflict for library " LUA_SM, libname);
+      luaL_error(L, "name conflict for library " LUA_QS, libname);
     lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
     lua_pushvalue(L, -2);
     lua_setfield(L, -2, libname);  /* _LOADED[modname] = new table */
@@ -366,7 +366,7 @@ LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name,
   for (;;) {
     const char *fname;
     if ((p = pushnexttemplate(L, p)) == NULL) {
-      lua_pushfstring(L, "no readable " LUA_SM " in path " LUA_SM "",
+      lua_pushfstring(L, "no readable " LUA_QS " in path " LUA_QS "",
                          name, path);
       return NULL;
     }

+ 5 - 5
lbaselib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.174 2005/05/16 19:21:11 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.175 2005/05/16 21:19:00 roberto Exp roberto $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -39,8 +39,8 @@ static int luaB_print (lua_State *L) {
     lua_call(L, 1, 1);
     s = lua_tostring(L, -1);  /* get result */
     if (s == NULL)
-      return luaL_error(L, LUA_SM " must return a string to " LUA_SM,
-                           "tostring", "print");
+      return luaL_error(L, LUA_QL("tostring") " must return a string to "
+                           LUA_QL("print"));
     if (i>1) fputs("\t", stdout);
     fputs(s, stdout);
     lua_pop(L, 1);  /* pop result */
@@ -149,8 +149,8 @@ static int luaB_setfenv (lua_State *L) {
     return 0;
   }
   else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
-    luaL_error(L, LUA_SM " cannot change environment of given object",
-                  "setfenv");
+    luaL_error(L,
+          LUA_QL("setfenv") " cannot change environment of given object");
   return 1;
 }
 

+ 4 - 4
ldblib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.96 2005/05/16 18:45:15 roberto Exp roberto $
+** $Id: ldblib.c,v 1.97 2005/05/16 21:19:00 roberto Exp roberto $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -48,8 +48,8 @@ static int db_setfenv (lua_State *L) {
   luaL_checktype(L, 2, LUA_TTABLE);
   lua_settop(L, 2);
   if (lua_setfenv(L, 1) == 0)
-    luaL_error(L, LUA_SM " cannot change environment of given object",
-                  "setfenv");
+    luaL_error(L, LUA_QL("setfenv")
+                  " cannot change environment of given object");
   return 1;
 }
 
@@ -348,7 +348,7 @@ static int db_errorfb (lua_State *L) {
     if (ar.currentline > 0)
       lua_pushfstring(L, "%d:", ar.currentline);
     if (*ar.namewhat != '\0')  /* is there a name? */
-        lua_pushfstring(L, " in function " LUA_SM, ar.name);
+        lua_pushfstring(L, " in function " LUA_QS, ar.name);
     else {
       if (*ar.what == 'm')  /* main? */
         lua_pushfstring(L, " in main chunk");

+ 2 - 2
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 2.18 2005/05/16 18:45:15 roberto Exp roberto $
+** $Id: ldebug.c,v 2.19 2005/05/16 21:19:00 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -548,7 +548,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
   const char *kind = (isinstack(L->ci, o)) ?
                          getobjname(L, L->ci, o - L->base, &name) : NULL;
   if (kind)
-    luaG_runerror(L, "attempt to %s %s " LUA_SM " (a %s value)",
+    luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
                 op, kind, name, t);
   else
     luaG_runerror(L, "attempt to %s a %s value", op, t);

+ 4 - 3
ldump.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldump.c,v 2.4 2004/10/04 19:01:12 roberto Exp roberto $
+** $Id: ldump.c,v 2.5 2005/05/05 20:47:02 roberto Exp roberto $
 ** save pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -21,7 +21,7 @@
 
 typedef struct {
  lua_State* L;
- lua_Chunkwriter writer;
+ lua_Writer writer;
  void* data;
  int strip;
  int status;
@@ -164,7 +164,8 @@ static void DumpHeader(DumpState* D)
 /*
 ** dump Lua function as precompiled chunk
 */
-int luaU_dump (lua_State* L, const Proto* f, lua_Chunkwriter w, void* data, int strip)
+int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data,
+                             int strip)
 {
  DumpState D;
  D.L=L;

+ 2 - 2
llex.c

@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 2.10 2005/04/27 18:37:51 roberto Exp roberto $
+** $Id: llex.c,v 2.11 2005/05/16 21:19:00 roberto Exp roberto $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -102,7 +102,7 @@ void luaX_lexerror (LexState *ls, const char *msg, int token) {
   luaO_chunkid(buff, getstr(ls->source), MAXSRC);
   msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
   if (token)
-    luaO_pushfstring(ls->L, "%s near " LUA_SM, msg, txtToken(ls, token));
+    luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
   luaD_throw(ls->L, LUA_ERRSYNTAX);
 }
 

+ 12 - 12
loadlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: loadlib.c,v 1.26 2005/04/13 17:24:20 roberto Exp roberto $
+** $Id: loadlib.c,v 1.27 2005/05/16 21:19:00 roberto Exp roberto $
 ** Dynamic library loader for Lua
 ** See Copyright Notice in lua.h
 **
@@ -191,7 +191,7 @@ static void *ll_load (lua_State *L, const char *path) {
 static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
   NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym);
   if (nss == NULL) {
-    lua_pushfstring(L, "symbol " LUA_SM " not found", sym);
+    lua_pushfstring(L, "symbol " LUA_QS " not found", sym);
     return NULL;
   }
   return (lua_CFunction)NSAddressOfSymbol(nss);
@@ -213,9 +213,9 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
 
 
 #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux)
-#define DLMSG "'loadlib' not enabled; check your Lua installation"
+#define DLMSG LUA_QL("loadlib") " not enabled; check your Lua installation"
 #else
-#define DLMSG		"'loadlib' not supported"
+#define DLMSG		LUA_QL("loadlib") " not supported"
 #endif
 
 static void ll_unloadlib (void *lib) {
@@ -327,11 +327,11 @@ static int loader_Lua (lua_State *L) {
     path = lua_tostring(L, -1);
   }
   if (path == NULL)
-    luaL_error(L, LUA_SM " must be a string", "package.path");
+    luaL_error(L, LUA_QL("package.path") " must be a string");
   fname = luaL_searchpath(L, fname, path);
   if (fname == NULL) return 0;  /* library not found in this path */
   if (luaL_loadfile(L, fname) != 0)
-    luaL_error(L, "error loading package " LUA_SM " (%s)",
+    luaL_error(L, "error loading package " LUA_QS " (%s)",
                   name, lua_tostring(L, -1));
   return 1;  /* library loaded successfully */
 }
@@ -345,13 +345,13 @@ static int loader_C (lua_State *L) {
   lua_getfield(L, LUA_ENVIRONINDEX, "cpath");
   path = lua_tostring(L, -1);
   if (path == NULL)
-    luaL_error(L, LUA_SM " must be a string", "package.cpath");
+    luaL_error(L, LUA_QL("package.cpath") " must be a string");
   fname = luaL_searchpath(L, fname, path);
   if (fname == NULL) return 0;  /* library not found in this path */
   funcname = luaL_gsub(L, name, ".", LUA_OFSEP);
   funcname = lua_pushfstring(L, "%s%s", POF, funcname);
   if (ll_loadfunc(L, fname, funcname) != 1)
-    luaL_error(L, "error loading package " LUA_SM " (%s)",
+    luaL_error(L, "error loading package " LUA_QS " (%s)",
                   name, lua_tostring(L, -2));
   return 1;  /* library loaded successfully */
 }
@@ -360,7 +360,7 @@ static int loader_C (lua_State *L) {
 static int loader_preload (lua_State *L) {
   lua_getfield(L, LUA_ENVIRONINDEX, "preload");
   if (!lua_istable(L, -1))
-    luaL_error(L, LUA_SM " must be a table", "package.preload");
+    luaL_error(L, LUA_QL("package.preload") " must be a table");
   lua_getfield(L, -1, luaL_checkstring(L, 1));
   return 1;
 }
@@ -380,11 +380,11 @@ static int ll_require (lua_State *L) {
   /* iterate over available loaders */
   lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
   if (!lua_istable(L, -1))
-    luaL_error(L, LUA_SM " must be a table", "package.loaders");
+    luaL_error(L, LUA_QL("package.loaders") " must be a table");
   for (i=1;; i++) {
     lua_rawgeti(L, -1, i);  /* get a loader */
     if (lua_isnil(L, -1))
-      return luaL_error(L, "package " LUA_SM " not found", name);
+      return luaL_error(L, "package " LUA_QS " not found", name);
     lua_pushstring(L, name);
     lua_call(L, 1, 1);  /* call it */
     if (lua_isnil(L, -1)) lua_pop(L, 1);
@@ -423,7 +423,7 @@ static int ll_module (lua_State *L) {
     luaL_setfield(L, LUA_GLOBALSINDEX, modname);
   }
   else if (!lua_istable(L, -1))
-    return luaL_error(L, "name conflict for module " LUA_SM, modname);
+    return luaL_error(L, "name conflict for module " LUA_QS, modname);
   /* check whether table already has a _NAME field */
   lua_getfield(L, -1, "_NAME");
   if (!lua_isnil(L, -1))  /* is table an initialized module? */

+ 3 - 3
loslib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: loslib.c,v 1.7 2005/03/18 18:02:04 roberto Exp roberto $
+** $Id: loslib.c,v 1.8 2005/05/16 21:19:00 roberto Exp roberto $
 ** Standard Operating System library
 ** See Copyright Notice in lua.h
 */
@@ -113,7 +113,7 @@ static int getfield (lua_State *L, const char *key, int d) {
     res = (int)lua_tointeger(L, -1);
   else {
     if (d < 0)
-      return luaL_error(L, "field " LUA_SM " missing in date table", key);
+      return luaL_error(L, "field " LUA_QS " missing in date table", key);
     res = d;
   }
   lua_pop(L, 1);
@@ -151,7 +151,7 @@ static int io_date (lua_State *L) {
     if (strftime(b, sizeof(b), s, stm))
       lua_pushstring(L, b);
     else
-      return luaL_error(L, LUA_SM " format too long", "date");
+      return luaL_error(L, LUA_QL("date") " format too long");
   }
   return 1;
 }

+ 7 - 7
lparser.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 2.25 2005/05/05 20:47:02 roberto Exp roberto $
+** $Id: lparser.c,v 2.26 2005/05/16 21:19:00 roberto Exp roberto $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -82,7 +82,7 @@ static void anchor_token (LexState *ls) {
 
 static void error_expected (LexState *ls, int token) {
   luaX_syntaxerror(ls,
-      luaO_pushfstring(ls->L, LUA_SM " expected", luaX_token2str(ls, token)));
+      luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
 }
 
 
@@ -125,7 +125,7 @@ static void check_match (LexState *ls, int what, int who, int where) {
       error_expected(ls, what);
     else {
       luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
-             LUA_SM " expected (to close " LUA_SM " at line %d)",
+             LUA_QS " expected (to close " LUA_QS " at line %d)",
               luaX_token2str(ls, what), luaX_token2str(ls, who), where));
     }
   }
@@ -577,7 +577,7 @@ static void parlist (LexState *ls) {
           f->is_vararg = 1;
           break;
         }
-        default: luaX_syntaxerror(ls, "<name> or '...' expected");
+        default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
       }
     } while (!f->is_vararg && testnext(ls, ','));
   }
@@ -765,7 +765,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
     case TK_DOTS: {  /* vararg */
       FuncState *fs = ls->fs;
       check_condition(ls, fs->f->is_vararg,
-                      "cannot use '...' outside a vararg function");
+                      "cannot use " LUA_QL("...") " outside a vararg function");
       fs->f->is_vararg = NEWSTYLEVARARG;
       init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
       break;
@@ -1017,7 +1017,7 @@ static void whilestat (LexState *ls, int line) {
   fs->jpc = NO_JUMP;
   sizeexp = fs->pc - expinit;  /* size of expression code */
   if (sizeexp > LUAI_MAXEXPWHILE) 
-    luaX_syntaxerror(ls, "'while' condition too complex");
+    luaX_syntaxerror(ls, LUA_QL("while") " condition too complex");
   for (i = 0; i < sizeexp; i++)  /* save `exp' code */
     codeexp[i] = fs->f->code[expinit + i];
   fs->pc = expinit;  /* remove `exp' code */
@@ -1141,7 +1141,7 @@ static void forstat (LexState *ls, int line) {
   switch (ls->t.token) {
     case '=': fornum(ls, varname, line); break;
     case ',': case TK_IN: forlist(ls, varname); break;
-    default: luaX_syntaxerror(ls, "'=' or 'in' expected");
+    default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
   }
   check_match(ls, TK_END, TK_FOR, line);
   leaveblock(fs);  /* loop scope (`break' jumps to this point) */

+ 6 - 5
lstrlib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.113 2005/05/16 19:21:11 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.114 2005/05/16 21:19:00 roberto Exp roberto $
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -200,14 +200,14 @@ static const char *classend (MatchState *ms, const char *p) {
   switch (*p++) {
     case L_ESC: {
       if (*p == '\0')
-        luaL_error(ms->L, "malformed pattern (ends with '%%')");
+        luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
       return p+1;
     }
     case '[': {
       if (*p == '^') p++;
       do {  /* look for a `]' */
         if (*p == '\0')
-          luaL_error(ms->L, "malformed pattern (missing ']')");
+          luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
         if (*(p++) == L_ESC && *p != '\0')
           p++;  /* skip escapes (e.g. `%]') */
       } while (*p != ']');
@@ -382,7 +382,8 @@ static const char *match (MatchState *ms, const char *s, const char *p) {
           const char *ep; char previous;
           p += 2;
           if (*p != '[')
-            luaL_error(ms->L, "missing '[' after '%%f' in pattern");
+            luaL_error(ms->L, "missing " LUA_QL("[") " after "
+                               LUA_QL("%%f") " in pattern");
           ep = classend(ms, p);  /* points to what is next */
           previous = (s == ms->src_init) ? '\0' : *(s-1);
           if (matchbracketclass(uchar(previous), p, ep-1) ||
@@ -741,7 +742,7 @@ static int str_format (lua_State *L) {
           }
         }
         default: {  /* also treat cases `pnLlh' */
-          return luaL_error(L, "invalid option to " LUA_SM, "format");
+          return luaL_error(L, "invalid option to " LUA_QL("format"));
         }
       }
       luaL_addlstring(&b, buff, strlen(buff));

+ 2 - 2
ltable.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.21 2005/05/03 19:30:17 roberto Exp roberto $
+** $Id: ltable.c,v 2.22 2005/05/16 21:19:00 roberto Exp roberto $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -151,7 +151,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
       }
       else n = gnext(n);
     } while (n);
-    luaG_runerror(L, "invalid key to " LUA_SM, "next");  /* key not found */
+    luaG_runerror(L, "invalid key to " LUA_QL("next"));  /* key not found */
     return 0;  /* to avoid warnings */
   }
 }

+ 2 - 2
ltablib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltablib.c,v 1.29 2005/03/28 17:17:53 roberto Exp roberto $
+** $Id: ltablib.c,v 1.30 2005/05/16 21:19:00 roberto Exp roberto $
 ** Library for Table Manipulation
 ** See Copyright Notice in lua.h
 */
@@ -65,7 +65,7 @@ static int setn (lua_State *L) {
 #ifndef luaL_setn
   luaL_setn(L, 1, luaL_checkint(L, 2));
 #else
-  luaL_error(L, LUA_SM " is obsolete", "setn");
+  luaL_error(L, LUA_QL("setn") " is obsolete");
 #endif
   lua_pushvalue(L, 1);
   return 1;

+ 8 - 7
lua.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.c,v 1.142 2005/04/13 17:24:20 roberto Exp roberto $
+** $Id: lua.c,v 1.143 2005/05/16 21:19:00 roberto Exp roberto $
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 */
@@ -44,9 +44,9 @@ static void print_usage (void) {
   "usage: %s [options] [script [args]].\n"
   "Available options are:\n"
   "  -        execute stdin as a file\n"
-  "  -e stat  execute string 'stat'\n"
-  "  -i       enter interactive mode after executing 'script'\n"
-  "  -l name  require library 'name'\n"
+  "  -e stat  execute string " LUA_QL("stat") "\n"
+  "  -i       enter interactive mode after executing " LUA_QL("script") "\n"
+  "  -l name  require library " LUA_QL("name") "\n"
   "  -v       show version information\n"
   "  -w       trap access to undefined globals\n"
   "  --       stop handling options\n" ,
@@ -209,8 +209,9 @@ static void dotty (lua_State *L) {
       lua_getglobal(L, "print");
       lua_insert(L, 1);
       if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
-        l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)",
-                                               lua_tostring(L, -1)));
+        l_message(progname, lua_pushfstring(L,
+                               "error calling " LUA_QL("print") " (%s)",
+                               lua_tostring(L, -1)));
     }
   }
   lua_settop(L, 0);  /* clear stack */
@@ -222,7 +223,7 @@ static void dotty (lua_State *L) {
 static int checkvar (lua_State *L) {
   const char *name = lua_tostring(L, 2);
   if (name)
-    luaL_error(L, "attempt to access undefined variable " LUA_SM, name);
+    luaL_error(L, "attempt to access undefined variable " LUA_QS, name);
   return 0;
 }
 

+ 21 - 22
lua.h

@@ -1,8 +1,8 @@
 /*
-** $Id: lua.h,v 1.206 2005/05/05 20:47:02 roberto Exp roberto $
+** $Id: lua.h,v 1.207 2005/05/16 19:21:11 roberto Exp roberto $
 ** Lua - An Extensible Extension Language
 ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
-** http://www.lua.org	mailto:[email protected]
+** http://www.lua.org
 ** See Copyright Notice at the end of this file
 */
 
@@ -55,10 +55,9 @@ typedef int (*lua_CFunction) (lua_State *L);
 /*
 ** functions that read/write blocks when loading/dumping Lua chunks
 */
-typedef const char * (*lua_Chunkreader) (lua_State *L, void *ud, size_t *sz);
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
 
-typedef int (*lua_Chunkwriter) (lua_State *L, const void* p,
-                                size_t sz, void* ud);
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
 
 
 /*
@@ -70,17 +69,17 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
 /*
 ** basic types
 */
-#define LUA_TNONE	(-1)
+#define LUA_TNONE		(-1)
 
-#define LUA_TNIL	0
-#define LUA_TBOOLEAN	1
+#define LUA_TNIL		0
+#define LUA_TBOOLEAN		1
 #define LUA_TLIGHTUSERDATA	2
-#define LUA_TNUMBER	3
-#define LUA_TSTRING	4
-#define LUA_TTABLE	5
-#define LUA_TFUNCTION	6
-#define LUA_TUSERDATA	7
-#define LUA_TTHREAD	8
+#define LUA_TNUMBER		3
+#define LUA_TSTRING		4
+#define LUA_TTABLE		5
+#define LUA_TFUNCTION		6
+#define LUA_TUSERDATA		7
+#define LUA_TTHREAD		8
 
 
 
@@ -147,7 +146,6 @@ LUA_API int            (lua_lessthan) (lua_State *L, int idx1, int idx2);
 LUA_API lua_Number      (lua_tonumber) (lua_State *L, int idx);
 LUA_API lua_Integer     (lua_tointeger) (lua_State *L, int idx);
 LUA_API int             (lua_toboolean) (lua_State *L, int idx);
-LUA_API const char     *(lua_tostring) (lua_State *L, int idx);
 LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);
 LUA_API size_t          (lua_objsize) (lua_State *L, int idx);
 LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);
@@ -202,11 +200,11 @@ LUA_API int   (lua_setfenv) (lua_State *L, int idx);
 */
 LUA_API void  (lua_call) (lua_State *L, int nargs, int nresults);
 LUA_API int   (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
-LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
-LUA_API int   (lua_load) (lua_State *L, lua_Chunkreader reader, void *dt,
+LUA_API int   (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
                                         const char *chunkname);
 
-LUA_API int (lua_dump) (lua_State *L, lua_Chunkwriter writer, void *data);
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
 
 
 /*
@@ -290,7 +288,8 @@ LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
 
 #define lua_getgccount(L)	lua_gc(L, LUA_GCCOUNT, 0)
 
-
+#define lua_Chunkreader		lua_Reader
+#define lua_Chunkwriter		lua_Writer
 
 
 
@@ -321,6 +320,8 @@ LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
 
 typedef struct lua_Debug lua_Debug;  /* activation record */
 
+
+/* Functions to be called by the debuger in specific events */
 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
 
 
@@ -337,8 +338,6 @@ LUA_API int lua_gethookmask (lua_State *L);
 LUA_API int lua_gethookcount (lua_State *L);
 
 
-#define LUA_IDSIZE	60
-
 struct lua_Debug {
   int event;
   const char *name;	/* (n) */
@@ -358,7 +357,7 @@ struct lua_Debug {
 
 
 /******************************************************************************
-* Copyright (C) 1994-2004 Tecgraf, PUC-Rio.  All rights reserved.
+* Copyright (C) 1994-2005 Tecgraf, PUC-Rio.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the

+ 55 - 42
luaconf.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.47 2005/05/03 19:30:17 roberto Exp roberto $
+** $Id: luaconf.h,v 1.48 2005/05/16 21:19:00 roberto Exp roberto $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -13,14 +13,12 @@
 
 
 /*
-** {==================================================================
-** Index (search for keyword to find corresponding entry)
+** ==================================================================
+** Search for "@@" to find all configurable definitions.
 ** ===================================================================
 */
 
 
-/* }================================================================== */
-
 
 
 /*
@@ -67,17 +65,17 @@
 /*
 @@ LUA_PATHSEP is the character that separates templates in a path.
 ** CHANGE it if for some reason your system cannot use a
-** semicolon. (E.g., a semicolon may be a too common character in
+** semicolon. (E.g., if a semicolon is a common character in
 ** file/directory names.) Probably you do not need to change this.
 */
 #define LUA_PATHSEP	';'
 
 
 /*
-@@ LUA_PATH_MARK is ths string that marks the substitution points in a
+@@ LUA_PATH_MARK is the string that marks the substitution points in a
 @* template.
-** CHANGE it if for some reason your system cannot use an interogation
-** mark.  (E.g., an interogation mark may be a too common character in
+** CHANGE it if for some reason your system cannot use an interrogation
+** mark.  (E.g., if an interogation mark is a common character in
 ** file/directory names.) Probably you do not need to change this.
 */
 #define LUA_PATH_MARK	"?"
@@ -113,16 +111,16 @@
 
 #endif
 
-/* more often then not the libs go together with the core */
+/* more often than not the libs go together with the core */
 #define LUALIB_API	LUA_API
 
 
 /*
 @@ LUAI_FUNC is a mark for all extern functions that are not to be
 @* exported to outside modules.
-** CHANGE it if you need to mark them in some special way. Gcc mark
-** them as "hidden" to optimize their call when Lua is compiled as a
-** shared library.
+** CHANGE it if you need to mark them in some special way. Gcc (versions
+** 3.2 and later) mark them as "hidden" to optimize their call when Lua
+** is compiled as a shared library.
 */
 #if defined(luaall_c)
 #define LUAI_FUNC	static
@@ -141,10 +139,20 @@
 
 
 /*
-@@ LUA_SM describes how variable strings appear in error messages.
+@@ LUA_QL describes how error messages quote program elements.
 ** CHANGE it if you want a different appearance.
 */
-#define LUA_SM		"'%s'"
+#define LUA_QL(x)	"'" x "'"
+#define LUA_QS		LUA_QL("%s")
+
+
+/*
+@@ LUA_IDSIZE gives the maximum size for the description of the source
+@* of a function in debug information.
+** CHANGE it if you a different size.
+*/
+#define LUA_IDSIZE	60
+
 
 /*
 ** {==================================================================
@@ -155,8 +163,8 @@
 #if defined(lua_c) || defined(luaall_c)
 
 /*
-@@ lua_stdin_is_tty is a function to detect whether the standard input is
-@* a 'tty' (that is, is interactive).
+@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
+@* is, whether we're running lua interactively).
 ** CHANGE it if you have a better definition for non-POSIX/non-Windows
 ** systems.
 */
@@ -191,7 +199,8 @@
 
 
 /*
-@@ LUA_MAXINPUT is the maximum length for an input line
+@@ LUA_MAXINPUT is the maximum length for an input line in the
+@* stand-alone interpreter.
 ** CHANGE it if you need longer lines.
 */
 #define LUA_MAXINPUT	512
@@ -200,10 +209,10 @@
 /*
 @@ lua_readline defines how to show a prompt and then read a line from
 @* the standard input.
-@@ lua_saveline defines how to "save" a read line.
+@@ lua_saveline defines how to "save" a read line in a "history".
 @@ lua_freeline defines how to free a line read by lua_readline.
-** CHANGE them if you want to improve this functionality (e.g., using GNU
-** readline and history facilities).
+** CHANGE them if you want to improve this functionality (e.g., by using
+** GNU readline and history facilities).
 */
 #if !defined(__STRICT_ANSI__) && defined(LUA_USE_READLINE)
 #include <stdio.h>
@@ -317,14 +326,14 @@
 /*
 @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
 @@ LUAI_INT32 is an signed integer with at least 32 bits.
-@@ LUAI_UMEM is an an unsigned integer big enough to count the total
+@@ LUAI_UMEM is an unsigned integer big enough to count the total
 @* memory used by Lua.
-@@ LUAI_MEM is an a signed integer big enough to count the total memory
+@@ LUAI_MEM is a signed integer big enough to count the total memory
 @* used by Lua.
 ** CHANGE here if for some weird reason the default definitions are not
-** good enough for your machine. (The 'else' definition always works,
-** but may waste space on machines with 64-bit longs.) Probably you do
-** not need to change this.
+** good enough for your machine. (The definitions in the 'else'
+** part always works, but may waste space on machines with 64-bit
+** longs.) Probably you do not need to change this.
 */
 #if LUAI_BITSINT >= 32
 #define LUAI_UINT32	unsigned int
@@ -352,7 +361,8 @@
 
 
 /*
-@@ LUAI_MAXCSTACK limits the number of slots that a C function can use.
+@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
+@* can use.
 ** CHANGE it if you need lots of (Lua) stack space for your C
 ** functions. This limit is arbitrary; its only purpose is to stop C
 ** functions to consume unlimited stack space.
@@ -379,7 +389,7 @@
 @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
 @* syntactical nested non-terminals in a program.
 */
-#define LUAI_MAXCCALLS	200
+#define LUAI_MAXCCALLS		200
 
 
 /*
@@ -420,7 +430,7 @@
 ** in C is extremely slow, so any alternative is worth trying.
 */
 
-/* On a GNU/Pentium, resort to assembler */
+/* On a gcc/Pentium, resort to assembler */
 #if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__i386)
 #define lua_number2int(i,d)	__asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
 
@@ -433,10 +443,10 @@
 
 /* on Pentium machines compliant with C99, you can try lrint */
 #elif defined (__i386) && defined(__STDC_VERSION__) && \
-                                 (__STDC_VERSION__ >= 199900L)
+				 (__STDC_VERSION__ >= 199900L)
 #define lua_number2int(i,d)	((i)=lrint(d))
 
-/* this option always work, but may be slow */
+/* this option always works, but may be slow */
 #else
 #define lua_number2int(i,d)	((i)=(int)(d))
 
@@ -447,14 +457,14 @@
 @@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
 ** CHANGE (see lua_number2int).
 */
-/* On a GNU or Windows/Pentium, resort to assembler */
+/* On a gcc or Windows/Pentium, resort to assembler */
 #if (defined(__GNUC__) && defined(__i386)) || \
     (defined(_MSC_VER) && defined(_M_IX86))
 #define lua_number2integer(i,n)		lua_number2int(i, n)
 
-/* this option always work, but may be slow */
+/* this option always works, but may be slow */
 #else
-#define lua_number2integer(i,d)     ((i)=(lua_Integer)(d))
+#define lua_number2integer(i,d)		((i)=(lua_Integer)(d))
 
 #endif
 
@@ -462,6 +472,7 @@
 
 /*
 ** {==================================================================
+@@ LUA_NUMBER is the type of numbers in Lua.
 ** CHANGE the following definitions only if you want to build Lua
 ** with a number type different from double. You may also need to
 ** change lua_number2int & lua_number2integer.
@@ -470,7 +481,6 @@
 
 
 /*
-@@ LUA_NUMBER is the type of numbers in Lua.
 @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
 @* over a number.
 */
@@ -512,9 +522,9 @@
 /*
 @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
 ** CHANGE it if your system requires alignments larger than double. (For
-** instance, if your system supports long double and those long doubles
-** must be aligned in 16-byte boundaries, then you should add long
-** double in the union.) Probably you do not need to change this.
+** instance, if your system supports long doubles and they must be
+** aligned in 16-byte boundaries, then you should add long double in the
+** union.) Probably you do not need to change this.
 */
 #define LUAI_USER_ALIGNMENT_T	union { double u; void *s; long l; }
 
@@ -535,7 +545,7 @@
 #define luai_jmpbuf	int  /* dummy variable */
 
 #elif !defined(__STRICT_ANSI__) && (defined(unix) || defined(__unix) || \
-                                    defined(__unix__))
+				    defined(__unix__))
 /* in Unix, try _longjmp/_setjmp (more efficient) */
 #define LUAI_THROW(L,c)	_longjmp((c)->b, 1)
 #define LUAI_TRY(L,c,a)	if (_setjmp((c)->b) == 0) { a }
@@ -589,7 +599,7 @@
 ** dynamic-library system for your platform (either Windows' DLL, Mac's
 ** dyld, or Unix's dlopen). If your system is some kind of Unix, there
 ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
-** it.  To use dlopen you also need to adapt the makefile (probably
+** it.  To use dlopen you also need to adapt the src/Makefile (probably
 ** adding -ldl to the linker options), so Lua does not select it
 ** automatically.  (When you change the makefile to add -ldl, you must
 ** also add -DLUA_USE_DLOPEN.)
@@ -611,7 +621,7 @@
 @@ lua_lock/lua_unlock are macros for thread synchronization inside the
 @* Lua core. This is an attempt to simplify the implementation of a
 @* multithreaded version of Lua.
-** CHANGE them only if you know what you are doing. all accesses to
+** CHANGE them only if you know what you are doing. All accesses to
 ** the global state and to global objects are synchronized.  Because
 ** threads can read the stack of other threads (when running garbage
 ** collection), a thread must also synchronize any write-access to its
@@ -650,7 +660,10 @@
 
 /* =================================================================== */
 
-/* Local configuration */
+/*
+** Local configuration. You can use this space to add your redefinitions
+** without modifying the main part of the file.
+*/
 
 
 

+ 2 - 2
lundump.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.h,v 1.34 2003/08/25 19:51:54 roberto Exp roberto $
+** $Id: lundump.h,v 1.35 2005/04/25 19:24:10 roberto Exp roberto $
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -18,7 +18,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff,
 LUAI_FUNC int luaU_endianness (void);
 
 /* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w,
+LUAI_FUNC int luaU_dump (lua_State* L, const Proto* Main, lua_Writer w,
                                        void* data, int strip);
 
 /* print one chunk; from print.c */

+ 4 - 4
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.42 2005/05/04 20:42:28 roberto Exp roberto $
+** $Id: lvm.c,v 2.43 2005/05/16 21:19:00 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -688,11 +688,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
         const TValue *pstep = ra+2;
         L->savedpc = pc;  /* next steps may throw errors */
         if (!tonumber(init, ra))
-          luaG_runerror(L, "'for' initial value must be a number");
+          luaG_runerror(L, LUA_QL("for") " initial value must be a number");
         else if (!tonumber(plimit, ra+1))
-          luaG_runerror(L, "'for' limit must be a number");
+          luaG_runerror(L, LUA_QL("for") " limit must be a number");
         else if (!tonumber(pstep, ra+2))
-          luaG_runerror(L, "'for' step must be a number");
+          luaG_runerror(L, LUA_QL("for") " step must be a number");
         setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
         dojump(L, pc, GETARG_sBx(i));
         continue;

+ 2 - 2
lzio.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.c,v 1.28 2003/11/18 10:44:53 roberto Exp roberto $
+** $Id: lzio.c,v 1.29 2004/04/30 20:13:38 roberto Exp roberto $
 ** a generic input stream interface
 ** See Copyright Notice in lua.h
 */
@@ -43,7 +43,7 @@ int luaZ_lookahead (ZIO *z) {
 }
 
 
-void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader, void *data) {
+void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
   z->L = L;
   z->reader = reader;
   z->data = data;

+ 3 - 3
lzio.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.h,v 1.19 2003/10/03 16:05:34 roberto Exp roberto $
+** $Id: lzio.h,v 1.20 2005/04/25 19:24:10 roberto Exp roberto $
 ** Buffered streams
 ** See Copyright Notice in lua.h
 */
@@ -44,7 +44,7 @@ typedef struct Mbuffer {
 
 
 LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
-LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader,
+LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
                                         void *data);
 LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n);	/* read next n bytes */
 LUAI_FUNC int luaZ_lookahead (ZIO *z);
@@ -56,7 +56,7 @@ LUAI_FUNC int luaZ_lookahead (ZIO *z);
 struct Zio {
   size_t n;			/* bytes still unread */
   const char *p;		/* current position in buffer */
-  lua_Chunkreader reader;
+  lua_Reader reader;
   void* data;			/* additional data */
   lua_State *L;			/* Lua state (for reader) */
 };