Ver código fonte

no more explicit support for wide-chars; too much troble...

Roberto Ierusalimschy 24 anos atrás
pai
commit
72659a0605
39 arquivos alterados com 1161 adições e 1210 exclusões
  1. 31 32
      lapi.c
  2. 22 23
      lauxlib.c
  3. 18 18
      lauxlib.h
  4. 113 114
      lbaselib.c
  5. 8 9
      lcode.c
  6. 2 2
      lcode.h
  7. 35 36
      ldblib.c
  8. 43 44
      ldebug.c
  9. 2 2
      ldebug.h
  10. 19 20
      ldo.c
  11. 2 2
      ldo.h
  12. 2 3
      lfunc.c
  13. 2 2
      lfunc.h
  14. 2 3
      lgc.c
  15. 122 123
      liolib.c
  16. 100 101
      llex.c
  17. 6 6
      llex.h
  18. 29 30
      lmathlib.c
  19. 3 4
      lmem.c
  20. 2 2
      lmem.h
  21. 20 21
      lobject.c
  22. 5 5
      lobject.h
  23. 43 44
      lopcodes.c
  24. 2 2
      lopcodes.h
  25. 83 84
      lparser.c
  26. 2 3
      lstate.c
  27. 6 7
      lstring.c
  28. 5 5
      lstring.h
  29. 141 136
      lstrlib.c
  30. 5 6
      ltable.c
  31. 107 108
      ltests.c
  32. 21 22
      ltm.c
  33. 4 4
      ltm.h
  34. 58 59
      lua.c
  35. 28 57
      lua.h
  36. 10 10
      luadebug.h
  37. 34 35
      lundump.c
  38. 23 24
      lvm.c
  39. 1 2
      lzio.c

+ 31 - 32
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 1.159 2001/10/31 19:58:11 roberto Exp $
+** $Id: lapi.c,v 1.160 2001/11/16 16:29:51 roberto Exp $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lapi.h"
 #include "lapi.h"
@@ -23,10 +22,10 @@
 #include "lvm.h"
 #include "lvm.h"
 
 
 
 
-const l_char lua_ident[] =
-  l_s("$Lua: ") l_s(LUA_VERSION) l_s(" ") l_s(LUA_COPYRIGHT) l_s(" $\n")
-  l_s("$Authors: ") l_s(LUA_AUTHORS) l_s(" $\n")
-  l_s("$URL: www.lua.org $\n");
+const char lua_ident[] =
+  "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
+  "$Authors: " LUA_AUTHORS " $\n"
+  "$URL: www.lua.org $\n";
 
 
 
 
 
 
@@ -156,12 +155,12 @@ LUA_API int lua_rawtag (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API const l_char *lua_type (lua_State *L, int index) {
+LUA_API const char *lua_type (lua_State *L, int index) {
   StkId o;
   StkId o;
-  const l_char *type;
+  const char *type;
   lua_lock(L);
   lua_lock(L);
   o = luaA_indexAcceptable(L, index);
   o = luaA_indexAcceptable(L, index);
-  type = (o == NULL) ? l_s("no value") : luaT_typename(G(L), o);
+  type = (o == NULL) ? "no value" : luaT_typename(G(L), o);
   lua_unlock(L);
   lua_unlock(L);
   return type;
   return type;
 }
 }
@@ -230,14 +229,14 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) {
 }
 }
 
 
 
 
-LUA_API const l_char *lua_tostring (lua_State *L, int index) {
+LUA_API const char *lua_tostring (lua_State *L, int index) {
   StkId o = luaA_indexAcceptable(L, index);
   StkId o = luaA_indexAcceptable(L, index);
   if (o == NULL)
   if (o == NULL)
     return NULL;
     return NULL;
   else if (ttype(o) == LUA_TSTRING)
   else if (ttype(o) == LUA_TSTRING)
     return svalue(o);
     return svalue(o);
   else {
   else {
-    const l_char *s;
+    const char *s;
     lua_lock(L);  /* `luaV_tostring' may create a new string */
     lua_lock(L);  /* `luaV_tostring' may create a new string */
     s = (luaV_tostring(L, o) == 0) ? svalue(o) : NULL;
     s = (luaV_tostring(L, o) == 0) ? svalue(o) : NULL;
     lua_unlock(L);
     lua_unlock(L);
@@ -309,7 +308,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
 }
 }
 
 
 
 
-LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) {
+LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
   lua_lock(L);
   lua_lock(L);
   setsvalue(L->top, luaS_newlstr(L, s, len));
   setsvalue(L->top, luaS_newlstr(L, s, len));
   api_incr_top(L);
   api_incr_top(L);
@@ -317,7 +316,7 @@ LUA_API void lua_pushlstring (lua_State *L, const l_char *s, size_t len) {
 }
 }
 
 
 
 
-LUA_API void lua_pushstring (lua_State *L, const l_char *s) {
+LUA_API void lua_pushstring (lua_State *L, const char *s) {
   if (s == NULL)
   if (s == NULL)
     lua_pushnil(L);
     lua_pushnil(L);
   else
   else
@@ -346,7 +345,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
 */
 */
 
 
 
 
-LUA_API void lua_getglobal (lua_State *L, const l_char *name) {
+LUA_API void lua_getglobal (lua_State *L, const char *name) {
   lua_lock(L);
   lua_lock(L);
   luaV_getglobal(L, luaS_new(L, name), L->top);
   luaV_getglobal(L, luaS_new(L, name), L->top);
   api_incr_top(L);
   api_incr_top(L);
@@ -398,7 +397,7 @@ LUA_API void lua_newtable (lua_State *L) {
 */
 */
 
 
 
 
-LUA_API void lua_setglobal (lua_State *L, const l_char *name) {
+LUA_API void lua_setglobal (lua_State *L, const char *name) {
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   luaV_setglobal(L, luaS_new(L, name), L->top - 1);
   luaV_setglobal(L, luaS_new(L, name), L->top - 1);
@@ -470,7 +469,7 @@ LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
 }
 }
 
 
 
 
-LUA_API int lua_dofile (lua_State *L, const l_char *filename) {
+LUA_API int lua_dofile (lua_State *L, const char *filename) {
   int status;
   int status;
   status = lua_loadfile(L, filename);
   status = lua_loadfile(L, filename);
   if (status == 0)  /* parse OK? */
   if (status == 0)  /* parse OK? */
@@ -479,8 +478,8 @@ LUA_API int lua_dofile (lua_State *L, const l_char *filename) {
 }
 }
 
 
 
 
-LUA_API int lua_dobuffer (lua_State *L, const l_char *buff, size_t size,
-                          const l_char *name) {
+LUA_API int lua_dobuffer (lua_State *L, const char *buff, size_t size,
+                          const char *name) {
   int status;
   int status;
   status = lua_loadbuffer(L, buff, size, name);
   status = lua_loadbuffer(L, buff, size, name);
   if (status == 0)  /* parse OK? */
   if (status == 0)  /* parse OK? */
@@ -489,7 +488,7 @@ LUA_API int lua_dobuffer (lua_State *L, const l_char *buff, size_t size,
 }
 }
 
 
 
 
-LUA_API int lua_dostring (lua_State *L, const l_char *str) {
+LUA_API int lua_dostring (lua_State *L, const char *str) {
   return lua_dobuffer(L, str, strlen(str), str);
   return lua_dobuffer(L, str, strlen(str), str);
 }
 }
 
 
@@ -534,22 +533,22 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
 ** miscellaneous functions
 ** miscellaneous functions
 */
 */
 
 
-LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
+LUA_API int lua_newtype (lua_State *L, const char *name, int basictype) {
   int tag;
   int tag;
   lua_lock(L);
   lua_lock(L);
   if (basictype != LUA_TNONE &&
   if (basictype != LUA_TNONE &&
       basictype != LUA_TTABLE &&
       basictype != LUA_TTABLE &&
       basictype != LUA_TUSERDATA)
       basictype != LUA_TUSERDATA)
-    luaO_verror(L, l_s("invalid basic type (%d) for new type"), basictype);
+    luaO_verror(L, "invalid basic type (%d) for new type", basictype);
   tag = luaT_newtag(L, name, basictype);
   tag = luaT_newtag(L, name, basictype);
   if (tag == LUA_TNONE)
   if (tag == LUA_TNONE)
-    luaO_verror(L, l_s("type name '%.30s' already exists"), name);
+    luaO_verror(L, "type name '%.30s' already exists", name);
   lua_unlock(L);
   lua_unlock(L);
   return tag;
   return tag;
 }
 }
 
 
 
 
-LUA_API int lua_name2tag (lua_State *L, const l_char *name) {
+LUA_API int lua_name2tag (lua_State *L, const char *name) {
   int tag;
   int tag;
   const TObject *v;
   const TObject *v;
   lua_lock(L);
   lua_lock(L);
@@ -565,10 +564,10 @@ LUA_API int lua_name2tag (lua_State *L, const l_char *name) {
 }
 }
 
 
 
 
-LUA_API const l_char *lua_tag2name (lua_State *L, int tag) {
-  const l_char *s;
+LUA_API const char *lua_tag2name (lua_State *L, int tag) {
+  const char *s;
   lua_lock(L);
   lua_lock(L);
-  s = (tag == LUA_TNONE) ? l_s("no value") : typenamebytag(G(L), tag);
+  s = (tag == LUA_TNONE) ? "no value" : typenamebytag(G(L), tag);
   lua_unlock(L);
   lua_unlock(L);
   return s;
   return s;
 }
 }
@@ -579,10 +578,10 @@ LUA_API void lua_settag (lua_State *L, int tag) {
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   if (tag < 0 || tag >= G(L)->ntag)
   if (tag < 0 || tag >= G(L)->ntag)
-    luaO_verror(L, l_s("%d is not a valid tag"), tag);
+    luaO_verror(L, "%d is not a valid tag", tag);
   basictype = G(L)->TMtable[tag].basictype;
   basictype = G(L)->TMtable[tag].basictype;
   if (basictype != LUA_TNONE && basictype != ttype(L->top-1))
   if (basictype != LUA_TNONE && basictype != ttype(L->top-1))
-    luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag,
+    luaO_verror(L, "tag %d can only be used for type '%.20s'", tag,
                 typenamebytag(G(L), basictype));
                 typenamebytag(G(L), basictype));
   switch (ttype(L->top-1)) {
   switch (ttype(L->top-1)) {
     case LUA_TTABLE:
     case LUA_TTABLE:
@@ -592,14 +591,14 @@ LUA_API void lua_settag (lua_State *L, int tag) {
       uvalue(L->top-1)->uv.tag = tag;
       uvalue(L->top-1)->uv.tag = tag;
       break;
       break;
     default:
     default:
-      luaO_verror(L, l_s("cannot change the tag of a %.20s"),
+      luaO_verror(L, "cannot change the tag of a %.20s",
                   luaT_typename(G(L), L->top-1));
                   luaT_typename(G(L), L->top-1));
   }
   }
   lua_unlock(L);
   lua_unlock(L);
 }
 }
 
 
 
 
-LUA_API void lua_error (lua_State *L, const l_char *s) {
+LUA_API void lua_error (lua_State *L, const char *s) {
   lua_lock(L);
   lua_lock(L);
   luaD_error(L, s);
   luaD_error(L, s);
   lua_unlock(L);
   lua_unlock(L);
@@ -630,7 +629,7 @@ LUA_API int lua_getn (lua_State *L, int index) {
   lua_lock(L);
   lua_lock(L);
   t = luaA_index(L, index);
   t = luaA_index(L, index);
   api_check(L, ttype(t) == LUA_TTABLE);
   api_check(L, ttype(t) == LUA_TTABLE);
-  value = luaH_getstr(hvalue(t), luaS_newliteral(L, l_s("n")));  /* = t.n */
+  value = luaH_getstr(hvalue(t), luaS_newliteral(L, "n"));  /* = t.n */
   if (ttype(value) == LUA_TNUMBER)
   if (ttype(value) == LUA_TNUMBER)
     n = cast(int, nvalue(value));
     n = cast(int, nvalue(value));
   else {
   else {
@@ -734,7 +733,7 @@ LUA_API void lua_pushupvalues (lua_State *L) {
   api_check(L, iscfunction(func));
   api_check(L, iscfunction(func));
   n = clvalue(func)->c.nupvalues;
   n = clvalue(func)->c.nupvalues;
   if (LUA_MINSTACK+n > lua_stackspace(L))
   if (LUA_MINSTACK+n > lua_stackspace(L))
-    luaD_error(L, l_s("stack overflow"));
+    luaD_error(L, "stack overflow");
   for (i=0; i<n; i++) {
   for (i=0; i<n; i++) {
     setobj(L->top, &clvalue(func)->c.upvalue[i]);
     setobj(L->top, &clvalue(func)->c.upvalue[i]);
     L->top++;
     L->top++;

+ 22 - 23
lauxlib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lauxlib.c,v 1.52 2001/10/26 17:33:30 roberto Exp $
+** $Id: lauxlib.c,v 1.53 2001/10/31 19:40:14 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -14,7 +14,6 @@
 ** With care, these functions can be used by other libraries.
 ** With care, these functions can be used by other libraries.
 */
 */
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
@@ -23,7 +22,7 @@
 
 
 
 
 
 
-LUALIB_API int luaL_findstring (const l_char *name, const l_char *const list[]) {
+LUALIB_API int luaL_findstring (const char *name, const char *const list[]) {
   int i;
   int i;
   for (i=0; list[i]; i++)
   for (i=0; list[i]; i++)
     if (strcmp(list[i], name) == 0)
     if (strcmp(list[i], name) == 0)
@@ -31,20 +30,20 @@ LUALIB_API int luaL_findstring (const l_char *name, const l_char *const list[])
   return -1;  /* name not found */
   return -1;  /* name not found */
 }
 }
 
 
-LUALIB_API void luaL_argerror (lua_State *L, int narg, const l_char *extramsg) {
+LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
   lua_Debug ar;
   lua_Debug ar;
   lua_getstack(L, 0, &ar);
   lua_getstack(L, 0, &ar);
-  lua_getinfo(L, l_s("n"), &ar);
+  lua_getinfo(L, "n", &ar);
   if (ar.name == NULL)
   if (ar.name == NULL)
-    ar.name = l_s("?");
-  luaL_verror(L, l_s("bad argument #%d to `%.50s' (%.100s)"),
+    ar.name = "?";
+  luaL_verror(L, "bad argument #%d to `%.50s' (%.100s)",
               narg, ar.name, extramsg);
               narg, ar.name, extramsg);
 }
 }
 
 
 
 
-LUALIB_API void luaL_typerror (lua_State *L, int narg, const l_char *tname) {
-  l_char buff[80];
-  sprintf(buff, l_s("%.25s expected, got %.25s"), tname, lua_type(L,narg));
+LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname) {
+  char buff[80];
+  sprintf(buff, "%.25s expected, got %.25s", tname, lua_type(L,narg));
   luaL_argerror(L, narg, buff);
   luaL_argerror(L, narg, buff);
 }
 }
 
 
@@ -54,9 +53,9 @@ static void tag_error (lua_State *L, int narg, int tag) {
 }
 }
 
 
 
 
-LUALIB_API void luaL_check_stack (lua_State *L, int space, const l_char *mes) {
+LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) {
   if (space > lua_stackspace(L))
   if (space > lua_stackspace(L))
-    luaL_verror(L, l_s("stack overflow (%.30s)"), mes);
+    luaL_verror(L, "stack overflow (%.30s)", mes);
 }
 }
 
 
 
 
@@ -68,27 +67,27 @@ LUALIB_API void luaL_check_rawtype(lua_State *L, int narg, int t) {
 
 
 LUALIB_API void luaL_check_any (lua_State *L, int narg) {
 LUALIB_API void luaL_check_any (lua_State *L, int narg) {
   if (lua_rawtag(L, narg) == LUA_TNONE)
   if (lua_rawtag(L, narg) == LUA_TNONE)
-    luaL_argerror(L, narg, l_s("value expected"));
+    luaL_argerror(L, narg, "value expected");
 }
 }
 
 
 
 
 LUALIB_API void *luaL_check_userdata (lua_State *L, int narg,
 LUALIB_API void *luaL_check_userdata (lua_State *L, int narg,
-                                      const l_char *name) {
+                                      const char *name) {
   if (strcmp(lua_type(L, narg), name) != 0)
   if (strcmp(lua_type(L, narg), name) != 0)
     luaL_typerror(L, narg, name);
     luaL_typerror(L, narg, name);
   return lua_touserdata(L, narg);
   return lua_touserdata(L, narg);
 }
 }
 
 
 
 
-LUALIB_API const l_char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
-  const l_char *s = lua_tostring(L, narg);
+LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
+  const char *s = lua_tostring(L, narg);
   if (!s) tag_error(L, narg, LUA_TSTRING);
   if (!s) tag_error(L, narg, LUA_TSTRING);
   if (len) *len = lua_strlen(L, narg);
   if (len) *len = lua_strlen(L, narg);
   return s;
   return s;
 }
 }
 
 
 
 
-LUALIB_API const l_char *luaL_opt_lstr (lua_State *L, int narg, const l_char *def, size_t *len) {
+LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) {
   if (lua_isnull(L, narg)) {
   if (lua_isnull(L, narg)) {
     if (len)
     if (len)
       *len = (def ? strlen(def) : 0);
       *len = (def ? strlen(def) : 0);
@@ -119,8 +118,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n) {
 }
 }
 
 
 
 
-LUALIB_API void luaL_verror (lua_State *L, const l_char *fmt, ...) {
-  l_char buff[500];
+LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...) {
+  char buff[500];
   va_list argp;
   va_list argp;
   va_start(argp, fmt);
   va_start(argp, fmt);
   vsprintf(buff, fmt, argp);
   vsprintf(buff, fmt, argp);
@@ -174,20 +173,20 @@ static void adjuststack (luaL_Buffer *B) {
 }
 }
 
 
 
 
-LUALIB_API l_char *luaL_prepbuffer (luaL_Buffer *B) {
+LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
   if (emptybuffer(B))
   if (emptybuffer(B))
     adjuststack(B);
     adjuststack(B);
   return B->buffer;
   return B->buffer;
 }
 }
 
 
 
 
-LUALIB_API void luaL_addlstring (luaL_Buffer *B, const l_char *s, size_t l) {
+LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
   while (l--)
   while (l--)
     luaL_putchar(B, *s++);
     luaL_putchar(B, *s++);
 }
 }
 
 
 
 
-LUALIB_API void luaL_addstring (luaL_Buffer *B, const l_char *s) {
+LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
   luaL_addlstring(B, s, strlen(s));
   luaL_addlstring(B, s, strlen(s));
 }
 }
 
 
@@ -236,7 +235,7 @@ LUALIB_API int luaL_ref (lua_State *L, int t) {
   }
   }
   else {  /* no free elements */
   else {  /* no free elements */
     ref = lua_getn(L, t) + 1;  /* use next `n' */
     ref = lua_getn(L, t) + 1;  /* use next `n' */
-    lua_pushliteral(L, l_s("n"));
+    lua_pushliteral(L, "n");
     lua_pushnumber(L, ref);
     lua_pushnumber(L, ref);
     lua_settable(L, t);  /* n = n+1 */
     lua_settable(L, t);  /* n = n+1 */
   }
   }

+ 18 - 18
lauxlib.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lauxlib.h,v 1.37 2001/10/26 17:33:30 roberto Exp $
+** $Id: lauxlib.h,v 1.38 2001/10/31 19:40:14 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -21,31 +21,31 @@
 
 
 
 
 typedef struct luaL_reg {
 typedef struct luaL_reg {
-  const lua_char *name;
+  const char *name;
   lua_CFunction func;
   lua_CFunction func;
 } luaL_reg;
 } luaL_reg;
 
 
 
 
 LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n);
 LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n);
-LUALIB_API void luaL_typerror (lua_State *L, int narg, const lua_char *tname);
+LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname);
 LUALIB_API void luaL_argerror (lua_State *L, int numarg,
 LUALIB_API void luaL_argerror (lua_State *L, int numarg,
-                               const lua_char *extramsg);
-LUALIB_API const lua_char *luaL_check_lstr (lua_State *L, int numArg,
+                               const char *extramsg);
+LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg,
                                             size_t *len);
                                             size_t *len);
-LUALIB_API const lua_char *luaL_opt_lstr (lua_State *L, int numArg,
-                                          const lua_char *def, size_t *len);
+LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg,
+                                          const char *def, size_t *len);
 LUALIB_API lua_Number luaL_check_number (lua_State *L, int numArg);
 LUALIB_API lua_Number luaL_check_number (lua_State *L, int numArg);
 LUALIB_API lua_Number luaL_opt_number (lua_State *L, int nArg, lua_Number def);
 LUALIB_API lua_Number luaL_opt_number (lua_State *L, int nArg, lua_Number def);
 
 
-LUALIB_API void luaL_check_stack (lua_State *L, int space, const lua_char *msg);
+LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *msg);
 LUALIB_API void luaL_check_rawtype (lua_State *L, int narg, int t);
 LUALIB_API void luaL_check_rawtype (lua_State *L, int narg, int t);
 LUALIB_API void luaL_check_any (lua_State *L, int narg);
 LUALIB_API void luaL_check_any (lua_State *L, int narg);
 LUALIB_API void *luaL_check_userdata (lua_State *L, int narg,
 LUALIB_API void *luaL_check_userdata (lua_State *L, int narg,
-                                      const lua_char *name);
+                                      const char *name);
 
 
-LUALIB_API void luaL_verror (lua_State *L, const lua_char *fmt, ...);
-LUALIB_API int luaL_findstring (const lua_char *name, 
-                                const lua_char *const list[]);
+LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...);
+LUALIB_API int luaL_findstring (const char *name, 
+                                const char *const list[]);
 
 
 LUALIB_API int luaL_ref (lua_State *L, int t);
 LUALIB_API int luaL_ref (lua_State *L, int t);
 LUALIB_API void luaL_unref (lua_State *L, int t, int ref);
 LUALIB_API void luaL_unref (lua_State *L, int t, int ref);
@@ -81,22 +81,22 @@ LUALIB_API void luaL_unref (lua_State *L, int t, int ref);
 
 
 
 
 typedef struct luaL_Buffer {
 typedef struct luaL_Buffer {
-  lua_char *p;			/* current position in buffer */
+  char *p;			/* current position in buffer */
   int level;
   int level;
   lua_State *L;
   lua_State *L;
-  lua_char buffer[LUAL_BUFFERSIZE];
+  char buffer[LUAL_BUFFERSIZE];
 } luaL_Buffer;
 } luaL_Buffer;
 
 
 #define luaL_putchar(B,c) \
 #define luaL_putchar(B,c) \
   ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
   ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
-   (*(B)->p++ = (lua_char)(c)))
+   (*(B)->p++ = (char)(c)))
 
 
 #define luaL_addsize(B,n)	((B)->p += (n))
 #define luaL_addsize(B,n)	((B)->p += (n))
 
 
 LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B);
 LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B);
-LUALIB_API lua_char *luaL_prepbuffer (luaL_Buffer *B);
-LUALIB_API void luaL_addlstring (luaL_Buffer *B, const lua_char *s, size_t l);
-LUALIB_API void luaL_addstring (luaL_Buffer *B, const lua_char *s);
+LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B);
+LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);
+LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s);
 LUALIB_API void luaL_addvalue (luaL_Buffer *B);
 LUALIB_API void luaL_addvalue (luaL_Buffer *B);
 LUALIB_API void luaL_pushresult (luaL_Buffer *B);
 LUALIB_API void luaL_pushresult (luaL_Buffer *B);
 
 

+ 113 - 114
lbaselib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lbaselib.c,v 1.44 2001/10/17 21:12:57 roberto Exp $
+** $Id: lbaselib.c,v 1.45 2001/10/26 17:33:30 roberto Exp $
 ** Basic library
 ** Basic library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -11,7 +11,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
@@ -21,7 +20,7 @@
 
 
 
 
 static void aux_setn (lua_State *L, int t, int n) {
 static void aux_setn (lua_State *L, int t, int n) {
-  lua_pushliteral(L, l_s("n"));
+  lua_pushliteral(L, "n");
   lua_pushnumber(L, n);
   lua_pushnumber(L, n);
   lua_settable(L, t);
   lua_settable(L, t);
 }
 }
@@ -43,21 +42,21 @@ static int luaB__ALERT (lua_State *L) {
 */
 */
 static int luaB__ERRORMESSAGE (lua_State *L) {
 static int luaB__ERRORMESSAGE (lua_State *L) {
   luaL_check_rawtype(L, 1, LUA_TSTRING);
   luaL_check_rawtype(L, 1, LUA_TSTRING);
-  lua_getglobal(L, l_s(LUA_ALERT));
+  lua_getglobal(L, LUA_ALERT);
   if (lua_isfunction(L, -1)) {  /* avoid error loop if _ALERT is not defined */
   if (lua_isfunction(L, -1)) {  /* avoid error loop if _ALERT is not defined */
     lua_Debug ar;
     lua_Debug ar;
-    lua_pushliteral(L, l_s("error: "));
+    lua_pushliteral(L, "error: ");
     lua_pushvalue(L, 1);
     lua_pushvalue(L, 1);
     if (lua_getstack(L, 1, &ar)) {
     if (lua_getstack(L, 1, &ar)) {
-      lua_getinfo(L, l_s("Sl"), &ar);
+      lua_getinfo(L, "Sl", &ar);
       if (ar.source && ar.currentline > 0) {
       if (ar.source && ar.currentline > 0) {
-        l_char buff[100];
-        sprintf(buff, l_s("\n  <%.70s: line %d>"), ar.short_src, ar.currentline);
+        char buff[100];
+        sprintf(buff, "\n  <%.70s: line %d>", ar.short_src, ar.currentline);
         lua_pushstring(L, buff);
         lua_pushstring(L, buff);
         lua_concat(L, 2);
         lua_concat(L, 2);
       }
       }
     }
     }
-    lua_pushliteral(L, l_s("\n"));
+    lua_pushliteral(L, "\n");
     lua_concat(L, 3);
     lua_concat(L, 3);
     lua_rawcall(L, 1, 0);
     lua_rawcall(L, 1, 0);
   }
   }
@@ -74,20 +73,20 @@ static int luaB__ERRORMESSAGE (lua_State *L) {
 static int luaB_print (lua_State *L) {
 static int luaB_print (lua_State *L) {
   int n = lua_gettop(L);  /* number of arguments */
   int n = lua_gettop(L);  /* number of arguments */
   int i;
   int i;
-  lua_getglobal(L, l_s("tostring"));
+  lua_getglobal(L, "tostring");
   for (i=1; i<=n; i++) {
   for (i=1; i<=n; i++) {
-    const l_char *s;
+    const char *s;
     lua_pushvalue(L, -1);  /* function to be called */
     lua_pushvalue(L, -1);  /* function to be called */
     lua_pushvalue(L, i);   /* value to print */
     lua_pushvalue(L, i);   /* value to print */
     lua_rawcall(L, 1, 1);
     lua_rawcall(L, 1, 1);
     s = lua_tostring(L, -1);  /* get result */
     s = lua_tostring(L, -1);  /* get result */
     if (s == NULL)
     if (s == NULL)
-      lua_error(L, l_s("`tostring' must return a string to `print'"));
-    if (i>1) fputs(l_s("\t"), stdout);
+      lua_error(L, "`tostring' must return a string to `print'");
+    if (i>1) fputs("\t", stdout);
     fputs(s, stdout);
     fputs(s, stdout);
     lua_pop(L, 1);  /* pop result */
     lua_pop(L, 1);  /* pop result */
   }
   }
-  fputs(l_s("\n"), stdout);
+  fputs("\n", stdout);
   return 0;
   return 0;
 }
 }
 
 
@@ -102,14 +101,14 @@ static int luaB_tonumber (lua_State *L) {
     }
     }
   }
   }
   else {
   else {
-    const l_char *s1 = luaL_check_string(L, 1);
-    l_char *s2;
+    const char *s1 = luaL_check_string(L, 1);
+    char *s2;
     unsigned long n;
     unsigned long n;
-    luaL_arg_check(L, 2 <= base && base <= 36, 2, l_s("base out of range"));
+    luaL_arg_check(L, 2 <= base && base <= 36, 2, "base out of range");
     n = strtoul(s1, &s2, base);
     n = strtoul(s1, &s2, base);
     if (s1 != s2) {  /* at least one valid digit? */
     if (s1 != s2) {  /* at least one valid digit? */
-      while (isspace(uchar(*s2))) s2++;  /* skip trailing spaces */
-      if (*s2 == l_c('\0')) {  /* no invalid trailing characters? */
+      while (isspace((unsigned char)(*s2))) s2++;  /* skip trailing spaces */
+      if (*s2 == '\0') {  /* no invalid trailing characters? */
         lua_pushnumber(L, n);
         lua_pushnumber(L, n);
         return 1;
         return 1;
       }
       }
@@ -143,14 +142,14 @@ static int gettag (lua_State *L, int narg) {
     case LUA_TNUMBER:
     case LUA_TNUMBER:
       return (int)(lua_tonumber(L, narg));
       return (int)(lua_tonumber(L, narg));
     case LUA_TSTRING: {
     case LUA_TSTRING: {
-      const l_char *name = lua_tostring(L, narg);
+      const char *name = lua_tostring(L, narg);
       int tag = lua_name2tag(L, name);
       int tag = lua_name2tag(L, name);
       if (tag == LUA_TNONE)
       if (tag == LUA_TNONE)
-        luaL_verror(L, l_s("'%.30s' is not a valid type name"), name);
+        luaL_verror(L, "'%.30s' is not a valid type name", name);
       return tag;
       return tag;
     }
     }
     default:
     default:
-      luaL_argerror(L, narg, l_s("tag or type name expected"));
+      luaL_argerror(L, narg, "tag or type name expected");
       return 0;  /* to avoid warnings */
       return 0;  /* to avoid warnings */
   }
   }
 }
 }
@@ -170,11 +169,11 @@ static int luaB_settype (lua_State *L) {
 }
 }
 
 
 static int luaB_weakmode (lua_State *L) {
 static int luaB_weakmode (lua_State *L) {
-  const l_char *mode = luaL_check_string(L, 2);
+  const char *mode = luaL_check_string(L, 2);
   luaL_check_rawtype(L, 1, LUA_TTABLE);
   luaL_check_rawtype(L, 1, LUA_TTABLE);
-  if (*mode == l_c('?')) {
-    l_char buff[3];
-    l_char *s = buff;
+  if (*mode == '?') {
+    char buff[3];
+    char *s = buff;
     int imode = lua_getweakmode(L, 1);
     int imode = lua_getweakmode(L, 1);
     if (imode & LUA_WEAK_KEY) *s++ = 'k';
     if (imode & LUA_WEAK_KEY) *s++ = 'k';
     if (imode & LUA_WEAK_VALUE) *s++ = 'v';
     if (imode & LUA_WEAK_VALUE) *s++ = 'v';
@@ -184,8 +183,8 @@ static int luaB_weakmode (lua_State *L) {
   }
   }
   else {
   else {
     int imode = 0;
     int imode = 0;
-    if (strchr(mode, l_c('k'))) imode |= LUA_WEAK_KEY;
-    if (strchr(mode, l_c('v'))) imode |= LUA_WEAK_VALUE;
+    if (strchr(mode, 'k')) imode |= LUA_WEAK_KEY;
+    if (strchr(mode, 'v')) imode |= LUA_WEAK_VALUE;
     lua_pushvalue(L, 1);  /* push table */
     lua_pushvalue(L, 1);  /* push table */
     lua_setweakmode(L, imode);
     lua_setweakmode(L, imode);
     return 1;  /* return the table */
     return 1;  /* return the table */
@@ -193,7 +192,7 @@ static int luaB_weakmode (lua_State *L) {
 }
 }
 
 
 static int luaB_newtype (lua_State *L) {
 static int luaB_newtype (lua_State *L) {
-  const l_char *name = luaL_opt_string(L, 1, NULL);
+  const char *name = luaL_opt_string(L, 1, NULL);
   lua_pushnumber(L, lua_newtype(L, name, LUA_TTABLE));
   lua_pushnumber(L, lua_newtype(L, name, LUA_TTABLE));
   return 1;
   return 1;
 }
 }
@@ -226,11 +225,11 @@ static int luaB_rawset (lua_State *L) {
 
 
 static int luaB_settagmethod (lua_State *L) {
 static int luaB_settagmethod (lua_State *L) {
   int tag = gettag(L, 1);
   int tag = gettag(L, 1);
-  const l_char *event = luaL_check_string(L, 2);
+  const char *event = luaL_check_string(L, 2);
   luaL_arg_check(L, lua_isfunction(L, 3) || lua_isnil(L, 3), 3,
   luaL_arg_check(L, lua_isfunction(L, 3) || lua_isnil(L, 3), 3,
-                 l_s("function or nil expected"));
-  if (strcmp(event, l_s("gc")) == 0)
-    lua_error(L, l_s("cannot set `gc' tag method from Lua"));
+                 "function or nil expected");
+  if (strcmp(event, "gc") == 0)
+    lua_error(L, "cannot set `gc' tag method from Lua");
   lua_gettagmethod(L, tag, event);
   lua_gettagmethod(L, tag, event);
   lua_pushvalue(L, 3);
   lua_pushvalue(L, 3);
   lua_settagmethod(L, tag, event);
   lua_settagmethod(L, tag, event);
@@ -240,9 +239,9 @@ static int luaB_settagmethod (lua_State *L) {
 
 
 static int luaB_gettagmethod (lua_State *L) {
 static int luaB_gettagmethod (lua_State *L) {
   int tag = gettag(L, 1);
   int tag = gettag(L, 1);
-  const l_char *event = luaL_check_string(L, 2);
-  if (strcmp(event, l_s("gc")) == 0)
-    lua_error(L, l_s("cannot get `gc' tag method from Lua"));
+  const char *event = luaL_check_string(L, 2);
+  if (strcmp(event, "gc") == 0)
+    lua_error(L, "cannot get `gc' tag method from Lua");
   lua_gettagmethod(L, tag, event);
   lua_gettagmethod(L, tag, event);
   return 1;
   return 1;
 }
 }
@@ -288,9 +287,9 @@ static int luaB_next (lua_State *L) {
 
 
 
 
 static int passresults (lua_State *L, int status, int oldtop) {
 static int passresults (lua_State *L, int status, int oldtop) {
-  static const l_char *const errornames[] =
-    {l_s("ok"), l_s("run-time error"), l_s("file error"), l_s("syntax error"),
-     l_s("memory error"), l_s("error in error handling")};
+  static const char *const errornames[] =
+    {"ok", "run-time error", "file error", "syntax error",
+     "memory error", "error in error handling"};
   if (status == 0) {
   if (status == 0) {
     int nresults = lua_gettop(L) - oldtop;
     int nresults = lua_gettop(L) - oldtop;
     if (nresults > 0)
     if (nresults > 0)
@@ -311,8 +310,8 @@ static int passresults (lua_State *L, int status, int oldtop) {
 static int luaB_dostring (lua_State *L) {
 static int luaB_dostring (lua_State *L) {
   int oldtop = lua_gettop(L);
   int oldtop = lua_gettop(L);
   size_t l;
   size_t l;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
-  const l_char *chunkname = luaL_opt_string(L, 2, s);
+  const char *s = luaL_check_lstr(L, 1, &l);
+  const char *chunkname = luaL_opt_string(L, 2, s);
   return passresults(L, lua_dobuffer(L, s, l, chunkname), oldtop);
   return passresults(L, lua_dobuffer(L, s, l, chunkname), oldtop);
 }
 }
 
 
@@ -320,36 +319,36 @@ static int luaB_dostring (lua_State *L) {
 static int luaB_loadstring (lua_State *L) {
 static int luaB_loadstring (lua_State *L) {
   int oldtop = lua_gettop(L);
   int oldtop = lua_gettop(L);
   size_t l;
   size_t l;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
-  const l_char *chunkname = luaL_opt_string(L, 2, s);
+  const char *s = luaL_check_lstr(L, 1, &l);
+  const char *chunkname = luaL_opt_string(L, 2, s);
   return passresults(L, lua_loadbuffer(L, s, l, chunkname), oldtop);
   return passresults(L, lua_loadbuffer(L, s, l, chunkname), oldtop);
 }
 }
 
 
 static int luaB_dofile (lua_State *L) {
 static int luaB_dofile (lua_State *L) {
   int oldtop = lua_gettop(L);
   int oldtop = lua_gettop(L);
-  const l_char *fname = luaL_opt_string(L, 1, NULL);
+  const char *fname = luaL_opt_string(L, 1, NULL);
   return passresults(L, lua_dofile(L, fname), oldtop);
   return passresults(L, lua_dofile(L, fname), oldtop);
 }
 }
 
 
 
 
 static int luaB_loadfile (lua_State *L) {
 static int luaB_loadfile (lua_State *L) {
   int oldtop = lua_gettop(L);
   int oldtop = lua_gettop(L);
-  const l_char *fname = luaL_opt_string(L, 1, NULL);
+  const char *fname = luaL_opt_string(L, 1, NULL);
   return passresults(L, lua_loadfile(L, fname), oldtop);
   return passresults(L, lua_loadfile(L, fname), oldtop);
 }
 }
 
 
 
 
 
 
-#define LUA_PATH	l_s("LUA_PATH")
+#define LUA_PATH	"LUA_PATH"
 
 
-#define LUA_PATH_SEP	l_s(";")
+#define LUA_PATH_SEP	";"
 
 
 #ifndef LUA_PATH_DEFAULT
 #ifndef LUA_PATH_DEFAULT
-#define LUA_PATH_DEFAULT	l_s("./")
+#define LUA_PATH_DEFAULT	"./"
 #endif
 #endif
 
 
 static int luaB_require (lua_State *L) {
 static int luaB_require (lua_State *L) {
-  const l_char *path;
+  const char *path;
   luaL_check_string(L, 1);
   luaL_check_string(L, 1);
   lua_settop(L, 1);
   lua_settop(L, 1);
   lua_getglobal(L, LUA_PATH);  /* get path */
   lua_getglobal(L, LUA_PATH);  /* get path */
@@ -379,8 +378,8 @@ static int luaB_require (lua_State *L) {
       if (res == 0) break;  /* ok; file done */
       if (res == 0) break;  /* ok; file done */
       else if (res != LUA_ERRFILE)
       else if (res != LUA_ERRFILE)
         lua_error(L, NULL);  /* error running package; propagate it */
         lua_error(L, NULL);  /* error running package; propagate it */
-      if (*(path+l) == l_c('\0'))  /* no more directories? */
-        luaL_verror(L, l_s("could not load package `%.20s' from path `%.200s'"),
+      if (*(path+l) == '\0')  /* no more directories? */
+        luaL_verror(L, "could not load package `%.20s' from path `%.200s'",
                     lua_tostring(L, 1), lua_tostring(L, 2));
                     lua_tostring(L, 1), lua_tostring(L, 2));
       path += l+1;  /* try next directory */
       path += l+1;  /* try next directory */
     }
     }
@@ -396,7 +395,7 @@ static int aux_unpack (lua_State *L, int arg) {
   int n, i;
   int n, i;
   luaL_check_rawtype(L, arg, LUA_TTABLE);
   luaL_check_rawtype(L, arg, LUA_TTABLE);
   n = lua_getn(L, arg);
   n = lua_getn(L, arg);
-  luaL_check_stack(L, n, l_s("table too big to unpack"));
+  luaL_check_stack(L, n, "table too big to unpack");
   for (i=1; i<=n; i++)  /* push arg[1...n] */
   for (i=1; i<=n; i++)  /* push arg[1...n] */
     lua_rawgeti(L, arg, i);
     lua_rawgeti(L, arg, i);
   return n;
   return n;
@@ -410,15 +409,15 @@ static int luaB_unpack (lua_State *L) {
 
 
 static int luaB_call (lua_State *L) {
 static int luaB_call (lua_State *L) {
   int oldtop;
   int oldtop;
-  const l_char *options = luaL_opt_string(L, 3, l_s(""));
+  const char *options = luaL_opt_string(L, 3, "");
   int err = 0;  /* index of old error method */
   int err = 0;  /* index of old error method */
   int status;
   int status;
   int n;
   int n;
   if (!lua_isnull(L, 4)) {  /* set new error method */
   if (!lua_isnull(L, 4)) {  /* set new error method */
-    lua_getglobal(L, l_s(LUA_ERRORMESSAGE));
+    lua_getglobal(L, LUA_ERRORMESSAGE);
     err = lua_gettop(L);  /* get index */
     err = lua_gettop(L);  /* get index */
     lua_pushvalue(L, 4);
     lua_pushvalue(L, 4);
-    lua_setglobal(L, l_s(LUA_ERRORMESSAGE));
+    lua_setglobal(L, LUA_ERRORMESSAGE);
   }
   }
   oldtop = lua_gettop(L);  /* top before function-call preparation */
   oldtop = lua_gettop(L);  /* top before function-call preparation */
   /* push function */
   /* push function */
@@ -427,23 +426,23 @@ static int luaB_call (lua_State *L) {
   status = lua_call(L, n, LUA_MULTRET);
   status = lua_call(L, n, LUA_MULTRET);
   if (err != 0) {  /* restore old error method */
   if (err != 0) {  /* restore old error method */
     lua_pushvalue(L, err);
     lua_pushvalue(L, err);
-    lua_setglobal(L, l_s(LUA_ERRORMESSAGE));
+    lua_setglobal(L, LUA_ERRORMESSAGE);
   }
   }
   if (status != 0) {  /* error in call? */
   if (status != 0) {  /* error in call? */
-    if (strchr(options, l_c('x')))
+    if (strchr(options, 'x'))
       lua_pushnil(L);  /* return nil to signal the error */
       lua_pushnil(L);  /* return nil to signal the error */
     else
     else
       lua_error(L, NULL);  /* propagate error without additional messages */
       lua_error(L, NULL);  /* propagate error without additional messages */
     return 1;
     return 1;
   }
   }
-  if (strchr(options, l_c('p')))  /* pack results? */
-    lua_error(L, l_s("obsolete option `p' in `call'"));
+  if (strchr(options, 'p'))  /* pack results? */
+    lua_error(L, "obsolete option `p' in `call'");
   return lua_gettop(L) - oldtop;  /* results are already on the stack */
   return lua_gettop(L) - oldtop;  /* results are already on the stack */
 }
 }
 
 
 
 
 static int luaB_tostring (lua_State *L) {
 static int luaB_tostring (lua_State *L) {
-  l_char buff[64];
+  char buff[64];
   switch (lua_rawtag(L, 1)) {
   switch (lua_rawtag(L, 1)) {
     case LUA_TNUMBER:
     case LUA_TNUMBER:
       lua_pushstring(L, lua_tostring(L, 1));
       lua_pushstring(L, lua_tostring(L, 1));
@@ -452,25 +451,25 @@ static int luaB_tostring (lua_State *L) {
       lua_pushvalue(L, 1);
       lua_pushvalue(L, 1);
       return 1;
       return 1;
     case LUA_TTABLE:
     case LUA_TTABLE:
-      sprintf(buff, l_s("%.40s: %p"), lua_type(L, 1), lua_topointer(L, 1));
+      sprintf(buff, "%.40s: %p", lua_type(L, 1), lua_topointer(L, 1));
       break;
       break;
     case LUA_TFUNCTION:
     case LUA_TFUNCTION:
-      sprintf(buff, l_s("function: %p"), lua_topointer(L, 1));
+      sprintf(buff, "function: %p", lua_topointer(L, 1));
       break;
       break;
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      const l_char *t = lua_type(L, 1);
-      if (strcmp(t, l_s("userdata")) == 0)
-        sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1),
+      const char *t = lua_type(L, 1);
+      if (strcmp(t, "userdata") == 0)
+        sprintf(buff, "userdata(%d): %p", lua_tag(L, 1),
                 lua_touserdata(L, 1));
                 lua_touserdata(L, 1));
       else
       else
-        sprintf(buff, l_s("%.40s: %p"), t, lua_touserdata(L, 1));
+        sprintf(buff, "%.40s: %p", t, lua_touserdata(L, 1));
       break;
       break;
     }
     }
     case LUA_TNIL:
     case LUA_TNIL:
-      lua_pushliteral(L, l_s("nil"));
+      lua_pushliteral(L, "nil");
       return 1;
       return 1;
     default:
     default:
-      luaL_argerror(L, 1, l_s("value expected"));
+      luaL_argerror(L, 1, "value expected");
   }
   }
   lua_pushstring(L, buff);
   lua_pushstring(L, buff);
   return 1;
   return 1;
@@ -516,8 +515,8 @@ static int luaB_foreach (lua_State *L) {
 static int luaB_assert (lua_State *L) {
 static int luaB_assert (lua_State *L) {
   luaL_check_any(L, 1);
   luaL_check_any(L, 1);
   if (lua_isnil(L, 1))
   if (lua_isnil(L, 1))
-    luaL_verror(L, l_s("assertion failed!  %.90s"),
-                   luaL_opt_string(L, 2, l_s("")));
+    luaL_verror(L, "assertion failed!  %.90s",
+                   luaL_opt_string(L, 2, ""));
   lua_settop(L, 1);
   lua_settop(L, 1);
   return 1;
   return 1;
 }
 }
@@ -635,12 +634,12 @@ static void auxsort (lua_State *L, int l, int u) {
     for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
     for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
       /* repeat ++i until a[i] >= P */
       /* repeat ++i until a[i] >= P */
       while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
       while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
-        if (i>u) lua_error(L, l_s("invalid order function for sorting"));
+        if (i>u) lua_error(L, "invalid order function for sorting");
         lua_pop(L, 1);  /* remove a[i] */
         lua_pop(L, 1);  /* remove a[i] */
       }
       }
       /* repeat --j until a[j] <= P */
       /* repeat --j until a[j] <= P */
       while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
       while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
-        if (j<l) lua_error(L, l_s("invalid order function for sorting"));
+        if (j<l) lua_error(L, "invalid order function for sorting");
         lua_pop(L, 1);  /* remove a[j] */
         lua_pop(L, 1);  /* remove a[j] */
       }
       }
       if (j<i) {
       if (j<i) {
@@ -680,57 +679,57 @@ static int luaB_sort (lua_State *L) {
 
 
 
 
 static const luaL_reg base_funcs[] = {
 static const luaL_reg base_funcs[] = {
-  {l_s(LUA_ALERT), luaB__ALERT},
-  {l_s(LUA_ERRORMESSAGE), luaB__ERRORMESSAGE},
-  {l_s("call"), luaB_call},
-  {l_s("collectgarbage"), luaB_collectgarbage},
-  {l_s("dofile"), luaB_dofile},
-  {l_s("dostring"), luaB_dostring},
-  {l_s("error"), luaB_error},
-  {l_s("foreach"), luaB_foreach},
-  {l_s("foreachi"), luaB_foreachi},
-  {l_s("gcinfo"), luaB_gcinfo},
-  {l_s("getglobal"), luaB_getglobal},
-  {l_s("gettagmethod"), luaB_gettagmethod},
-  {l_s("globals"), luaB_globals},
-  {l_s("loadfile"), luaB_loadfile},
-  {l_s("loadstring"), luaB_loadstring},
-  {l_s("newtype"), luaB_newtype},
-  {l_s("newtag"), luaB_newtype},  /* for compatibility 4.0 */
-  {l_s("next"), luaB_next},
-  {l_s("print"), luaB_print},
-  {l_s("rawget"), luaB_rawget},
-  {l_s("rawset"), luaB_rawset},
-  {l_s("rawgettable"), luaB_rawget},  /* for compatibility 3.2 */
-  {l_s("rawsettable"), luaB_rawset},  /* for compatibility 3.2 */
-  {l_s("rawtype"), luaB_rawtype},
-  {l_s("setglobal"), luaB_setglobal},
-  {l_s("settag"), luaB_settype},  /* for compatibility 4.0 */
-  {l_s("settype"), luaB_settype},
-  {l_s("settagmethod"), luaB_settagmethod},
-  {l_s("tag"), luaB_tag},
-  {l_s("tonumber"), luaB_tonumber},
-  {l_s("tostring"), luaB_tostring},
-  {l_s("type"), luaB_type},
-  {l_s("assert"), luaB_assert},
-  {l_s("getn"), luaB_getn},
-  {l_s("sort"), luaB_sort},
-  {l_s("tinsert"), luaB_tinsert},
-  {l_s("tremove"), luaB_tremove},
-  {l_s("unpack"), luaB_unpack},
-  {l_s("weakmode"), luaB_weakmode}
+  {LUA_ALERT, luaB__ALERT},
+  {LUA_ERRORMESSAGE, luaB__ERRORMESSAGE},
+  {"call", luaB_call},
+  {"collectgarbage", luaB_collectgarbage},
+  {"dofile", luaB_dofile},
+  {"dostring", luaB_dostring},
+  {"error", luaB_error},
+  {"foreach", luaB_foreach},
+  {"foreachi", luaB_foreachi},
+  {"gcinfo", luaB_gcinfo},
+  {"getglobal", luaB_getglobal},
+  {"gettagmethod", luaB_gettagmethod},
+  {"globals", luaB_globals},
+  {"loadfile", luaB_loadfile},
+  {"loadstring", luaB_loadstring},
+  {"newtype", luaB_newtype},
+  {"newtag", luaB_newtype},  /* for compatibility 4.0 */
+  {"next", luaB_next},
+  {"print", luaB_print},
+  {"rawget", luaB_rawget},
+  {"rawset", luaB_rawset},
+  {"rawgettable", luaB_rawget},  /* for compatibility 3.2 */
+  {"rawsettable", luaB_rawset},  /* for compatibility 3.2 */
+  {"rawtype", luaB_rawtype},
+  {"setglobal", luaB_setglobal},
+  {"settag", luaB_settype},  /* for compatibility 4.0 */
+  {"settype", luaB_settype},
+  {"settagmethod", luaB_settagmethod},
+  {"tag", luaB_tag},
+  {"tonumber", luaB_tonumber},
+  {"tostring", luaB_tostring},
+  {"type", luaB_type},
+  {"assert", luaB_assert},
+  {"getn", luaB_getn},
+  {"sort", luaB_sort},
+  {"tinsert", luaB_tinsert},
+  {"tremove", luaB_tremove},
+  {"unpack", luaB_unpack},
+  {"weakmode", luaB_weakmode}
 };
 };
 
 
 
 
 
 
 LUALIB_API int lua_baselibopen (lua_State *L) {
 LUALIB_API int lua_baselibopen (lua_State *L) {
   luaL_openl(L, base_funcs);
   luaL_openl(L, base_funcs);
-  lua_pushliteral(L, l_s(LUA_VERSION));
-  lua_setglobal(L, l_s("_VERSION"));
+  lua_pushliteral(L, LUA_VERSION);
+  lua_setglobal(L, "_VERSION");
   /* `require' needs an empty table as upvalue */
   /* `require' needs an empty table as upvalue */
   lua_newtable(L);
   lua_newtable(L);
   lua_pushcclosure(L, luaB_require, 1);
   lua_pushcclosure(L, luaB_require, 1);
-  lua_setglobal(L, l_s("require"));
+  lua_setglobal(L, "require");
   return 0;
   return 0;
 }
 }
 
 

+ 8 - 9
lcode.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lcode.c,v 1.79 2001/08/27 15:16:28 roberto Exp roberto $
+** $Id: lcode.c,v 1.82 2001/09/07 17:39:10 roberto Exp $
 ** Code generator for Lua
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lcode.h"
 #include "lcode.h"
@@ -27,7 +26,7 @@
 
 
 
 
 
 
-void luaK_error (LexState *ls, const l_char *msg) {
+void luaK_error (LexState *ls, const char *msg) {
   luaX_error(ls, msg, ls->t.token);
   luaX_error(ls, msg, ls->t.token);
 }
 }
 
 
@@ -83,7 +82,7 @@ static void luaK_fixjump (FuncState *fs, int pc, int dest) {
   else {  /* jump is relative to position following jump instruction */
   else {  /* jump is relative to position following jump instruction */
     int offset = dest-(pc+1);
     int offset = dest-(pc+1);
     if (abs(offset) > MAXARG_sBc)
     if (abs(offset) > MAXARG_sBc)
-      luaK_error(fs->ls, l_s("control structure too long"));
+      luaK_error(fs->ls, "control structure too long");
     SETARG_sBc(*jmp, offset);
     SETARG_sBc(*jmp, offset);
   }
   }
 }
 }
@@ -202,7 +201,7 @@ void luaK_reserveregs (FuncState *fs, int n) {
   fs->freereg += n;
   fs->freereg += n;
   if (fs->freereg > fs->f->maxstacksize) {
   if (fs->freereg > fs->f->maxstacksize) {
     if (fs->freereg >= MAXSTACK)
     if (fs->freereg >= MAXSTACK)
-      luaK_error(fs->ls, l_s("function or expression too complex"));
+      luaK_error(fs->ls, "function or expression too complex");
     fs->f->maxstacksize = cast(short, fs->freereg);
     fs->f->maxstacksize = cast(short, fs->freereg);
   }
   }
 }
 }
@@ -232,7 +231,7 @@ static int addk (FuncState *fs, TObject *k) {
     TObject o;
     TObject o;
     Proto *f = fs->f;
     Proto *f = fs->f;
     luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
     luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
-                    MAXARG_Bc, l_s("constant table overflow"));
+                    MAXARG_Bc, "constant table overflow");
     setobj(&f->k[fs->nk], k);
     setobj(&f->k[fs->nk], k);
     setnvalue(&o, fs->nk);
     setnvalue(&o, fs->nk);
     luaH_set(fs->L, fs->h, k, &o);
     luaH_set(fs->L, fs->h, k, &o);
@@ -771,11 +770,11 @@ static void codelineinfo (FuncState *fs) {
   if (ls->lastline > fs->lastline) {
   if (ls->lastline > fs->lastline) {
     if (ls->lastline > fs->lastline+1) {
     if (ls->lastline > fs->lastline+1) {
       luaM_growvector(fs->L, f->lineinfo, fs->nlineinfo, f->sizelineinfo, int,
       luaM_growvector(fs->L, f->lineinfo, fs->nlineinfo, f->sizelineinfo, int,
-                      MAX_INT, l_s("line info overflow"));
+                      MAX_INT, "line info overflow");
       f->lineinfo[fs->nlineinfo++] = -(ls->lastline - (fs->lastline+1));
       f->lineinfo[fs->nlineinfo++] = -(ls->lastline - (fs->lastline+1));
     }
     }
     luaM_growvector(fs->L, f->lineinfo, fs->nlineinfo, f->sizelineinfo, int,
     luaM_growvector(fs->L, f->lineinfo, fs->nlineinfo, f->sizelineinfo, int,
-                    MAX_INT, l_s("line info overflow"));
+                    MAX_INT, "line info overflow");
     f->lineinfo[fs->nlineinfo++] = fs->pc;
     f->lineinfo[fs->nlineinfo++] = fs->pc;
     fs->lastline = ls->lastline;
     fs->lastline = ls->lastline;
   }
   }
@@ -788,7 +787,7 @@ static int luaK_code (FuncState *fs, Instruction i) {
   f = fs->f;
   f = fs->f;
   /* put new instruction in code array */
   /* put new instruction in code array */
   luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
   luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction,
-                  MAX_INT, l_s("code size overflow"));
+                  MAX_INT, "code size overflow");
   f->code[fs->pc] = i;
   f->code[fs->pc] = i;
 /*printf("free: %d  ", fs->freereg); printopcode(f, fs->pc);*/
 /*printf("free: %d  ", fs->freereg); printopcode(f, fs->pc);*/
   return fs->pc++;
   return fs->pc++;

+ 2 - 2
lcode.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lcode.h,v 1.23 2001/06/12 14:36:48 roberto Exp roberto $
+** $Id: lcode.h,v 1.24 2001/07/24 17:19:07 roberto Exp $
 ** Code generator for Lua
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -38,7 +38,7 @@ typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr;
 
 
 #define luaK_codeAsBc(fs,o,A,sBc)	luaK_codeABc(fs,o,A,(sBc)+MAXARG_sBc)
 #define luaK_codeAsBc(fs,o,A,sBc)	luaK_codeABc(fs,o,A,(sBc)+MAXARG_sBc)
 
 
-void luaK_error (LexState *ls, const l_char *msg);
+void luaK_error (LexState *ls, const char *msg);
 int luaK_codeABc (FuncState *fs, OpCode o, int A, unsigned int Bc);
 int luaK_codeABc (FuncState *fs, OpCode o, int A, unsigned int Bc);
 int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
 int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
 void luaK_nil (FuncState *fs, int from, int n);
 void luaK_nil (FuncState *fs, int from, int n);

+ 35 - 36
ldblib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldblib.c,v 1.39 2001/10/17 21:12:57 roberto Exp $
+** $Id: ldblib.c,v 1.40 2001/10/26 17:33:30 roberto Exp $
 ** Interface from Lua to its debug API
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -9,7 +9,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
@@ -18,14 +17,14 @@
 
 
 
 
 
 
-static void settabss (lua_State *L, const l_char *i, const l_char *v) {
+static void settabss (lua_State *L, const char *i, const char *v) {
   lua_pushstring(L, i);
   lua_pushstring(L, i);
   lua_pushstring(L, v);
   lua_pushstring(L, v);
   lua_settable(L, -3);
   lua_settable(L, -3);
 }
 }
 
 
 
 
-static void settabsi (lua_State *L, const l_char *i, int v) {
+static void settabsi (lua_State *L, const char *i, int v) {
   lua_pushstring(L, i);
   lua_pushstring(L, i);
   lua_pushnumber(L, v);
   lua_pushnumber(L, v);
   lua_settable(L, -3);
   lua_settable(L, -3);
@@ -34,8 +33,8 @@ static void settabsi (lua_State *L, const l_char *i, int v) {
 
 
 static int getinfo (lua_State *L) {
 static int getinfo (lua_State *L) {
   lua_Debug ar;
   lua_Debug ar;
-  const l_char *options = luaL_opt_string(L, 2, l_s("flnSu"));
-  l_char buff[20];
+  const char *options = luaL_opt_string(L, 2, "flnSu");
+  char buff[20];
   if (lua_isnumber(L, 1)) {
   if (lua_isnumber(L, 1)) {
     if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) {
     if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) {
       lua_pushnil(L);  /* level out of range */
       lua_pushnil(L);  /* level out of range */
@@ -44,35 +43,35 @@ static int getinfo (lua_State *L) {
   }
   }
   else if (lua_isfunction(L, 1)) {
   else if (lua_isfunction(L, 1)) {
     lua_pushvalue(L, 1);
     lua_pushvalue(L, 1);
-    sprintf(buff, l_s(">%.10s"), options);
+    sprintf(buff, ">%.10s", options);
     options = buff;
     options = buff;
   }
   }
   else
   else
-    luaL_argerror(L, 1, l_s("function or level expected"));
+    luaL_argerror(L, 1, "function or level expected");
   if (!lua_getinfo(L, options, &ar))
   if (!lua_getinfo(L, options, &ar))
-    luaL_argerror(L, 2, l_s("invalid option"));
+    luaL_argerror(L, 2, "invalid option");
   lua_newtable(L);
   lua_newtable(L);
   for (; *options; options++) {
   for (; *options; options++) {
     switch (*options) {
     switch (*options) {
-      case l_c('S'):
-        settabss(L, l_s("source"), ar.source);
+      case 'S':
+        settabss(L, "source", ar.source);
         if (ar.source)
         if (ar.source)
-          settabss(L, l_s("short_src"), ar.short_src);
-        settabsi(L, l_s("linedefined"), ar.linedefined);
-        settabss(L, l_s("what"), ar.what);
+          settabss(L, "short_src", ar.short_src);
+        settabsi(L, "linedefined", ar.linedefined);
+        settabss(L, "what", ar.what);
         break;
         break;
-      case l_c('l'):
-        settabsi(L, l_s("currentline"), ar.currentline);
+      case 'l':
+        settabsi(L, "currentline", ar.currentline);
         break;
         break;
-      case l_c('u'):
-        settabsi(L, l_s("nups"), ar.nups);
+      case 'u':
+        settabsi(L, "nups", ar.nups);
         break;
         break;
-      case l_c('n'):
-        settabss(L, l_s("name"), ar.name);
-        settabss(L, l_s("namewhat"), ar.namewhat);
+      case 'n':
+        settabss(L, "name", ar.name);
+        settabss(L, "namewhat", ar.namewhat);
         break;
         break;
-      case l_c('f'):
-        lua_pushliteral(L, l_s("func"));
+      case 'f':
+        lua_pushliteral(L, "func");
         lua_pushvalue(L, -3);
         lua_pushvalue(L, -3);
         lua_settable(L, -3);
         lua_settable(L, -3);
         break;
         break;
@@ -84,9 +83,9 @@ static int getinfo (lua_State *L) {
 
 
 static int getlocal (lua_State *L) {
 static int getlocal (lua_State *L) {
   lua_Debug ar;
   lua_Debug ar;
-  const l_char *name;
+  const char *name;
   if (!lua_getstack(L, luaL_check_int(L, 1), &ar))  /* level out of range? */
   if (!lua_getstack(L, luaL_check_int(L, 1), &ar))  /* level out of range? */
-    luaL_argerror(L, 1, l_s("level out of range"));
+    luaL_argerror(L, 1, "level out of range");
   name = lua_getlocal(L, &ar, luaL_check_int(L, 2));
   name = lua_getlocal(L, &ar, luaL_check_int(L, 2));
   if (name) {
   if (name) {
     lua_pushstring(L, name);
     lua_pushstring(L, name);
@@ -103,7 +102,7 @@ static int getlocal (lua_State *L) {
 static int setlocal (lua_State *L) {
 static int setlocal (lua_State *L) {
   lua_Debug ar;
   lua_Debug ar;
   if (!lua_getstack(L, luaL_check_int(L, 1), &ar))  /* level out of range? */
   if (!lua_getstack(L, luaL_check_int(L, 1), &ar))  /* level out of range? */
-    luaL_argerror(L, 1, l_s("level out of range"));
+    luaL_argerror(L, 1, "level out of range");
   luaL_check_any(L, 3);
   luaL_check_any(L, 3);
   lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2)));
   lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2)));
   return 1;
   return 1;
@@ -111,11 +110,11 @@ static int setlocal (lua_State *L) {
 
 
 
 
 
 
-#define KEY_CALLHOOK	l_s("luadblibCallhook")
-#define KEY_LINEHOOK	l_s("luadblibLinehook")
+#define KEY_CALLHOOK	"luadblibCallhook"
+#define KEY_LINEHOOK	"luadblibLinehook"
 
 
 
 
-static void hookf (lua_State *L, const l_char *key) {
+static void hookf (lua_State *L, const char *key) {
   lua_pushstring(L, key);
   lua_pushstring(L, key);
   lua_gettable(L, LUA_REGISTRYINDEX);
   lua_gettable(L, LUA_REGISTRYINDEX);
   if (lua_isfunction(L, -1)) {
   if (lua_isfunction(L, -1)) {
@@ -139,7 +138,7 @@ static void linef (lua_State *L, lua_Debug *ar) {
 }
 }
 
 
 
 
-static void sethook (lua_State *L, const l_char *key, lua_Hook hook,
+static void sethook (lua_State *L, const char *key, lua_Hook hook,
                      lua_Hook (*sethookf)(lua_State * L, lua_Hook h)) {
                      lua_Hook (*sethookf)(lua_State * L, lua_Hook h)) {
   lua_settop(L, 1);
   lua_settop(L, 1);
   if (lua_isnil(L, 1))
   if (lua_isnil(L, 1))
@@ -147,7 +146,7 @@ static void sethook (lua_State *L, const l_char *key, lua_Hook hook,
   else if (lua_isfunction(L, 1))
   else if (lua_isfunction(L, 1))
     (*sethookf)(L, hook);
     (*sethookf)(L, hook);
   else
   else
-    luaL_argerror(L, 1, l_s("function expected"));
+    luaL_argerror(L, 1, "function expected");
   lua_pushstring(L, key);
   lua_pushstring(L, key);
   lua_gettable(L, LUA_REGISTRYINDEX);   /* get old value */
   lua_gettable(L, LUA_REGISTRYINDEX);   /* get old value */
   lua_pushstring(L, key);
   lua_pushstring(L, key);
@@ -169,11 +168,11 @@ static int setlinehook (lua_State *L) {
 
 
 
 
 static const luaL_reg dblib[] = {
 static const luaL_reg dblib[] = {
-  {l_s("getlocal"), getlocal},
-  {l_s("getinfo"), getinfo},
-  {l_s("setcallhook"), setcallhook},
-  {l_s("setlinehook"), setlinehook},
-  {l_s("setlocal"), setlocal}
+  {"getlocal", getlocal},
+  {"getinfo", getinfo},
+  {"setcallhook", setcallhook},
+  {"setlinehook", setlinehook},
+  {"setlocal", setlocal}
 };
 };
 
 
 
 

+ 43 - 44
ldebug.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldebug.c,v 1.91 2001/10/25 19:14:14 roberto Exp roberto $
+** $Id: ldebug.c,v 1.92 2001/10/31 19:58:11 roberto Exp $
 ** Debug Interface
 ** Debug Interface
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lapi.h"
 #include "lapi.h"
@@ -26,8 +25,8 @@
 
 
 
 
 
 
-static const l_char *getfuncname (lua_State *L, CallInfo *ci,
-                                  const l_char **name);
+static const char *getfuncname (lua_State *L, CallInfo *ci,
+                                  const char **name);
 
 
 
 
 
 
@@ -139,8 +138,8 @@ static Proto *getluaproto (CallInfo *ci) {
 }
 }
 
 
 
 
-LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
-  const l_char *name;
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
+  const char *name;
   CallInfo *ci;
   CallInfo *ci;
   Proto *fp;
   Proto *fp;
   lua_lock(L);
   lua_lock(L);
@@ -157,8 +156,8 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
 }
 }
 
 
 
 
-LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
-  const l_char *name;
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
+  const char *name;
   CallInfo *ci;
   CallInfo *ci;
   Proto *fp;
   Proto *fp;
   lua_lock(L);
   lua_lock(L);
@@ -168,7 +167,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
   L->top--;  /* pop new value */
   L->top--;  /* pop new value */
   if (fp) {  /* is a Lua function? */
   if (fp) {  /* is a Lua function? */
     name = luaF_getlocalname(fp, n, currentpc(ci));
     name = luaF_getlocalname(fp, n, currentpc(ci));
-    if (!name || name[0] == l_c('('))  /* `(' starts private locals */
+    if (!name || name[0] == '(')  /* `(' starts private locals */
       name = NULL;
       name = NULL;
     else
     else
       setobj(ci->base+(n-1), L->top);
       setobj(ci->base+(n-1), L->top);
@@ -181,7 +180,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
 static void infoLproto (lua_Debug *ar, Proto *f) {
 static void infoLproto (lua_Debug *ar, Proto *f) {
   ar->source = getstr(f->source);
   ar->source = getstr(f->source);
   ar->linedefined = f->lineDefined;
   ar->linedefined = f->lineDefined;
-  ar->what = l_s("Lua");
+  ar->what = "Lua";
 }
 }
 
 
 
 
@@ -190,23 +189,23 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) {
   if (ttype(func) == LUA_TFUNCTION)
   if (ttype(func) == LUA_TFUNCTION)
     cl = clvalue(func);
     cl = clvalue(func);
   else {
   else {
-    luaD_error(L, l_s("value for `lua_getinfo' is not a function"));
+    luaD_error(L, "value for `lua_getinfo' is not a function");
     cl = NULL;  /* to avoid warnings */
     cl = NULL;  /* to avoid warnings */
   }
   }
   if (cl->c.isC) {
   if (cl->c.isC) {
-    ar->source = l_s("=C");
+    ar->source = "=C";
     ar->linedefined = -1;
     ar->linedefined = -1;
-    ar->what = l_s("C");
+    ar->what = "C";
   }
   }
   else
   else
     infoLproto(ar, cl->l.p);
     infoLproto(ar, cl->l.p);
   luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
   luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
   if (ar->linedefined == 0)
   if (ar->linedefined == 0)
-    ar->what = l_s("main");
+    ar->what = "main";
 }
 }
 
 
 
 
-static const l_char *travtagmethods (global_State *G, const TObject *o) {
+static const char *travtagmethods (global_State *G, const TObject *o) {
   if (ttype(o) == LUA_TFUNCTION) {
   if (ttype(o) == LUA_TFUNCTION) {
     int e;
     int e;
     for (e=0; e<TM_N; e++) {
     for (e=0; e<TM_N; e++) {
@@ -220,7 +219,7 @@ static const l_char *travtagmethods (global_State *G, const TObject *o) {
 }
 }
 
 
 
 
-static const l_char *travglobals (lua_State *L, const TObject *o) {
+static const char *travglobals (lua_State *L, const TObject *o) {
   Table *g = hvalue(&L->gt);
   Table *g = hvalue(&L->gt);
   int i = sizenode(g);
   int i = sizenode(g);
   while (i--) {
   while (i--) {
@@ -235,20 +234,20 @@ static const l_char *travglobals (lua_State *L, const TObject *o) {
 static void getname (lua_State *L, const TObject *f, lua_Debug *ar) {
 static void getname (lua_State *L, const TObject *f, lua_Debug *ar) {
   /* try to find a name for given function */
   /* try to find a name for given function */
   if ((ar->name = travglobals(L, f)) != NULL)
   if ((ar->name = travglobals(L, f)) != NULL)
-    ar->namewhat = l_s("global");
+    ar->namewhat = "global";
   /* not found: try tag methods */
   /* not found: try tag methods */
   else if ((ar->name = travtagmethods(G(L), f)) != NULL)
   else if ((ar->name = travtagmethods(G(L), f)) != NULL)
-    ar->namewhat = l_s("tag-method");
-  else ar->namewhat = l_s("");  /* not found at all */
+    ar->namewhat = "tag-method";
+  else ar->namewhat = "";  /* not found at all */
 }
 }
 
 
 
 
-LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
   StkId f;
   StkId f;
   CallInfo *ci;
   CallInfo *ci;
   int status = 1;
   int status = 1;
   lua_lock(L);
   lua_lock(L);
-  if (*what != l_c('>')) {  /* function is active? */
+  if (*what != '>') {  /* function is active? */
     ci = ar->_ci;
     ci = ar->_ci;
     f = ci->base - 1;
     f = ci->base - 1;
   }
   }
@@ -259,25 +258,25 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) {
   }
   }
   for (; *what; what++) {
   for (; *what; what++) {
     switch (*what) {
     switch (*what) {
-      case l_c('S'): {
+      case 'S': {
         funcinfo(L, ar, f);
         funcinfo(L, ar, f);
         break;
         break;
       }
       }
-      case l_c('l'): {
+      case 'l': {
         ar->currentline = currentline(ci);
         ar->currentline = currentline(ci);
         break;
         break;
       }
       }
-      case l_c('u'): {
+      case 'u': {
         ar->nups = (ttype(f) == LUA_TFUNCTION) ? clvalue(f)->c.nupvalues : 0;
         ar->nups = (ttype(f) == LUA_TFUNCTION) ? clvalue(f)->c.nupvalues : 0;
         break;
         break;
       }
       }
-      case l_c('n'): {
+      case 'n': {
         ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
         ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
         if (ar->namewhat == NULL)
         if (ar->namewhat == NULL)
           getname(L, f, ar);
           getname(L, f, ar);
         break;
         break;
       }
       }
-      case l_c('f'): {
+      case 'f': {
         setobj(L->top, f);
         setobj(L->top, f);
         incr_top;  /* push function */
         incr_top;  /* push function */
         break;
         break;
@@ -470,7 +469,7 @@ int luaG_checkcode (const Proto *pt) {
 }
 }
 
 
 
 
-static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
+static const char *getobjname (lua_State *L, StkId obj, const char **name) {
   CallInfo *ci = ci_stack(L, obj);
   CallInfo *ci = ci_stack(L, obj);
   if (isLmark(ci)) {  /* an active Lua function? */
   if (isLmark(ci)) {  /* an active Lua function? */
     Proto *p = ci_func(ci)->l.p;
     Proto *p = ci_func(ci)->l.p;
@@ -479,14 +478,14 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
     Instruction i;
     Instruction i;
     *name = luaF_getlocalname(p, stackpos+1, pc);
     *name = luaF_getlocalname(p, stackpos+1, pc);
     if (*name)  /* is a local? */
     if (*name)  /* is a local? */
-      return l_s("local");
+      return "local";
     i = luaG_symbexec(p, pc, stackpos);  /* try symbolic execution */
     i = luaG_symbexec(p, pc, stackpos);  /* try symbolic execution */
     lua_assert(pc != -1);
     lua_assert(pc != -1);
     switch (GET_OPCODE(i)) {
     switch (GET_OPCODE(i)) {
       case OP_GETGLOBAL: {
       case OP_GETGLOBAL: {
         lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING);
         lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING);
         *name = svalue(&p->k[GETARG_Bc(i)]);
         *name = svalue(&p->k[GETARG_Bc(i)]);
-        return l_s("global");
+        return "global";
       }
       }
       case OP_MOVE: {
       case OP_MOVE: {
         int a = GETARG_A(i);
         int a = GETARG_A(i);
@@ -500,7 +499,7 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
         int c = GETARG_C(i) - MAXSTACK;
         int c = GETARG_C(i) - MAXSTACK;
         if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) {
         if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) {
           *name = svalue(&p->k[c]);
           *name = svalue(&p->k[c]);
-          return l_s("field");
+          return "field";
         }
         }
         break;
         break;
       }
       }
@@ -511,8 +510,8 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) {
 }
 }
 
 
 
 
-static const l_char *getfuncname (lua_State *L, CallInfo *ci,
-                                  const l_char **name) {
+static const char *getfuncname (lua_State *L, CallInfo *ci,
+                                  const char **name) {
   ci = ci->prev;  /* calling function */
   ci = ci->prev;  /* calling function */
   if (ci == &L->basefunc || !isLmark(ci))
   if (ci == &L->basefunc || !isLmark(ci))
     return NULL;  /* not an active Lua function */
     return NULL;  /* not an active Lua function */
@@ -529,22 +528,22 @@ static const l_char *getfuncname (lua_State *L, CallInfo *ci,
 }
 }
 
 
 
 
-void luaG_typeerror (lua_State *L, StkId o, const l_char *op) {
-  const l_char *name;
-  const l_char *kind = getobjname(L, o, &name);
-  const l_char *t = luaT_typename(G(L), o);
+void luaG_typeerror (lua_State *L, StkId o, const char *op) {
+  const char *name;
+  const char *kind = getobjname(L, o, &name);
+  const char *t = luaT_typename(G(L), o);
   if (kind)
   if (kind)
-    luaO_verror(L, l_s("attempt to %.30s %.20s `%.40s' (a %.10s value)"),
+    luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)",
                 op, kind, name, t);
                 op, kind, name, t);
   else
   else
-    luaO_verror(L, l_s("attempt to %.30s a %.10s value"), op, t);
+    luaO_verror(L, "attempt to %.30s a %.10s value", op, t);
 }
 }
 
 
 
 
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
   if (ttype(p1) == LUA_TSTRING) p1 = p2;
   if (ttype(p1) == LUA_TSTRING) p1 = p2;
   lua_assert(ttype(p1) != LUA_TSTRING);
   lua_assert(ttype(p1) != LUA_TSTRING);
-  luaG_typeerror(L, p1, l_s("concat"));
+  luaG_typeerror(L, p1, "concat");
 }
 }
 
 
 
 
@@ -552,16 +551,16 @@ void luaG_aritherror (lua_State *L, StkId p1, TObject *p2) {
   TObject temp;
   TObject temp;
   if (luaV_tonumber(p1, &temp) != NULL)
   if (luaV_tonumber(p1, &temp) != NULL)
     p1 = p2;  /* first operand is OK; error is in the second */
     p1 = p2;  /* first operand is OK; error is in the second */
-  luaG_typeerror(L, p1, l_s("perform arithmetic on"));
+  luaG_typeerror(L, p1, "perform arithmetic on");
 }
 }
 
 
 
 
 void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
 void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
-  const l_char *t1 = luaT_typename(G(L), p1);
-  const l_char *t2 = luaT_typename(G(L), p2);
+  const char *t1 = luaT_typename(G(L), p1);
+  const char *t2 = luaT_typename(G(L), p2);
   if (t1[2] == t2[2])
   if (t1[2] == t2[2])
-    luaO_verror(L, l_s("attempt to compare two %.10s values"), t1);
+    luaO_verror(L, "attempt to compare two %.10s values", t1);
   else
   else
-    luaO_verror(L, l_s("attempt to compare %.10s with %.10s"), t1, t2);
+    luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2);
 }
 }
 
 

+ 2 - 2
ldebug.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldebug.h,v 1.14 2001/06/11 14:56:42 roberto Exp roberto $
+** $Id: ldebug.h,v 1.15 2001/06/28 19:58:57 roberto Exp $
 ** Auxiliary functions from Debug Interface module
 ** Auxiliary functions from Debug Interface module
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -12,7 +12,7 @@
 #include "luadebug.h"
 #include "luadebug.h"
 
 
 
 
-void luaG_typeerror (lua_State *L, StkId o, const l_char *op);
+void luaG_typeerror (lua_State *L, StkId o, const char *op);
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
 void luaG_aritherror (lua_State *L, StkId p1, TObject *p2);
 void luaG_aritherror (lua_State *L, StkId p1, TObject *p2);
 int luaG_getline (int *lineinfo, int pc, int refline, int *refi);
 int luaG_getline (int *lineinfo, int pc, int refline, int *refi);

+ 19 - 20
ldo.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldo.c,v 1.143 2001/10/17 21:12:57 roberto Exp $
+** $Id: ldo.c,v 1.144 2001/11/27 20:56:47 roberto Exp $
 ** Stack and Call structure of Lua
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldebug.h"
 #include "ldebug.h"
@@ -58,7 +57,7 @@ void luaD_stackerror (lua_State *L) {
   else {
   else {
     L->stack_last += EXTRA_STACK;  /* to be used by error message */
     L->stack_last += EXTRA_STACK;  /* to be used by error message */
     lua_assert(L->stack_last == L->stack+L->stacksize-1);
     lua_assert(L->stack_last == L->stack+L->stacksize-1);
-    luaD_error(L, l_s("stack overflow"));
+    luaD_error(L, "stack overflow");
   }
   }
 }
 }
 
 
@@ -99,7 +98,7 @@ static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
 void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) {
 void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) {
   if (L->allowhooks) {
   if (L->allowhooks) {
     lua_Debug ar;
     lua_Debug ar;
-    ar.event = l_s("line");
+    ar.event = "line";
     ar._ci = L->ci;
     ar._ci = L->ci;
     ar.currentline = line;
     ar.currentline = line;
     dohook(L, &ar, linehook);
     dohook(L, &ar, linehook);
@@ -108,7 +107,7 @@ void luaD_lineHook (lua_State *L, int line, lua_Hook linehook) {
 
 
 
 
 static void luaD_callHook (lua_State *L, lua_Hook callhook,
 static void luaD_callHook (lua_State *L, lua_Hook callhook,
-                           const l_char *event) {
+                           const char *event) {
   if (L->allowhooks) {
   if (L->allowhooks) {
     lua_Debug ar;
     lua_Debug ar;
     ar.event = event;
     ar.event = event;
@@ -146,7 +145,7 @@ void luaD_call (lua_State *L, StkId func) {
     /* `func' is not a function; check the `function' tag method */
     /* `func' is not a function; check the `function' tag method */
     Closure *tm = luaT_gettmbyObj(G(L), func, TM_FUNCTION);
     Closure *tm = luaT_gettmbyObj(G(L), func, TM_FUNCTION);
     if (tm == NULL)
     if (tm == NULL)
-      luaG_typeerror(L, func, l_s("call"));
+      luaG_typeerror(L, func, "call");
     luaD_openstack(L, func);
     luaD_openstack(L, func);
     setclvalue(func, tm);  /* tag method is the new function to be called */
     setclvalue(func, tm);  /* tag method is the new function to be called */
   }
   }
@@ -155,12 +154,12 @@ void luaD_call (lua_State *L, StkId func) {
   ci.base = func+1;
   ci.base = func+1;
   callhook = L->callhook;
   callhook = L->callhook;
   if (callhook)
   if (callhook)
-    luaD_callHook(L, callhook, l_s("call"));
+    luaD_callHook(L, callhook, "call");
   firstResult = (clvalue(func)->c.isC ?
   firstResult = (clvalue(func)->c.isC ?
                         callCclosure(L, &clvalue(func)->c) :
                         callCclosure(L, &clvalue(func)->c) :
                         luaV_execute(L, &clvalue(func)->l, func+1));
                         luaV_execute(L, &clvalue(func)->l, func+1));
   if (callhook)  /* same hook that was active at entry */
   if (callhook)  /* same hook that was active at entry */
-    luaD_callHook(L, callhook, l_s("return"));
+    luaD_callHook(L, callhook, "return");
   L->ci = ci.prev;  /* unchain callinfo */
   L->ci = ci.prev;  /* unchain callinfo */
   /* move results to `func' (to erase parameters and function) */
   /* move results to `func' (to erase parameters and function) */
   while (firstResult < L->top)
   while (firstResult < L->top)
@@ -245,21 +244,21 @@ static int protectedparser (lua_State *L, ZIO *z, int bin) {
 }
 }
 
 
 
 
-LUA_API int lua_loadfile (lua_State *L, const l_char *filename) {
+LUA_API int lua_loadfile (lua_State *L, const char *filename) {
   ZIO z;
   ZIO z;
   int status;
   int status;
   int bin;  /* flag for file mode */
   int bin;  /* flag for file mode */
   int nlevel;  /* level on the stack of filename */
   int nlevel;  /* level on the stack of filename */
-  FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r"));
+  FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
   if (f == NULL) return LUA_ERRFILE;  /* unable to open file */
   if (f == NULL) return LUA_ERRFILE;  /* unable to open file */
   bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
   bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
   if (bin && f != stdin) {
   if (bin && f != stdin) {
     fclose(f);
     fclose(f);
-    f = fopen(filename, l_s("rb"));  /* reopen in binary mode */
+    f = fopen(filename, "rb");  /* reopen in binary mode */
     if (f == NULL) return LUA_ERRFILE;  /* unable to reopen file */
     if (f == NULL) return LUA_ERRFILE;  /* unable to reopen file */
   }
   }
-  lua_pushliteral(L, l_s("@"));
-  lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename);
+  lua_pushliteral(L, "@");
+  lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename);
   lua_concat(L, 2);
   lua_concat(L, 2);
   nlevel = lua_gettop(L);
   nlevel = lua_gettop(L);
   filename = lua_tostring(L, -1);  /* filename = `@'..filename */
   filename = lua_tostring(L, -1);  /* filename = `@'..filename */
@@ -272,11 +271,11 @@ LUA_API int lua_loadfile (lua_State *L, const l_char *filename) {
 }
 }
 
 
 
 
-LUA_API int lua_loadbuffer (lua_State *L, const l_char *buff, size_t size,
-                          const l_char *name) {
+LUA_API int lua_loadbuffer (lua_State *L, const char *buff, size_t size,
+                          const char *name) {
   ZIO z;
   ZIO z;
   int status;
   int status;
-  if (!name) name = l_s("?");
+  if (!name) name = "?";
   luaZ_mopen(&z, buff, size, name);
   luaZ_mopen(&z, buff, size, name);
   status = protectedparser(L, &z, buff[0]==LUA_SIGNATURE[0]);
   status = protectedparser(L, &z, buff[0]==LUA_SIGNATURE[0]);
   return status;
   return status;
@@ -301,9 +300,9 @@ struct lua_longjmp {
 };
 };
 
 
 
 
-static void message (lua_State *L, const l_char *s) {
+static void message (lua_State *L, const char *s) {
   StkId top = L->top;
   StkId top = L->top;
-  luaV_getglobal(L, luaS_newliteral(L, l_s(LUA_ERRORMESSAGE)), top);
+  luaV_getglobal(L, luaS_newliteral(L, LUA_ERRORMESSAGE), top);
   if (ttype(top) == LUA_TFUNCTION) {
   if (ttype(top) == LUA_TFUNCTION) {
     incr_top;
     incr_top;
     setsvalue(top+1, luaS_new(L, s));
     setsvalue(top+1, luaS_new(L, s));
@@ -317,7 +316,7 @@ static void message (lua_State *L, const l_char *s) {
 /*
 /*
 ** Reports an error, and jumps up to the available recovery label
 ** Reports an error, and jumps up to the available recovery label
 */
 */
-void luaD_error (lua_State *L, const l_char *s) {
+void luaD_error (lua_State *L, const char *s) {
   if (s) message(L, s);
   if (s) message(L, s);
   luaD_breakrun(L, LUA_ERRRUN);
   luaD_breakrun(L, LUA_ERRRUN);
 }
 }
@@ -330,7 +329,7 @@ void luaD_breakrun (lua_State *L, int errcode) {
   }
   }
   else {
   else {
     if (errcode != LUA_ERRMEM)
     if (errcode != LUA_ERRMEM)
-      message(L, l_s("unable to recover; exiting\n"));
+      message(L, "unable to recover; exiting\n");
     exit(EXIT_FAILURE);
     exit(EXIT_FAILURE);
   }
   }
 }
 }

+ 2 - 2
ldo.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ldo.h,v 1.33 2001/06/05 19:41:24 roberto Exp roberto $
+** $Id: ldo.h,v 1.34 2001/06/08 19:00:57 roberto Exp $
 ** Stack and Call structure of Lua
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -28,7 +28,7 @@ void luaD_lineHook (lua_State *L, int line, lua_Hook linehook);
 void luaD_call (lua_State *L, StkId func);
 void luaD_call (lua_State *L, StkId func);
 void luaD_stackerror (lua_State *L);
 void luaD_stackerror (lua_State *L);
 
 
-void luaD_error (lua_State *L, const l_char *s);
+void luaD_error (lua_State *L, const char *s);
 void luaD_breakrun (lua_State *L, int errcode);
 void luaD_breakrun (lua_State *L, int errcode);
 int luaD_runprotected (lua_State *L, void (*f)(lua_State *, void *), void *ud);
 int luaD_runprotected (lua_State *L, void (*f)(lua_State *, void *), void *ud);
 
 

+ 2 - 3
lfunc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lfunc.c,v 1.48 2001/10/02 16:45:03 roberto Exp $
+** $Id: lfunc.c,v 1.49 2001/11/06 21:41:53 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lfunc.h"
 #include "lfunc.h"
@@ -157,7 +156,7 @@ void luaF_freeclosure (lua_State *L, Closure *c) {
 ** Look for n-th local variable at line `line' in function `func'.
 ** Look for n-th local variable at line `line' in function `func'.
 ** Returns NULL if not found.
 ** Returns NULL if not found.
 */
 */
-const l_char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
+const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
   int i;
   int i;
   for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
   for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
     if (pc < f->locvars[i].endpc) {  /* is variable active? */
     if (pc < f->locvars[i].endpc) {  /* is variable active? */

+ 2 - 2
lfunc.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lfunc.h,v 1.16 2001/09/07 17:39:10 roberto Exp $
+** $Id: lfunc.h,v 1.17 2001/10/02 16:45:03 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -19,7 +19,7 @@ void luaF_close (lua_State *L, StkId level);
 void luaF_freeproto (lua_State *L, Proto *f);
 void luaF_freeproto (lua_State *L, Proto *f);
 void luaF_freeclosure (lua_State *L, Closure *c);
 void luaF_freeclosure (lua_State *L, Closure *c);
 
 
-const l_char *luaF_getlocalname (const Proto *func, int local_number, int pc);
+const char *luaF_getlocalname (const Proto *func, int local_number, int pc);
 
 
 
 
 #endif
 #endif

+ 2 - 3
lgc.c

@@ -1,10 +1,9 @@
 /*
 /*
-** $Id: lgc.c,v 1.115 2001/10/31 19:58:11 roberto Exp $
+** $Id: lgc.c,v 1.116 2001/11/06 21:41:53 roberto Exp $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldebug.h"
 #include "ldebug.h"
@@ -352,7 +351,7 @@ static void collectstrings (lua_State *L, int all) {
 static void checkMbuffer (lua_State *L) {
 static void checkMbuffer (lua_State *L) {
   if (G(L)->Mbuffsize > MINBUFFER*2) {  /* is buffer too big? */
   if (G(L)->Mbuffsize > MINBUFFER*2) {  /* is buffer too big? */
     size_t newsize = G(L)->Mbuffsize/2;  /* still larger than MINBUFFER */
     size_t newsize = G(L)->Mbuffsize/2;  /* still larger than MINBUFFER */
-    luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, newsize, l_char);
+    luaM_reallocvector(L, G(L)->Mbuffer, G(L)->Mbuffsize, newsize, char);
     G(L)->Mbuffsize = newsize;
     G(L)->Mbuffsize = newsize;
   }
   }
 }
 }

+ 122 - 123
liolib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: liolib.c,v 1.123 2001/10/02 16:41:36 roberto Exp $
+** $Id: liolib.c,v 1.124 2001/10/26 17:33:30 roberto Exp $
 ** Standard I/O (and system) library
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -10,7 +10,6 @@
 #include <string.h>
 #include <string.h>
 #include <time.h>
 #include <time.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
@@ -40,12 +39,12 @@ int pclose(); */
 #define OUTFILE 1
 #define OUTFILE 1
 #define NOFILE	2
 #define NOFILE	2
 
 
-#define FILEHANDLE		l_s("FileHandle")
-#define CLOSEDFILEHANDLE	l_s("ClosedFileHandle")
+#define FILEHANDLE		"FileHandle"
+#define CLOSEDFILEHANDLE	"ClosedFileHandle"
 
 
 
 
-static const l_char *const filenames[] = {l_s("_INPUT"), l_s("_OUTPUT")};
-static const l_char *const basicfiles[] = {l_s("_STDIN"), l_s("_STDOUT")};
+static const char *const filenames[] = {"_INPUT", "_OUTPUT"};
+static const char *const basicfiles[] = {"_STDIN", "_STDOUT"};
 
 
 
 
 static int pushresult (lua_State *L, int i) {
 static int pushresult (lua_State *L, int i) {
@@ -77,16 +76,16 @@ static FILE *getopthandle (lua_State *L, int inout) {
   if (p != NULL) {  /* is it a userdata ? */
   if (p != NULL) {  /* is it a userdata ? */
     if (!checkfile(L, 1)) {  /* not a valid file handle? */
     if (!checkfile(L, 1)) {  /* not a valid file handle? */
       if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0)
       if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0)
-        luaL_argerror(L, 1, l_s("file is closed"));
+        luaL_argerror(L, 1, "file is closed");
       else
       else
-        luaL_argerror(L, 1, l_s("(invalid value)"));
+        luaL_argerror(L, 1, "(invalid value)");
     }
     }
     lua_pushvalue(L, 1); lua_remove(L, 1);  /* move it to stack top */
     lua_pushvalue(L, 1); lua_remove(L, 1);  /* move it to stack top */
   }
   }
   else {  /* try global value */
   else {  /* try global value */
     lua_getglobal(L, filenames[inout]);
     lua_getglobal(L, filenames[inout]);
     if (!checkfile(L,-1))
     if (!checkfile(L,-1))
-      luaL_verror(L, l_s("global variable `%.10s' is not a valid file handle"),
+      luaL_verror(L, "global variable `%.10s' is not a valid file handle",
                   filenames[inout]);
                   filenames[inout]);
     p = (FILE *)(lua_touserdata(L, -1));
     p = (FILE *)(lua_touserdata(L, -1));
   }
   }
@@ -100,7 +99,7 @@ static void newfile (lua_State *L, FILE *f) {
 }
 }
 
 
 
 
-static void newfilewithname (lua_State *L, FILE *f, const l_char *name) {
+static void newfilewithname (lua_State *L, FILE *f, const char *name) {
   newfile(L, f);
   newfile(L, f);
   lua_setglobal(L, name);
   lua_setglobal(L, name);
 }
 }
@@ -158,7 +157,7 @@ static int io_tmpfile (lua_State *L) {
 
 
 
 
 
 
-static int io_fromto (lua_State *L, int inout, const l_char *mode) {
+static int io_fromto (lua_State *L, int inout, const char *mode) {
   FILE *current;
   FILE *current;
   if (lua_isnull(L, 1)) {
   if (lua_isnull(L, 1)) {
     getopthandle(L, inout);
     getopthandle(L, inout);
@@ -166,25 +165,25 @@ static int io_fromto (lua_State *L, int inout, const l_char *mode) {
     return io_close(L);
     return io_close(L);
   }
   }
   else {
   else {
-    const l_char *s = luaL_check_string(L, 1);
-    current = (*s == l_c('|')) ? popen(s+1, mode) : fopen(s, mode);
+    const char *s = luaL_check_string(L, 1);
+    current = (*s == '|') ? popen(s+1, mode) : fopen(s, mode);
     return setnewfile(L, current, inout);
     return setnewfile(L, current, inout);
   }
   }
 }
 }
 
 
 
 
 static int io_readfrom (lua_State *L) {
 static int io_readfrom (lua_State *L) {
-  return io_fromto(L, INFILE, l_s("r"));
+  return io_fromto(L, INFILE, "r");
 }
 }
 
 
 
 
 static int io_writeto (lua_State *L) {
 static int io_writeto (lua_State *L) {
-  return io_fromto(L, OUTFILE, l_s("w"));
+  return io_fromto(L, OUTFILE, "w");
 }
 }
 
 
 
 
 static int io_appendto (lua_State *L) {
 static int io_appendto (lua_State *L) {
-  FILE *current = fopen(luaL_check_string(L, 1), l_s("a"));
+  FILE *current = fopen(luaL_check_string(L, 1), "a");
   return setnewfile(L, current, OUTFILE);
   return setnewfile(L, current, OUTFILE);
 }
 }
 
 
@@ -208,7 +207,7 @@ static int io_appendto (lua_State *L) {
 **  Addison-Wesley, 1993.)
 **  Addison-Wesley, 1993.)
 */
 */
 
 
-static void prep_read_until (int next[], const l_char *p, int pl) {
+static void prep_read_until (int next[], const char *p, int pl) {
   int i = 0;
   int i = 0;
   int j = -1;
   int j = -1;
   next[0] = -1;
   next[0] = -1;
@@ -221,8 +220,8 @@ static void prep_read_until (int next[], const l_char *p, int pl) {
 }
 }
 
 
 
 
-static int read_until (lua_State *L, FILE *f, const l_char *p, int pl) {
-  l_charint c;
+static int read_until (lua_State *L, FILE *f, const char *p, int pl) {
+  int c;
   int j;
   int j;
   int next[LUA_MAXUNTIL+1];
   int next[LUA_MAXUNTIL+1];
   luaL_Buffer b;
   luaL_Buffer b;
@@ -255,7 +254,7 @@ static int read_until (lua_State *L, FILE *f, const l_char *p, int pl) {
 
 
 static int read_number (lua_State *L, FILE *f) {
 static int read_number (lua_State *L, FILE *f) {
   lua_Number d;
   lua_Number d;
-  if (fscanf(f, l_s(LUA_NUMBER_SCAN), &d) == 1) {
+  if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
     lua_pushnumber(L, d);
     lua_pushnumber(L, d);
     return 1;
     return 1;
   }
   }
@@ -264,7 +263,7 @@ static int read_number (lua_State *L, FILE *f) {
 
 
 
 
 static int test_eof (lua_State *L, FILE *f) {
 static int test_eof (lua_State *L, FILE *f) {
-  l_charint c = getc(f);
+  int c = getc(f);
   ungetc(c, f);
   ungetc(c, f);
   lua_pushlstring(L, NULL, 0);
   lua_pushlstring(L, NULL, 0);
   return (c != EOF);
   return (c != EOF);
@@ -278,9 +277,9 @@ static int read_chars (lua_State *L, FILE *f, size_t n) {
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   rlen = LUAL_BUFFERSIZE;  /* try to read that much each time */
   rlen = LUAL_BUFFERSIZE;  /* try to read that much each time */
   do {
   do {
-    l_char *p = luaL_prepbuffer(&b);
+    char *p = luaL_prepbuffer(&b);
     if (rlen > n) rlen = n;  /* cannot read more than asked */
     if (rlen > n) rlen = n;  /* cannot read more than asked */
-    nr = fread(p, sizeof(l_char), rlen, f);
+    nr = fread(p, sizeof(char), rlen, f);
     luaL_addsize(&b, nr);
     luaL_addsize(&b, nr);
     n -= nr;  /* still have to read `n' chars */
     n -= nr;  /* still have to read `n' chars */
   } while (n > 0 && nr == rlen);  /* until end of count or eof */
   } while (n > 0 && nr == rlen);  /* until end of count or eof */
@@ -295,11 +294,11 @@ static int io_read (lua_State *L) {
   int success;
   int success;
   int n;
   int n;
   if (nargs == 0) {  /* no arguments? */
   if (nargs == 0) {  /* no arguments? */
-    success = read_until(L, f, l_s("\n"), 1);  /* read until \n (a line) */
+    success = read_until(L, f, "\n", 1);  /* read until \n (a line) */
     n = 2;  /* will return n-1 results */
     n = 2;  /* will return n-1 results */
   }
   }
   else {  /* ensure stack space for all results and for auxlib's buffer */
   else {  /* ensure stack space for all results and for auxlib's buffer */
-    luaL_check_stack(L, nargs+LUA_MINSTACK, l_s("too many arguments"));
+    luaL_check_stack(L, nargs+LUA_MINSTACK, "too many arguments");
     success = 1;
     success = 1;
     for (n = 1; n<=nargs && success; n++) {
     for (n = 1; n<=nargs && success; n++) {
       if (lua_rawtag(L, n) == LUA_TNUMBER) {
       if (lua_rawtag(L, n) == LUA_TNUMBER) {
@@ -307,32 +306,32 @@ static int io_read (lua_State *L) {
         success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
         success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
       }
       }
       else {
       else {
-        const l_char *p = lua_tostring(L, n);
-        if (!p || p[0] != l_c('*'))
-          lua_error(L, l_s("invalid `read' option"));
+        const char *p = lua_tostring(L, n);
+        if (!p || p[0] != '*')
+          lua_error(L, "invalid `read' option");
         switch (p[1]) {
         switch (p[1]) {
-          case l_c('n'):  /* number */
+          case 'n':  /* number */
             success = read_number(L, f);
             success = read_number(L, f);
             break;
             break;
-          case l_c('l'):  /* line */
-            success = read_until(L, f, l_s("\n"), 1);  /* read until \n */
+          case 'l':  /* line */
+            success = read_until(L, f, "\n", 1);  /* read until \n */
             break;
             break;
-          case l_c('a'):  /* file */
+          case 'a':  /* file */
             read_chars(L, f, ~((size_t)0));  /* read MAX_SIZE_T chars */
             read_chars(L, f, ~((size_t)0));  /* read MAX_SIZE_T chars */
             success = 1; /* always success */
             success = 1; /* always success */
             break;
             break;
-          case l_c('w'):  /* word */
-            lua_error(L, l_s("obsolete option `*w'"));
+          case 'w':  /* word */
+            lua_error(L, "obsolete option `*w'");
             break;
             break;
-          case l_c('u'): {  /* read until */
+          case 'u': {  /* read until */
             size_t pl = lua_strlen(L, n) - 2;
             size_t pl = lua_strlen(L, n) - 2;
             luaL_arg_check(L, 0 < pl && pl <= LUA_MAXUNTIL, n,
             luaL_arg_check(L, 0 < pl && pl <= LUA_MAXUNTIL, n,
-                              l_s("invalid read-until length"));
+                              "invalid read-until length");
             success = read_until(L, f, p+2, (int)(pl));
             success = read_until(L, f, p+2, (int)(pl));
             break;
             break;
           }
           }
           default:
           default:
-            luaL_argerror(L, n, l_s("invalid format"));
+            luaL_argerror(L, n, "invalid format");
             success = 0;  /* to avoid warnings */
             success = 0;  /* to avoid warnings */
         }
         }
       }
       }
@@ -357,12 +356,12 @@ static int io_write (lua_State *L) {
     if (lua_rawtag(L, arg) == LUA_TNUMBER) {
     if (lua_rawtag(L, arg) == LUA_TNUMBER) {
       /* optimization: could be done exactly as for strings */
       /* optimization: could be done exactly as for strings */
       status = status &&
       status = status &&
-          fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0;
+          fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
     }
     }
     else {
     else {
       size_t l;
       size_t l;
-      const l_char *s = luaL_check_lstr(L, arg, &l);
-      status = status && (fwrite(s, sizeof(l_char), l, f) == l);
+      const char *s = luaL_check_lstr(L, arg, &l);
+      status = status && (fwrite(s, sizeof(char), l, f) == l);
     }
     }
   }
   }
   pushresult(L, status);
   pushresult(L, status);
@@ -372,11 +371,11 @@ static int io_write (lua_State *L) {
 
 
 static int io_seek (lua_State *L) {
 static int io_seek (lua_State *L) {
   static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
   static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
-  static const l_char *const modenames[] = {l_s("set"), l_s("cur"), l_s("end"), NULL};
+  static const char *const modenames[] = {"set", "cur", "end", NULL};
   FILE *f = (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE));
   FILE *f = (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE));
-  int op = luaL_findstring(luaL_opt_string(L, 2, l_s("cur")), modenames);
+  int op = luaL_findstring(luaL_opt_string(L, 2, "cur"), modenames);
   long offset = luaL_opt_long(L, 3, 0);
   long offset = luaL_opt_long(L, 3, 0);
-  luaL_arg_check(L, op != -1, 2, l_s("invalid mode"));
+  luaL_arg_check(L, op != -1, 2, "invalid mode");
   op = fseek(f, offset, mode[op]);
   op = fseek(f, offset, mode[op]);
   if (op)
   if (op)
     return pushresult(L, 0);  /* error */
     return pushresult(L, 0);  /* error */
@@ -420,9 +419,9 @@ static int io_rename (lua_State *L) {
 
 
 
 
 static int io_tmpname (lua_State *L) {
 static int io_tmpname (lua_State *L) {
-  l_char buff[L_tmpnam];
+  char buff[L_tmpnam];
   if (tmpnam(buff) != buff)
   if (tmpnam(buff) != buff)
-    lua_error(L, l_s("unable to generate a unique filename"));
+    lua_error(L, "unable to generate a unique filename");
   lua_pushstring(L, buff);
   lua_pushstring(L, buff);
   return 1;
   return 1;
 }
 }
@@ -449,14 +448,14 @@ static int io_clock (lua_State *L) {
 ** =======================================================
 ** =======================================================
 */
 */
 
 
-static void setfield (lua_State *L, const l_char *key, int value) {
+static void setfield (lua_State *L, const char *key, int value) {
   lua_pushstring(L, key);
   lua_pushstring(L, key);
   lua_pushnumber(L, value);
   lua_pushnumber(L, value);
   lua_rawset(L, -3);
   lua_rawset(L, -3);
 }
 }
 
 
 
 
-static int getfield (lua_State *L, const l_char *key, int d) {
+static int getfield (lua_State *L, const char *key, int d) {
   int res;
   int res;
   lua_pushstring(L, key);
   lua_pushstring(L, key);
   lua_rawget(L, -2);
   lua_rawget(L, -2);
@@ -464,7 +463,7 @@ static int getfield (lua_State *L, const l_char *key, int d) {
     res = (int)(lua_tonumber(L, -1));
     res = (int)(lua_tonumber(L, -1));
   else {
   else {
     if (d == -2)
     if (d == -2)
-      luaL_verror(L, l_s("field `%.20s' missing in date table"), key);
+      luaL_verror(L, "field `%.20s' missing in date table", key);
     res = d;
     res = d;
   }
   }
   lua_pop(L, 1);
   lua_pop(L, 1);
@@ -473,12 +472,12 @@ static int getfield (lua_State *L, const l_char *key, int d) {
 
 
 
 
 static int io_date (lua_State *L) {
 static int io_date (lua_State *L) {
-  const l_char *s = luaL_opt_string(L, 1, l_s("%c"));
+  const char *s = luaL_opt_string(L, 1, "%c");
   time_t t = (time_t)(luaL_opt_number(L, 2, -1));
   time_t t = (time_t)(luaL_opt_number(L, 2, -1));
   struct tm *stm;
   struct tm *stm;
   if (t == (time_t)(-1))  /* no time given? */
   if (t == (time_t)(-1))  /* no time given? */
     t = time(NULL);  /* use current time */
     t = time(NULL);  /* use current time */
-  if (*s == l_c('!')) {  /* UTC? */
+  if (*s == '!') {  /* UTC? */
     stm = gmtime(&t);
     stm = gmtime(&t);
     s++;  /* skip `!' */
     s++;  /* skip `!' */
   }
   }
@@ -486,24 +485,24 @@ static int io_date (lua_State *L) {
     stm = localtime(&t);
     stm = localtime(&t);
   if (stm == NULL)  /* invalid date? */
   if (stm == NULL)  /* invalid date? */
     lua_pushnil(L);
     lua_pushnil(L);
-  else if (strcmp(s, l_s("*t")) == 0) {
+  else if (strcmp(s, "*t") == 0) {
     lua_newtable(L);
     lua_newtable(L);
-    setfield(L, l_s("sec"), stm->tm_sec);
-    setfield(L, l_s("min"), stm->tm_min);
-    setfield(L, l_s("hour"), stm->tm_hour);
-    setfield(L, l_s("day"), stm->tm_mday);
-    setfield(L, l_s("month"), stm->tm_mon+1);
-    setfield(L, l_s("year"), stm->tm_year+1900);
-    setfield(L, l_s("wday"), stm->tm_wday+1);
-    setfield(L, l_s("yday"), stm->tm_yday+1);
-    setfield(L, l_s("isdst"), stm->tm_isdst);
+    setfield(L, "sec", stm->tm_sec);
+    setfield(L, "min", stm->tm_min);
+    setfield(L, "hour", stm->tm_hour);
+    setfield(L, "day", stm->tm_mday);
+    setfield(L, "month", stm->tm_mon+1);
+    setfield(L, "year", stm->tm_year+1900);
+    setfield(L, "wday", stm->tm_wday+1);
+    setfield(L, "yday", stm->tm_yday+1);
+    setfield(L, "isdst", stm->tm_isdst);
   }
   }
   else {
   else {
-    l_char b[256];
+    char b[256];
     if (strftime(b, sizeof(b), s, stm))
     if (strftime(b, sizeof(b), s, stm))
       lua_pushstring(L, b);
       lua_pushstring(L, b);
     else
     else
-      lua_error(L, l_s("invalid `date' format"));
+      lua_error(L, "invalid `date' format");
   }
   }
   return 1;
   return 1;
 }
 }
@@ -517,13 +516,13 @@ static int io_time (lua_State *L) {
     struct tm ts;
     struct tm ts;
     luaL_check_rawtype(L, 1, LUA_TTABLE);
     luaL_check_rawtype(L, 1, LUA_TTABLE);
     lua_settop(L, 1);  /* make sure table is at the top */
     lua_settop(L, 1);  /* make sure table is at the top */
-    ts.tm_sec = getfield(L, l_s("sec"), 0);
-    ts.tm_min = getfield(L, l_s("min"), 0);
-    ts.tm_hour = getfield(L, l_s("hour"), 12);
-    ts.tm_mday = getfield(L, l_s("day"), -2);
-    ts.tm_mon = getfield(L, l_s("month"), -2)-1;
-    ts.tm_year = getfield(L, l_s("year"), -2)-1900;
-    ts.tm_isdst = getfield(L, l_s("isdst"), -1);
+    ts.tm_sec = getfield(L, "sec", 0);
+    ts.tm_min = getfield(L, "min", 0);
+    ts.tm_hour = getfield(L, "hour", 12);
+    ts.tm_mday = getfield(L, "day", -2);
+    ts.tm_mon = getfield(L, "month", -2)-1;
+    ts.tm_year = getfield(L, "year", -2)-1900;
+    ts.tm_isdst = getfield(L, "isdst", -1);
     t = mktime(&ts);
     t = mktime(&ts);
     if (t == (time_t)(-1))
     if (t == (time_t)(-1))
       lua_pushnil(L);
       lua_pushnil(L);
@@ -546,10 +545,10 @@ static int io_difftime (lua_State *L) {
 static int io_setloc (lua_State *L) {
 static int io_setloc (lua_State *L) {
   static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
   static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
                       LC_NUMERIC, LC_TIME};
                       LC_NUMERIC, LC_TIME};
-  static const l_char *const catnames[] = {l_s("all"), l_s("collate"), l_s("ctype"), l_s("monetary"),
-     l_s("numeric"), l_s("time"), NULL};
-  int op = luaL_findstring(luaL_opt_string(L, 2, l_s("all")), catnames);
-  luaL_arg_check(L, op != -1, 2, l_s("invalid option"));
+  static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
+     "numeric", "time", NULL};
+  int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames);
+  luaL_arg_check(L, op != -1, 2, "invalid option");
   lua_pushstring(L, setlocale(cat[op], luaL_check_string(L, 1)));
   lua_pushstring(L, setlocale(cat[op], luaL_check_string(L, 1)));
   return 1;
   return 1;
 }
 }
@@ -566,10 +565,10 @@ static int io_exit (lua_State *L) {
 
 
 static int io_debug (lua_State *L) {
 static int io_debug (lua_State *L) {
   for (;;) {
   for (;;) {
-    l_char buffer[250];
-    fprintf(stderr, l_s("lua_debug> "));
+    char buffer[250];
+    fprintf(stderr, "lua_debug> ");
     if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
     if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
-        strcmp(buffer, l_s("cont\n")) == 0)
+        strcmp(buffer, "cont\n") == 0)
       return 0;
       return 0;
     lua_dostring(L, buffer);
     lua_dostring(L, buffer);
     lua_settop(L, 0);  /* remove eventual returns */
     lua_settop(L, 0);  /* remove eventual returns */
@@ -586,61 +585,61 @@ static int errorfb (lua_State *L) {
   lua_Debug ar;
   lua_Debug ar;
   luaL_Buffer b;
   luaL_Buffer b;
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
-  luaL_addstring(&b, l_s("error: "));
+  luaL_addstring(&b, "error: ");
   luaL_addstring(&b, luaL_check_string(L, 1));
   luaL_addstring(&b, luaL_check_string(L, 1));
-  luaL_addstring(&b, l_s("\n"));
+  luaL_addstring(&b, "\n");
   while (lua_getstack(L, level++, &ar)) {
   while (lua_getstack(L, level++, &ar)) {
-    l_char buff[120];  /* enough to fit following `sprintf's */
+    char buff[120];  /* enough to fit following `sprintf's */
     if (level == 2)
     if (level == 2)
-      luaL_addstring(&b, l_s("stack traceback:\n"));
+      luaL_addstring(&b, "stack traceback:\n");
     else if (level > LEVELS1 && firstpart) {
     else if (level > LEVELS1 && firstpart) {
       /* no more than `LEVELS2' more levels? */
       /* no more than `LEVELS2' more levels? */
       if (!lua_getstack(L, level+LEVELS2, &ar))
       if (!lua_getstack(L, level+LEVELS2, &ar))
         level--;  /* keep going */
         level--;  /* keep going */
       else {
       else {
-        luaL_addstring(&b, l_s("       ...\n"));  /* too many levels */
+        luaL_addstring(&b, "       ...\n");  /* too many levels */
         while (lua_getstack(L, level+LEVELS2, &ar))  /* find last levels */
         while (lua_getstack(L, level+LEVELS2, &ar))  /* find last levels */
           level++;
           level++;
       }
       }
       firstpart = 0;
       firstpart = 0;
       continue;
       continue;
     }
     }
-    sprintf(buff, l_s("%4d:  "), level-1);
+    sprintf(buff, "%4d:  ", level-1);
     luaL_addstring(&b, buff);
     luaL_addstring(&b, buff);
-    lua_getinfo(L, l_s("Snl"), &ar);
+    lua_getinfo(L, "Snl", &ar);
     switch (*ar.namewhat) {
     switch (*ar.namewhat) {
-      case l_c('g'):  case l_c('l'):  /* global, local */
-        sprintf(buff, l_s("function `%.50s'"), ar.name);
+      case 'g':  case 'l':  /* global, local */
+        sprintf(buff, "function `%.50s'", ar.name);
         break;
         break;
-      case l_c('f'):  /* field */
-        sprintf(buff, l_s("method `%.50s'"), ar.name);
+      case 'f':  /* field */
+        sprintf(buff, "method `%.50s'", ar.name);
         break;
         break;
-      case l_c('t'):  /* tag method */
-        sprintf(buff, l_s("`%.50s' tag method"), ar.name);
+      case 't':  /* tag method */
+        sprintf(buff, "`%.50s' tag method", ar.name);
         break;
         break;
       default: {
       default: {
-        if (*ar.what == l_c('m'))  /* main? */
-          sprintf(buff, l_s("main of %.70s"), ar.short_src);
-        else if (*ar.what == l_c('C'))  /* C function? */
-          sprintf(buff, l_s("%.70s"), ar.short_src);
+        if (*ar.what == 'm')  /* main? */
+          sprintf(buff, "main of %.70s", ar.short_src);
+        else if (*ar.what == 'C')  /* C function? */
+          sprintf(buff, "%.70s", ar.short_src);
         else
         else
-          sprintf(buff, l_s("function <%d:%.70s>"), ar.linedefined, ar.short_src);
+          sprintf(buff, "function <%d:%.70s>", ar.linedefined, ar.short_src);
         ar.source = NULL;  /* do not print source again */
         ar.source = NULL;  /* do not print source again */
       }
       }
     }
     }
     luaL_addstring(&b, buff);
     luaL_addstring(&b, buff);
     if (ar.currentline > 0) {
     if (ar.currentline > 0) {
-      sprintf(buff, l_s(" at line %d"), ar.currentline);
+      sprintf(buff, " at line %d", ar.currentline);
       luaL_addstring(&b, buff);
       luaL_addstring(&b, buff);
     }
     }
     if (ar.source) {
     if (ar.source) {
-      sprintf(buff, l_s(" [%.70s]"), ar.short_src);
+      sprintf(buff, " [%.70s]", ar.short_src);
       luaL_addstring(&b, buff);
       luaL_addstring(&b, buff);
     }
     }
-    luaL_addstring(&b, l_s("\n"));
+    luaL_addstring(&b, "\n");
   }
   }
   luaL_pushresult(&b);
   luaL_pushresult(&b);
-  lua_getglobal(L, l_s(LUA_ALERT));
+  lua_getglobal(L, LUA_ALERT);
   if (lua_isfunction(L, -1)) {  /* avoid loop if _ALERT is not defined */
   if (lua_isfunction(L, -1)) {  /* avoid loop if _ALERT is not defined */
     lua_pushvalue(L, -2);  /* error message */
     lua_pushvalue(L, -2);  /* error message */
     lua_rawcall(L, 1, 0);
     lua_rawcall(L, 1, 0);
@@ -651,29 +650,29 @@ static int errorfb (lua_State *L) {
 
 
 
 
 static const luaL_reg iolib[] = {
 static const luaL_reg iolib[] = {
-  {l_s("appendto"),  io_appendto},
-  {l_s("clock"),     io_clock},
-  {l_s("closefile"), io_close},
-  {l_s("date"),      io_date},
-  {l_s("debug"),     io_debug},
-  {l_s("difftime"),  io_difftime},
-  {l_s("execute"),   io_execute},
-  {l_s("exit"),      io_exit},
-  {l_s("flush"),     io_flush},
-  {l_s("getenv"),    io_getenv},
-  {l_s("openfile"),  io_open},
-  {l_s("read"),      io_read},
-  {l_s("readfrom"),  io_readfrom},
-  {l_s("remove"),    io_remove},
-  {l_s("rename"),    io_rename},
-  {l_s("seek"),      io_seek},
-  {l_s("setlocale"), io_setloc},
-  {l_s("time"),      io_time},
-  {l_s("tmpfile"),   io_tmpfile},
-  {l_s("tmpname"),   io_tmpname},
-  {l_s("write"),     io_write},
-  {l_s("writeto"),   io_writeto},
-  {l_s(LUA_ERRORMESSAGE), errorfb}
+  {"appendto",  io_appendto},
+  {"clock",     io_clock},
+  {"closefile", io_close},
+  {"date",      io_date},
+  {"debug",     io_debug},
+  {"difftime",  io_difftime},
+  {"execute",   io_execute},
+  {"exit",      io_exit},
+  {"flush",     io_flush},
+  {"getenv",    io_getenv},
+  {"openfile",  io_open},
+  {"read",      io_read},
+  {"readfrom",  io_readfrom},
+  {"remove",    io_remove},
+  {"rename",    io_rename},
+  {"seek",      io_seek},
+  {"setlocale", io_setloc},
+  {"time",      io_time},
+  {"tmpfile",   io_tmpfile},
+  {"tmpname",   io_tmpname},
+  {"write",     io_write},
+  {"writeto",   io_writeto},
+  {LUA_ERRORMESSAGE, errorfb}
 };
 };
 
 
 
 
@@ -684,12 +683,12 @@ LUALIB_API int lua_iolibopen (lua_State *L) {
   /* predefined file handles */
   /* predefined file handles */
   newfilewithname(L, stdin, basicfiles[INFILE]);
   newfilewithname(L, stdin, basicfiles[INFILE]);
   newfilewithname(L, stdout, basicfiles[OUTFILE]);
   newfilewithname(L, stdout, basicfiles[OUTFILE]);
-  newfilewithname(L, stderr, l_s("_STDERR"));
+  newfilewithname(L, stderr, "_STDERR");
   resetfile(L, INFILE);
   resetfile(L, INFILE);
   resetfile(L, OUTFILE);
   resetfile(L, OUTFILE);
   /* close files when collected */
   /* close files when collected */
   lua_pushcfunction(L, file_collect);
   lua_pushcfunction(L, file_collect);
-  lua_settagmethod(L, iotag, l_s("gc"));
+  lua_settagmethod(L, iotag, "gc");
   return 0;
   return 0;
 }
 }
 
 

+ 100 - 101
llex.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: llex.c,v 1.91 2001/08/31 19:46:07 roberto Exp $
+** $Id: llex.c,v 1.92 2001/11/16 16:29:10 roberto Exp $
 ** Lexical Analyzer
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -9,7 +9,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "llex.h"
 #include "llex.h"
@@ -26,13 +25,13 @@
 
 
 
 
 /* ORDER RESERVED */
 /* ORDER RESERVED */
-static const l_char *const token2string [] = {
-    l_s("and"), l_s("break"), l_s("do"), l_s("else"), l_s("elseif"),
-    l_s("end"), l_s("for"), l_s("function"), l_s("global"), l_s("if"),
-    l_s("in"), l_s("local"), l_s("nil"), l_s("not"), l_s("or"), l_s("repeat"),
-    l_s("return"), l_s("then"), l_s("until"), l_s("while"), l_s(""),
-    l_s(".."), l_s("..."), l_s("=="), l_s(">="), l_s("<="), l_s("~="),
-    l_s(""), l_s(""), l_s("<eof>")
+static const char *const token2string [] = {
+    "and", "break", "do", "else", "elseif",
+    "end", "for", "function", "global", "if",
+    "in", "local", "nil", "not", "or", "repeat",
+    "return", "then", "until", "while", "",
+    "..", "...", "==", ">=", "<=", "~=",
+    "", "", "<eof>"
 };
 };
 
 
 
 
@@ -49,62 +48,62 @@ void luaX_init (lua_State *L) {
 #define MAXSRC          80
 #define MAXSRC          80
 
 
 
 
-void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg) {
+void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
   if (val > limit) {
   if (val > limit) {
-    l_char buff[90];
-    sprintf(buff, l_s("too many %.40s (limit=%d)"), msg, limit);
+    char buff[90];
+    sprintf(buff, "too many %.40s (limit=%d)", msg, limit);
     luaX_error(ls, buff, ls->t.token);
     luaX_error(ls, buff, ls->t.token);
   }
   }
 }
 }
 
 
 
 
-static void luaX_syntaxerror (LexState *ls, const l_char *s,
-                              const l_char *token) {
-  l_char buff[MAXSRC];
+static void luaX_syntaxerror (LexState *ls, const char *s,
+                              const char *token) {
+  char buff[MAXSRC];
   luaO_chunkid(buff, getstr(ls->source), MAXSRC);
   luaO_chunkid(buff, getstr(ls->source), MAXSRC);
   luaO_verror(ls->L,
   luaO_verror(ls->L,
-              l_s("%.99s;\n  last token read: `%.30s' at line %d in %.80s"),
+              "%.99s;\n  last token read: `%.30s' at line %d in %.80s",
               s, token, ls->linenumber, buff);
               s, token, ls->linenumber, buff);
 }
 }
 
 
 
 
-void luaX_token2str (int token, l_char *s) {
+void luaX_token2str (int token, char *s) {
   if (token < FIRST_RESERVED) {
   if (token < FIRST_RESERVED) {
-    lua_assert(token == (l_char)token);
-    s[0] = (l_char)token;
-    s[1] = l_c('\0');
+    lua_assert(token == (char)token);
+    s[0] = (char)token;
+    s[1] = '\0';
   }
   }
   else
   else
     strcpy(s, token2string[token-FIRST_RESERVED]);
     strcpy(s, token2string[token-FIRST_RESERVED]);
 }
 }
 
 
 
 
-static l_char *token2str_all (LexState *ls, int token, l_char *s) {
+static char *token2str_all (LexState *ls, int token, char *s) {
   luaX_token2str(token, s);
   luaX_token2str(token, s);
-  if (s[0] == l_c('\0'))
-    return cast(l_char *, G(ls->L)->Mbuffer);
+  if (s[0] == '\0')
+    return cast(char *, G(ls->L)->Mbuffer);
   else
   else
     return s;
     return s;
 }
 }
 
 
 
 
-void luaX_error (LexState *ls, const l_char *s, int token) {
-  l_char buff[TOKEN_LEN];
+void luaX_error (LexState *ls, const char *s, int token) {
+  char buff[TOKEN_LEN];
   luaX_syntaxerror(ls, s, token2str_all(ls, token, buff));
   luaX_syntaxerror(ls, s, token2str_all(ls, token, buff));
 }
 }
 
 
 
 
 static void luaX_invalidchar (LexState *ls, int c) {
 static void luaX_invalidchar (LexState *ls, int c) {
-  l_char buff[8];
-  sprintf(buff, l_s("0x%02X"), uchar(c));
-  luaX_syntaxerror(ls, l_s("invalid control char"), buff);
+  char buff[8];
+  sprintf(buff, "0x%02X", (unsigned char)c);
+  luaX_syntaxerror(ls, "invalid control char", buff);
 }
 }
 
 
 
 
 static void inclinenumber (LexState *LS) {
 static void inclinenumber (LexState *LS) {
   next(LS);  /* skip `\n' */
   next(LS);  /* skip `\n' */
   ++LS->linenumber;
   ++LS->linenumber;
-  luaX_checklimit(LS, LS->linenumber, MAX_INT, l_s("lines in a chunk"));
+  luaX_checklimit(LS, LS->linenumber, MAX_INT, "lines in a chunk");
 }
 }
 
 
 
 
@@ -117,10 +116,10 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) {
   LS->lastline = 1;
   LS->lastline = 1;
   LS->source = source;
   LS->source = source;
   next(LS);  /* read first char */
   next(LS);  /* read first char */
-  if (LS->current == l_c('#')) {
+  if (LS->current == '#') {
     do {  /* skip first line */
     do {  /* skip first line */
       next(LS);
       next(LS);
-    } while (LS->current != l_c('\n') && LS->current != EOZ);
+    } while (LS->current != '\n' && LS->current != EOZ);
   }
   }
 }
 }
 
 
@@ -137,10 +136,10 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) {
 
 
 #define EXTRABUFF	128
 #define EXTRABUFF	128
 #define checkbuffer(L, n, len)	\
 #define checkbuffer(L, n, len)	\
-    if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \
-      luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char)
+    if (((len)+(n))*sizeof(char) > G(L)->Mbuffsize) \
+      luaO_openspace(L, (len)+(n)+EXTRABUFF, char)
 
 
-#define save(L, c, l)	(cast(l_char *, G(L)->Mbuffer)[l++] = (l_char)c)
+#define save(L, c, l)	(cast(char *, G(L)->Mbuffer)[l++] = (char)c)
 #define save_and_next(L, LS, l)  (save(L, LS->current, l), next(LS))
 #define save_and_next(L, LS, l)  (save(L, LS->current, l), next(LS))
 
 
 
 
@@ -151,8 +150,8 @@ static size_t readname (LexState *LS) {
   do {
   do {
     checkbuffer(L, 10, l);
     checkbuffer(L, 10, l);
     save_and_next(L, LS, l);
     save_and_next(L, LS, l);
-  } while (isalnum(LS->current) || LS->current == l_c('_'));
-  save(L, l_c('\0'), l);
+  } while (isalnum(LS->current) || LS->current == '_');
+  save(L, '\0', l);
   return l-1;
   return l-1;
 }
 }
 
 
@@ -162,18 +161,18 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
   lua_State *L = LS->L;
   lua_State *L = LS->L;
   size_t l = 0;
   size_t l = 0;
   checkbuffer(L, 10, l);
   checkbuffer(L, 10, l);
-  if (comma) save(L, l_c('.'), l);
+  if (comma) save(L, '.', l);
   while (isdigit(LS->current)) {
   while (isdigit(LS->current)) {
     checkbuffer(L, 10, l);
     checkbuffer(L, 10, l);
     save_and_next(L, LS, l);
     save_and_next(L, LS, l);
   }
   }
-  if (LS->current == l_c('.')) {
+  if (LS->current == '.') {
     save_and_next(L, LS, l);
     save_and_next(L, LS, l);
-    if (LS->current == l_c('.')) {
+    if (LS->current == '.') {
       save_and_next(L, LS, l);
       save_and_next(L, LS, l);
-      save(L, l_c('\0'), l);
+      save(L, '\0', l);
       luaX_error(LS,
       luaX_error(LS,
-                 l_s("ambiguous syntax (decimal point x string concatenation)"),
+                 "ambiguous syntax (decimal point x string concatenation)",
                  TK_NUMBER);
                  TK_NUMBER);
     }
     }
   }
   }
@@ -181,18 +180,18 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) {
     checkbuffer(L, 10, l);
     checkbuffer(L, 10, l);
     save_and_next(L, LS, l);
     save_and_next(L, LS, l);
   }
   }
-  if (LS->current == l_c('e') || LS->current == l_c('E')) {
+  if (LS->current == 'e' || LS->current == 'E') {
     save_and_next(L, LS, l);  /* read `E' */
     save_and_next(L, LS, l);  /* read `E' */
-    if (LS->current == l_c('+') || LS->current == l_c('-'))
+    if (LS->current == '+' || LS->current == '-')
       save_and_next(L, LS, l);  /* optional exponent sign */
       save_and_next(L, LS, l);  /* optional exponent sign */
     while (isdigit(LS->current)) {
     while (isdigit(LS->current)) {
       checkbuffer(L, 10, l);
       checkbuffer(L, 10, l);
       save_and_next(L, LS, l);
       save_and_next(L, LS, l);
     }
     }
   }
   }
-  save(L, l_c('\0'), l);
-  if (!luaO_str2d(cast(l_char *, G(L)->Mbuffer), &seminfo->r))
-    luaX_error(LS, l_s("malformed number"), TK_NUMBER);
+  save(L, '\0', l);
+  if (!luaO_str2d(cast(char *, G(L)->Mbuffer), &seminfo->r))
+    luaX_error(LS, "malformed number", TK_NUMBER);
 }
 }
 
 
 
 
@@ -201,34 +200,34 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) {
   int cont = 0;
   int cont = 0;
   size_t l = 0;
   size_t l = 0;
   checkbuffer(L, 10, l);
   checkbuffer(L, 10, l);
-  save(L, l_c('['), l);  /* save first `[' */
+  save(L, '[', l);  /* save first `[' */
   save_and_next(L, LS, l);  /* pass the second `[' */
   save_and_next(L, LS, l);  /* pass the second `[' */
-  if (LS->current == l_c('\n'))  /* string starts with a newline? */
+  if (LS->current == '\n')  /* string starts with a newline? */
     inclinenumber(LS);  /* skip it */
     inclinenumber(LS);  /* skip it */
   for (;;) {
   for (;;) {
     checkbuffer(L, 10, l);
     checkbuffer(L, 10, l);
     switch (LS->current) {
     switch (LS->current) {
       case EOZ:
       case EOZ:
-        save(L, l_c('\0'), l);
-        luaX_error(LS, l_s("unfinished long string"), TK_STRING);
+        save(L, '\0', l);
+        luaX_error(LS, "unfinished long string", TK_STRING);
         break;  /* to avoid warnings */
         break;  /* to avoid warnings */
-      case l_c('['):
+      case '[':
         save_and_next(L, LS, l);
         save_and_next(L, LS, l);
-        if (LS->current == l_c('[')) {
+        if (LS->current == '[') {
           cont++;
           cont++;
           save_and_next(L, LS, l);
           save_and_next(L, LS, l);
         }
         }
         continue;
         continue;
-      case l_c(']'):
+      case ']':
         save_and_next(L, LS, l);
         save_and_next(L, LS, l);
-        if (LS->current == l_c(']')) {
+        if (LS->current == ']') {
           if (cont == 0) goto endloop;
           if (cont == 0) goto endloop;
           cont--;
           cont--;
           save_and_next(L, LS, l);
           save_and_next(L, LS, l);
         }
         }
         continue;
         continue;
-      case l_c('\n'):
-        save(L, l_c('\n'), l);
+      case '\n':
+        save(L, '\n', l);
         inclinenumber(LS);
         inclinenumber(LS);
         continue;
         continue;
       default:
       default:
@@ -236,8 +235,8 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) {
     }
     }
   } endloop:
   } endloop:
   save_and_next(L, LS, l);  /* skip the second `]' */
   save_and_next(L, LS, l);  /* skip the second `]' */
-  save(L, l_c('\0'), l);
-  seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+2, l-5);
+  save(L, '\0', l);
+  seminfo->ts = luaS_newlstr(L, cast(char *, G(L)->Mbuffer)+2, l-5);
 }
 }
 
 
 
 
@@ -249,21 +248,21 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
   while (LS->current != del) {
   while (LS->current != del) {
     checkbuffer(L, 10, l);
     checkbuffer(L, 10, l);
     switch (LS->current) {
     switch (LS->current) {
-      case EOZ:  case l_c('\n'):
-        save(L, l_c('\0'), l);
-        luaX_error(LS, l_s("unfinished string"), TK_STRING);
+      case EOZ:  case '\n':
+        save(L, '\0', l);
+        luaX_error(LS, "unfinished string", TK_STRING);
         break;  /* to avoid warnings */
         break;  /* to avoid warnings */
-      case l_c('\\'):
+      case '\\':
         next(LS);  /* do not save the `\' */
         next(LS);  /* do not save the `\' */
         switch (LS->current) {
         switch (LS->current) {
-          case l_c('a'): save(L, l_c('\a'), l); next(LS); break;
-          case l_c('b'): save(L, l_c('\b'), l); next(LS); break;
-          case l_c('f'): save(L, l_c('\f'), l); next(LS); break;
-          case l_c('n'): save(L, l_c('\n'), l); next(LS); break;
-          case l_c('r'): save(L, l_c('\r'), l); next(LS); break;
-          case l_c('t'): save(L, l_c('\t'), l); next(LS); break;
-          case l_c('v'): save(L, l_c('\v'), l); next(LS); break;
-          case l_c('\n'): save(L, l_c('\n'), l); inclinenumber(LS); break;
+          case 'a': save(L, '\a', l); next(LS); break;
+          case 'b': save(L, '\b', l); next(LS); break;
+          case 'f': save(L, '\f', l); next(LS); break;
+          case 'n': save(L, '\n', l); next(LS); break;
+          case 'r': save(L, '\r', l); next(LS); break;
+          case 't': save(L, '\t', l); next(LS); break;
+          case 'v': save(L, '\v', l); next(LS); break;
+          case '\n': save(L, '\n', l); inclinenumber(LS); break;
           default: {
           default: {
             if (!isdigit(LS->current))
             if (!isdigit(LS->current))
               save_and_next(L, LS, l);  /* handles \\, \", \', and \? */
               save_and_next(L, LS, l);  /* handles \\, \", \', and \? */
@@ -271,12 +270,12 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
               int c = 0;
               int c = 0;
               int i = 0;
               int i = 0;
               do {
               do {
-                c = 10*c + (LS->current-l_c('0'));
+                c = 10*c + (LS->current-'0');
                 next(LS);
                 next(LS);
               } while (++i<3 && isdigit(LS->current));
               } while (++i<3 && isdigit(LS->current));
               if (c > UCHAR_MAX) {
               if (c > UCHAR_MAX) {
-                save(L, l_c('\0'), l);
-                luaX_error(LS, l_s("escape sequence too large"), TK_STRING);
+                save(L, '\0', l);
+                luaX_error(LS, "escape sequence too large", TK_STRING);
               }
               }
               save(L, c, l);
               save(L, c, l);
             }
             }
@@ -288,8 +287,8 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) {
     }
     }
   }
   }
   save_and_next(L, LS, l);  /* skip delimiter */
   save_and_next(L, LS, l);  /* skip delimiter */
-  save(L, l_c('\0'), l);
-  seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+1, l-3);
+  save(L, '\0', l);
+  seminfo->ts = luaS_newlstr(L, cast(char *, G(L)->Mbuffer)+1, l-3);
 }
 }
 
 
 
 
@@ -297,70 +296,70 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
   for (;;) {
   for (;;) {
     switch (LS->current) {
     switch (LS->current) {
 
 
-      case l_c(' '): case l_c('\t'): case l_c('\r'):  /* `\r' to avoid problems with DOS */
+      case ' ': case '\t': case '\r':  /* `\r' to avoid problems with DOS */
         next(LS);
         next(LS);
         continue;
         continue;
 
 
-      case l_c('\n'):
+      case '\n':
         inclinenumber(LS);
         inclinenumber(LS);
         continue;
         continue;
 
 
-      case l_c('$'):
+      case '$':
         luaX_error(LS,
         luaX_error(LS,
-                   l_s("unexpected `$' (pragmas are no longer supported)"),
+                   "unexpected `$' (pragmas are no longer supported)",
                    LS->current);
                    LS->current);
         break;
         break;
 
 
-      case l_c('-'):
+      case '-':
         next(LS);
         next(LS);
-        if (LS->current != l_c('-')) return l_c('-');
-        do { next(LS); } while (LS->current != l_c('\n') && LS->current != EOZ);
+        if (LS->current != '-') return '-';
+        do { next(LS); } while (LS->current != '\n' && LS->current != EOZ);
         continue;
         continue;
 
 
-      case l_c('['):
+      case '[':
         next(LS);
         next(LS);
-        if (LS->current != l_c('[')) return l_c('[');
+        if (LS->current != '[') return '[';
         else {
         else {
           read_long_string(LS, seminfo);
           read_long_string(LS, seminfo);
           return TK_STRING;
           return TK_STRING;
         }
         }
 
 
-      case l_c('='):
+      case '=':
         next(LS);
         next(LS);
-        if (LS->current != l_c('=')) return l_c('=');
+        if (LS->current != '=') return '=';
         else { next(LS); return TK_EQ; }
         else { next(LS); return TK_EQ; }
 
 
-      case l_c('<'):
+      case '<':
         next(LS);
         next(LS);
-        if (LS->current != l_c('=')) return l_c('<');
+        if (LS->current != '=') return '<';
         else { next(LS); return TK_LE; }
         else { next(LS); return TK_LE; }
 
 
-      case l_c('>'):
+      case '>':
         next(LS);
         next(LS);
-        if (LS->current != l_c('=')) return l_c('>');
+        if (LS->current != '=') return '>';
         else { next(LS); return TK_GE; }
         else { next(LS); return TK_GE; }
 
 
-      case l_c('~'):
+      case '~':
         next(LS);
         next(LS);
-        if (LS->current != l_c('=')) return l_c('~');
+        if (LS->current != '=') return '~';
         else { next(LS); return TK_NE; }
         else { next(LS); return TK_NE; }
 
 
-      case l_c('"'):
-      case l_c('\''):
+      case '"':
+      case '\'':
         read_string(LS, LS->current, seminfo);
         read_string(LS, LS->current, seminfo);
         return TK_STRING;
         return TK_STRING;
 
 
-      case l_c('.'):
+      case '.':
         next(LS);
         next(LS);
-        if (LS->current == l_c('.')) {
+        if (LS->current == '.') {
           next(LS);
           next(LS);
-          if (LS->current == l_c('.')) {
+          if (LS->current == '.') {
             next(LS);
             next(LS);
             return TK_DOTS;   /* ... */
             return TK_DOTS;   /* ... */
           }
           }
           else return TK_CONCAT;   /* .. */
           else return TK_CONCAT;   /* .. */
         }
         }
-        else if (!isdigit(LS->current)) return l_c('.');
+        else if (!isdigit(LS->current)) return '.';
         else {
         else {
           read_number(LS, 1, seminfo);
           read_number(LS, 1, seminfo);
           return TK_NUMBER;
           return TK_NUMBER;
@@ -374,17 +373,17 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
           read_number(LS, 0, seminfo);
           read_number(LS, 0, seminfo);
           return TK_NUMBER;
           return TK_NUMBER;
         }
         }
-        else if (isalpha(LS->current) || LS->current == l_c('_')) {
+        else if (isalpha(LS->current) || LS->current == '_') {
           /* identifier or reserved word */
           /* identifier or reserved word */
           size_t l = readname(LS);
           size_t l = readname(LS);
-          TString *ts = luaS_newlstr(LS->L, cast(l_char *, G(LS->L)->Mbuffer), l);
+          TString *ts = luaS_newlstr(LS->L, cast(char *, G(LS->L)->Mbuffer), l);
           if (ts->tsv.marked >= RESERVEDMARK)  /* reserved word? */
           if (ts->tsv.marked >= RESERVEDMARK)  /* reserved word? */
             return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED;
             return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED;
           seminfo->ts = ts;
           seminfo->ts = ts;
           return TK_NAME;
           return TK_NAME;
         }
         }
         else {
         else {
-          l_charint c = LS->current;
+          int c = LS->current;
           if (iscntrl(c))
           if (iscntrl(c))
             luaX_invalidchar(LS, c);
             luaX_invalidchar(LS, c);
           next(LS);
           next(LS);

+ 6 - 6
llex.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: llex.h,v 1.38 2001/08/31 19:46:07 roberto Exp $
+** $Id: llex.h,v 1.39 2001/11/16 16:29:10 roberto Exp $
 ** Lexical Analyzer
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -14,7 +14,7 @@
 #define FIRST_RESERVED	257
 #define FIRST_RESERVED	257
 
 
 /* maximum length of a reserved word */
 /* maximum length of a reserved word */
-#define TOKEN_LEN	(sizeof(l_s("function"))/sizeof(l_char))
+#define TOKEN_LEN	(sizeof("function")/sizeof(char))
 
 
 
 
 /*
 /*
@@ -49,7 +49,7 @@ typedef struct Token {
 
 
 
 
 typedef struct LexState {
 typedef struct LexState {
-  l_charint current;  /* current character */
+  int current;  /* current character (charint) */
   Token t;  /* current token */
   Token t;  /* current token */
   Token lookahead;  /* look ahead token */
   Token lookahead;  /* look ahead token */
   struct FuncState *fs;  /* `FuncState' is private to the parser */
   struct FuncState *fs;  /* `FuncState' is private to the parser */
@@ -64,9 +64,9 @@ typedef struct LexState {
 void luaX_init (lua_State *L);
 void luaX_init (lua_State *L);
 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
 void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source);
 int luaX_lex (LexState *LS, SemInfo *seminfo);
 int luaX_lex (LexState *LS, SemInfo *seminfo);
-void luaX_checklimit (LexState *ls, int val, int limit, const l_char *msg);
-void luaX_error (LexState *ls, const l_char *s, int token);
-void luaX_token2str (int token, l_char *s);
+void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
+void luaX_error (LexState *ls, const char *s, int token);
+void luaX_token2str (int token, char *s);
 
 
 
 
 #endif
 #endif

+ 29 - 30
lmathlib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lmathlib.c,v 1.37 2001/03/06 20:09:38 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.38 2001/03/26 14:31:49 roberto Exp $
 ** Standard mathematical library
 ** Standard mathematical library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -8,7 +8,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <math.h>
 #include <math.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
@@ -177,18 +176,18 @@ static int math_random (lua_State *L) {
     }
     }
     case 1: {  /* only upper limit */
     case 1: {  /* only upper limit */
       int u = luaL_check_int(L, 1);
       int u = luaL_check_int(L, 1);
-      luaL_arg_check(L, 1<=u, 1, l_s("interval is empty"));
+      luaL_arg_check(L, 1<=u, 1, "interval is empty");
       lua_pushnumber(L, (int)(r*u)+1);  /* integer between 1 and `u' */
       lua_pushnumber(L, (int)(r*u)+1);  /* integer between 1 and `u' */
       break;
       break;
     }
     }
     case 2: {  /* lower and upper limits */
     case 2: {  /* lower and upper limits */
       int l = luaL_check_int(L, 1);
       int l = luaL_check_int(L, 1);
       int u = luaL_check_int(L, 2);
       int u = luaL_check_int(L, 2);
-      luaL_arg_check(L, l<=u, 2, l_s("interval is empty"));
+      luaL_arg_check(L, l<=u, 2, "interval is empty");
       lua_pushnumber(L, (int)(r*(u-l+1))+l);  /* integer between `l' and `u' */
       lua_pushnumber(L, (int)(r*(u-l+1))+l);  /* integer between `l' and `u' */
       break;
       break;
     }
     }
-    default: lua_error(L, l_s("wrong number of arguments"));
+    default: lua_error(L, "wrong number of arguments");
   }
   }
   return 1;
   return 1;
 }
 }
@@ -201,29 +200,29 @@ static int math_randomseed (lua_State *L) {
 
 
 
 
 static const luaL_reg mathlib[] = {
 static const luaL_reg mathlib[] = {
-{l_s("abs"),   math_abs},
-{l_s("sin"),   math_sin},
-{l_s("cos"),   math_cos},
-{l_s("tan"),   math_tan},
-{l_s("asin"),  math_asin},
-{l_s("acos"),  math_acos},
-{l_s("atan"),  math_atan},
-{l_s("atan2"), math_atan2},
-{l_s("ceil"),  math_ceil},
-{l_s("floor"), math_floor},
-{l_s("mod"),   math_mod},
-{l_s("frexp"), math_frexp},
-{l_s("ldexp"), math_ldexp},
-{l_s("sqrt"),  math_sqrt},
-{l_s("min"),   math_min},
-{l_s("max"),   math_max},
-{l_s("log"),   math_log},
-{l_s("log10"), math_log10},
-{l_s("exp"),   math_exp},
-{l_s("deg"),   math_deg},
-{l_s("rad"),   math_rad},
-{l_s("random"),     math_random},
-{l_s("randomseed"), math_randomseed}
+{"abs",   math_abs},
+{"sin",   math_sin},
+{"cos",   math_cos},
+{"tan",   math_tan},
+{"asin",  math_asin},
+{"acos",  math_acos},
+{"atan",  math_atan},
+{"atan2", math_atan2},
+{"ceil",  math_ceil},
+{"floor", math_floor},
+{"mod",   math_mod},
+{"frexp", math_frexp},
+{"ldexp", math_ldexp},
+{"sqrt",  math_sqrt},
+{"min",   math_min},
+{"max",   math_max},
+{"log",   math_log},
+{"log10", math_log10},
+{"exp",   math_exp},
+{"deg",   math_deg},
+{"rad",   math_rad},
+{"random",     math_random},
+{"randomseed", math_randomseed}
 };
 };
 
 
 /*
 /*
@@ -232,9 +231,9 @@ static const luaL_reg mathlib[] = {
 LUALIB_API int lua_mathlibopen (lua_State *L) {
 LUALIB_API int lua_mathlibopen (lua_State *L) {
   luaL_openl(L, mathlib);
   luaL_openl(L, mathlib);
   lua_pushcfunction(L, math_pow);
   lua_pushcfunction(L, math_pow);
-  lua_settagmethod(L, LUA_TNUMBER, l_s("pow"));
+  lua_settagmethod(L, LUA_TNUMBER, "pow");
   lua_pushnumber(L, PI);
   lua_pushnumber(L, PI);
-  lua_setglobal(L, l_s("PI"));
+  lua_setglobal(L, "PI");
   return 0;
   return 0;
 }
 }
 
 

+ 3 - 4
lmem.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lmem.c,v 1.50 2001/08/31 19:46:07 roberto Exp $
+** $Id: lmem.c,v 1.51 2001/10/25 19:13:33 roberto Exp $
 ** Interface to Memory Manager
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldo.h"
 #include "ldo.h"
@@ -27,7 +26,7 @@
 
 
 
 
 void *luaM_growaux (lua_State *L, void *block, int *size, int size_elems,
 void *luaM_growaux (lua_State *L, void *block, int *size, int size_elems,
-                    int limit, const l_char *errormsg) {
+                    int limit, const char *errormsg) {
   void *newblock;
   void *newblock;
   int newsize = (*size)*2;
   int newsize = (*size)*2;
   if (newsize < MINSIZEARRAY)
   if (newsize < MINSIZEARRAY)
@@ -54,7 +53,7 @@ void *luaM_realloc (lua_State *L, void *block, lu_mem oldsize, lu_mem size) {
     block = NULL;
     block = NULL;
   }
   }
   else if (size >= MAX_SIZET)
   else if (size >= MAX_SIZET)
-    luaD_error(L, l_s("memory allocation error: block too big"));
+    luaD_error(L, "memory allocation error: block too big");
   else {
   else {
     block = l_realloc(block, oldsize, size);
     block = l_realloc(block, oldsize, size);
     if (block == NULL) {
     if (block == NULL) {

+ 2 - 2
lmem.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lmem.h,v 1.22 2001/02/23 17:17:25 roberto Exp $
+** $Id: lmem.h,v 1.24 2001/09/07 17:30:16 roberto Exp $
 ** Interface to Memory Manager
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -16,7 +16,7 @@
 void *luaM_realloc (lua_State *L, void *oldblock, lu_mem oldsize, lu_mem size);
 void *luaM_realloc (lua_State *L, void *oldblock, lu_mem oldsize, lu_mem size);
 
 
 void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
 void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem,
-                    int limit, const l_char *errormsg);
+                    int limit, const char *errormsg);
 
 
 #define luaM_free(L, b, s)	luaM_realloc(L, (b), (s), 0)
 #define luaM_free(L, b, s)	luaM_realloc(L, (b), (s), 0)
 #define luaM_freelem(L, b)	luaM_realloc(L, (b), sizeof(*(b)), 0)
 #define luaM_freelem(L, b)	luaM_realloc(L, (b), sizeof(*(b)), 0)

+ 20 - 21
lobject.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.c,v 1.70 2001/03/26 14:31:49 roberto Exp $
+** $Id: lobject.c,v 1.71 2001/10/25 19:14:14 roberto Exp $
 ** Some generic functions over Lua objects
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldo.h"
 #include "ldo.h"
@@ -73,12 +72,12 @@ void *luaO_openspaceaux (lua_State *L, size_t n) {
 }
 }
 
 
 
 
-int luaO_str2d (const l_char *s, lua_Number *result) {
-  l_char *endptr;
+int luaO_str2d (const char *s, lua_Number *result) {
+  char *endptr;
   lua_Number res = lua_str2number(s, &endptr);
   lua_Number res = lua_str2number(s, &endptr);
   if (endptr == s) return 0;  /* no conversion */
   if (endptr == s) return 0;  /* no conversion */
-  while (isspace(uchar(*endptr))) endptr++;
-  if (*endptr != l_c('\0')) return 0;  /* invalid trailing characters? */
+  while (isspace((unsigned char)(*endptr))) endptr++;
+  if (*endptr != '\0') return 0;  /* invalid trailing characters? */
   *result = res;
   *result = res;
   return 1;
   return 1;
 }
 }
@@ -88,9 +87,9 @@ int luaO_str2d (const l_char *s, lua_Number *result) {
 #define MAX_VERROR	280
 #define MAX_VERROR	280
 
 
 /* this function needs to handle only '%d' and '%.XXs' formats */
 /* this function needs to handle only '%d' and '%.XXs' formats */
-void luaO_verror (lua_State *L, const l_char *fmt, ...) {
+void luaO_verror (lua_State *L, const char *fmt, ...) {
   va_list argp;
   va_list argp;
-  l_char buff[MAX_VERROR];  /* to hold formatted message */
+  char buff[MAX_VERROR];  /* to hold formatted message */
   va_start(argp, fmt);
   va_start(argp, fmt);
   vsprintf(buff, fmt, argp);
   vsprintf(buff, fmt, argp);
   va_end(argp);
   va_end(argp);
@@ -98,36 +97,36 @@ void luaO_verror (lua_State *L, const l_char *fmt, ...) {
 }
 }
 
 
 
 
-void luaO_chunkid (l_char *out, const l_char *source, int bufflen) {
-  if (*source == l_c('=')) {
+void luaO_chunkid (char *out, const char *source, int bufflen) {
+  if (*source == '=') {
     strncpy(out, source+1, bufflen);  /* remove first char */
     strncpy(out, source+1, bufflen);  /* remove first char */
-    out[bufflen-1] = l_c('\0');  /* ensures null termination */
+    out[bufflen-1] = '\0';  /* ensures null termination */
   }
   }
   else {
   else {
-    if (*source == l_c('@')) {
+    if (*source == '@') {
       int l;
       int l;
       source++;  /* skip the `@' */
       source++;  /* skip the `@' */
-      bufflen -= sizeof(l_s("file `...%s'"));
+      bufflen -= sizeof("file `...%s'");
       l = strlen(source);
       l = strlen(source);
       if (l>bufflen) {
       if (l>bufflen) {
         source += (l-bufflen);  /* get last part of file name */
         source += (l-bufflen);  /* get last part of file name */
-        sprintf(out, l_s("file `...%.99s'"), source);
+        sprintf(out, "file `...%.99s'", source);
       }
       }
       else
       else
-        sprintf(out, l_s("file `%.99s'"), source);
+        sprintf(out, "file `%.99s'", source);
     }
     }
     else {
     else {
-      int len = strcspn(source, l_s("\n"));  /* stop at first newline */
-      bufflen -= sizeof(l_s("string \"%.*s...\""));
+      int len = strcspn(source, "\n");  /* stop at first newline */
+      bufflen -= sizeof("string \"%.*s...\"");
       if (len > bufflen) len = bufflen;
       if (len > bufflen) len = bufflen;
-      if (source[len] != l_c('\0')) {  /* must truncate? */
-        strcpy(out, l_s("string \""));
+      if (source[len] != '\0') {  /* must truncate? */
+        strcpy(out, "string \"");
         out += strlen(out);
         out += strlen(out);
         strncpy(out, source, len);
         strncpy(out, source, len);
-        strcpy(out+len, l_s("...\""));
+        strcpy(out+len, "...\"");
       }
       }
       else
       else
-        sprintf(out, l_s("string \"%.99s\""), source);
+        sprintf(out, "string \"%.99s\"", source);
     }
     }
   }
   }
 }
 }

+ 5 - 5
lobject.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.h,v 1.115 2001/10/25 19:14:14 roberto Exp $
+** $Id: lobject.h,v 1.116 2001/11/06 21:41:53 roberto Exp $
 ** Type definitions for Lua objects
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -114,7 +114,7 @@ typedef union TString {
 } TString;
 } TString;
 
 
 
 
-#define getstr(ts)	cast(l_char *, (ts) + 1)
+#define getstr(ts)	cast(char *, (ts) + 1)
 #define svalue(o)       getstr(tsvalue(o))
 #define svalue(o)       getstr(tsvalue(o))
 
 
 
 
@@ -277,10 +277,10 @@ int luaO_log2 (unsigned int x);
 void *luaO_openspaceaux (lua_State *L, size_t n);
 void *luaO_openspaceaux (lua_State *L, size_t n);
 
 
 int luaO_equalObj (const TObject *t1, const TObject *t2);
 int luaO_equalObj (const TObject *t1, const TObject *t2);
-int luaO_str2d (const l_char *s, lua_Number *result);
+int luaO_str2d (const char *s, lua_Number *result);
 
 
-void luaO_verror (lua_State *L, const l_char *fmt, ...);
-void luaO_chunkid (l_char *out, const l_char *source, int len);
+void luaO_verror (lua_State *L, const char *fmt, ...);
+void luaO_chunkid (char *out, const char *source, int len);
 
 
 
 
 #endif
 #endif

+ 43 - 44
lopcodes.c

@@ -1,12 +1,11 @@
 /*
 /*
-** $Id: lopcodes.c,v 1.5 2001/09/07 17:39:10 roberto Exp $
+** $Id: lopcodes.c,v 1.6 2001/10/25 19:14:14 roberto Exp $
 ** extracted automatically from lopcodes.h by mkprint.lua
 ** extracted automatically from lopcodes.h by mkprint.lua
 ** DO NOT EDIT
 ** DO NOT EDIT
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
 
 
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lobject.h"
 #include "lobject.h"
@@ -15,48 +14,48 @@
 
 
 #ifdef LUA_OPNAMES
 #ifdef LUA_OPNAMES
 
 
-const l_char *const luaP_opnames[] = {
-  l_s("MOVE"),
-  l_s("LOADK"),
-  l_s("LOADINT"),
-  l_s("LOADNIL"),
-  l_s("GETUPVAL"),
-  l_s("GETGLOBAL"),
-  l_s("GETTABLE"),
-  l_s("SETGLOBAL"),
-  l_s("SETUPVAL"),
-  l_s("SETTABLE"),
-  l_s("NEWTABLE"),
-  l_s("SELF"),
-  l_s("ADD"),
-  l_s("SUB"),
-  l_s("MUL"),
-  l_s("DIV"),
-  l_s("POW"),
-  l_s("UNM"),
-  l_s("NOT"),
-  l_s("CONCAT"),
-  l_s("JMP"),
-  l_s("CJMP"),
-  l_s("TESTEQ"),
-  l_s("TESTNE"),
-  l_s("TESTLT"),
-  l_s("TESTLE"),
-  l_s("TESTGT"),
-  l_s("TESTGE"),
-  l_s("TESTT"),
-  l_s("TESTF"),
-  l_s("NILJMP"),
-  l_s("CALL"),
-  l_s("RETURN"),
-  l_s("FORPREP"),
-  l_s("FORLOOP"),
-  l_s("TFORPREP"),
-  l_s("TFORLOOP"),
-  l_s("SETLIST"),
-  l_s("SETLISTO"),
-  l_s("CLOSE"),
-  l_s("CLOSURE")
+const char *const luaP_opnames[] = {
+  "MOVE",
+  "LOADK",
+  "LOADINT",
+  "LOADNIL",
+  "GETUPVAL",
+  "GETGLOBAL",
+  "GETTABLE",
+  "SETGLOBAL",
+  "SETUPVAL",
+  "SETTABLE",
+  "NEWTABLE",
+  "SELF",
+  "ADD",
+  "SUB",
+  "MUL",
+  "DIV",
+  "POW",
+  "UNM",
+  "NOT",
+  "CONCAT",
+  "JMP",
+  "CJMP",
+  "TESTEQ",
+  "TESTNE",
+  "TESTLT",
+  "TESTLE",
+  "TESTGT",
+  "TESTGE",
+  "TESTT",
+  "TESTF",
+  "NILJMP",
+  "CALL",
+  "RETURN",
+  "FORPREP",
+  "FORLOOP",
+  "TFORPREP",
+  "TFORLOOP",
+  "SETLIST",
+  "SETLISTO",
+  "CLOSE",
+  "CLOSURE"
 };
 };
 
 
 #endif
 #endif

+ 2 - 2
lopcodes.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lopcodes.h,v 1.81 2001/09/07 17:39:10 roberto Exp $
+** $Id: lopcodes.h,v 1.82 2001/10/25 19:14:14 roberto Exp $
 ** Opcodes for Lua virtual machine
 ** Opcodes for Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -224,7 +224,7 @@ extern const lu_byte luaP_opmodes[NUM_OPCODES];
 /*
 /*
 ** opcode names (only included when compiled with LUA_OPNAMES)
 ** opcode names (only included when compiled with LUA_OPNAMES)
 */
 */
-extern const l_char *const luaP_opnames[];
+extern const char *const luaP_opnames[];
 
 
 
 
 #endif
 #endif

+ 83 - 84
lparser.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lparser.c,v 1.159 2001/10/02 16:41:36 roberto Exp $
+** $Id: lparser.c,v 1.160 2001/10/25 19:14:14 roberto Exp $
 ** Lua Parser
 ** Lua Parser
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lcode.h"
 #include "lcode.h"
@@ -76,9 +75,9 @@ static void lookahead (LexState *ls) {
 
 
 
 
 static void error_expected (LexState *ls, int token) {
 static void error_expected (LexState *ls, int token) {
-  l_char buff[30], t[TOKEN_LEN];
+  char buff[30], t[TOKEN_LEN];
   luaX_token2str(token, t);
   luaX_token2str(token, t);
-  sprintf(buff, l_s("`%.10s' expected"), t);
+  sprintf(buff, "`%.10s' expected", t);
   luaK_error(ls, buff);
   luaK_error(ls, buff);
 }
 }
 
 
@@ -90,7 +89,7 @@ static void check (LexState *ls, int c) {
 }
 }
 
 
 
 
-static void check_condition (LexState *ls, int c, const l_char *msg) {
+static void check_condition (LexState *ls, int c, const char *msg) {
   if (!c) luaK_error(ls, msg);
   if (!c) luaK_error(ls, msg);
 }
 }
 
 
@@ -109,11 +108,11 @@ static void check_match (LexState *ls, int what, int who, int where) {
     if (where == ls->linenumber)
     if (where == ls->linenumber)
       error_expected(ls, what);
       error_expected(ls, what);
     else {
     else {
-      l_char buff[70];
-      l_char t_what[TOKEN_LEN], t_who[TOKEN_LEN];
+      char buff[70];
+      char t_what[TOKEN_LEN], t_who[TOKEN_LEN];
       luaX_token2str(what, t_what);
       luaX_token2str(what, t_what);
       luaX_token2str(who, t_who);
       luaX_token2str(who, t_who);
-      sprintf(buff, l_s("`%.10s' expected (to close `%.10s' at line %d)"),
+      sprintf(buff, "`%.10s' expected (to close `%.10s' at line %d)",
               t_what, t_who, where);
               t_what, t_who, where);
       luaK_error(ls, buff);
       luaK_error(ls, buff);
     }
     }
@@ -123,7 +122,7 @@ static void check_match (LexState *ls, int what, int who, int where) {
 
 
 
 
 static TString *str_checkname (LexState *ls) {
 static TString *str_checkname (LexState *ls) {
-  check_condition(ls, (ls->t.token == TK_NAME), l_s("<name> expected"));
+  check_condition(ls, (ls->t.token == TK_NAME), "<name> expected");
   return ls->t.seminfo.ts;
   return ls->t.seminfo.ts;
 }
 }
 
 
@@ -150,7 +149,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
   FuncState *fs = ls->fs;
   FuncState *fs = ls->fs;
   Proto *f = fs->f;
   Proto *f = fs->f;
   luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
   luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
-                  LocVar, MAX_INT, l_s(""));
+                  LocVar, MAX_INT, "");
   f->locvars[fs->nlocvars].varname = varname;
   f->locvars[fs->nlocvars].varname = varname;
   return fs->nlocvars++;
   return fs->nlocvars++;
 }
 }
@@ -158,7 +157,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
 
 
 static void new_localvar (LexState *ls, TString *name, int n) {
 static void new_localvar (LexState *ls, TString *name, int n) {
   FuncState *fs = ls->fs;
   FuncState *fs = ls->fs;
-  luaX_checklimit(ls, fs->nactloc+n+1, MAXLOCALS, l_s("local variables"));
+  luaX_checklimit(ls, fs->nactloc+n+1, MAXLOCALS, "local variables");
   fs->actloc[fs->nactloc+n] = luaI_registerlocalvar(ls, name);
   fs->actloc[fs->nactloc+n] = luaI_registerlocalvar(ls, name);
 }
 }
 
 
@@ -194,7 +193,7 @@ static void removelocalvars (LexState *ls, int nvars, int toclose) {
 }
 }
 
 
 
 
-static void new_localvarstr (LexState *ls, const l_char *name, int n) {
+static void new_localvarstr (LexState *ls, const char *name, int n) {
   new_localvar(ls, luaS_new(ls->L, name), n);
   new_localvar(ls, luaS_new(ls->L, name), n);
 }
 }
 
 
@@ -206,7 +205,7 @@ static int indexupvalue (FuncState *fs, expdesc *v) {
       return i;
       return i;
   }
   }
   /* new one */
   /* new one */
-  luaX_checklimit(fs->ls, fs->f->nupvalues+1, MAXUPVALUES, l_s("upvalues"));
+  luaX_checklimit(fs->ls, fs->f->nupvalues+1, MAXUPVALUES, "upvalues");
   fs->upvalues[fs->f->nupvalues] = *v;
   fs->upvalues[fs->f->nupvalues] = *v;
   return fs->f->nupvalues++;
   return fs->f->nupvalues++;
 }
 }
@@ -263,11 +262,11 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
 static void code_params (LexState *ls, int nparams, short dots) {
 static void code_params (LexState *ls, int nparams, short dots) {
   FuncState *fs = ls->fs;
   FuncState *fs = ls->fs;
   adjustlocalvars(ls, nparams);
   adjustlocalvars(ls, nparams);
-  luaX_checklimit(ls, fs->nactloc, MAXPARAMS, l_s("parameters"));
+  luaX_checklimit(ls, fs->nactloc, MAXPARAMS, "parameters");
   fs->f->numparams = cast(short, fs->nactloc);  /* `self' could be there already */
   fs->f->numparams = cast(short, fs->nactloc);  /* `self' could be there already */
   fs->f->is_vararg = dots;
   fs->f->is_vararg = dots;
   if (dots) {
   if (dots) {
-    new_localvarstr(ls, l_s("arg"), 0);
+    new_localvarstr(ls, "arg", 0);
     adjustlocalvars(ls, 1);
     adjustlocalvars(ls, 1);
   }
   }
   luaK_reserveregs(fs, fs->nactloc);  /* reserve register for parameters */
   luaK_reserveregs(fs, fs->nactloc);  /* reserve register for parameters */
@@ -294,7 +293,7 @@ static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
   Proto *f = fs->f;
   Proto *f = fs->f;
   int i;
   int i;
   luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
   luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *,
-                  MAXARG_Bc, l_s("constant table overflow"));
+                  MAXARG_Bc, "constant table overflow");
   f->p[fs->np++] = func->f;
   f->p[fs->np++] = func->f;
   init_exp(v, VRELOCABLE, luaK_codeABc(fs, OP_CLOSURE, 0, fs->np-1));
   init_exp(v, VRELOCABLE, luaK_codeABc(fs, OP_CLOSURE, 0, fs->np-1));
   for (i=0; i<func->f->nupvalues; i++) {
   for (i=0; i<func->f->nupvalues; i++) {
@@ -366,7 +365,7 @@ Proto *luaY_parser (lua_State *L, ZIO *z) {
   next(&lexstate);  /* read first token */
   next(&lexstate);  /* read first token */
   chunk(&lexstate);
   chunk(&lexstate);
   check_condition(&lexstate, (lexstate.t.token == TK_EOS),
   check_condition(&lexstate, (lexstate.t.token == TK_EOS),
-                             l_s("<eof> expected"));
+                             "<eof> expected");
   close_func(&lexstate);
   close_func(&lexstate);
   lua_assert(funcstate.prev == NULL);
   lua_assert(funcstate.prev == NULL);
   lua_assert(funcstate.f->nupvalues == 0);
   lua_assert(funcstate.f->nupvalues == 0);
@@ -396,7 +395,7 @@ static void luaY_index (LexState *ls, expdesc *v) {
   next(ls);  /* skip the '[' */
   next(ls);  /* skip the '[' */
   expr(ls, v);
   expr(ls, v);
   luaK_exp2val(ls->fs, v);
   luaK_exp2val(ls->fs, v);
-  check(ls, l_c(']'));
+  check(ls, ']');
 }
 }
 
 
 
 
@@ -404,7 +403,7 @@ static int explist1 (LexState *ls, expdesc *v) {
   /* explist1 -> expr { `,' expr } */
   /* explist1 -> expr { `,' expr } */
   int n = 1;  /* at least one expression */
   int n = 1;  /* at least one expression */
   expr(ls, v);
   expr(ls, v);
-  while (ls->t.token == l_c(',')) {
+  while (ls->t.token == ',') {
     next(ls);  /* skip comma */
     next(ls);  /* skip comma */
     luaK_exp2nextreg(ls->fs, v);
     luaK_exp2nextreg(ls->fs, v);
     expr(ls, v);
     expr(ls, v);
@@ -419,21 +418,21 @@ static void funcargs (LexState *ls, expdesc *f) {
   expdesc args;
   expdesc args;
   int base, nparams;
   int base, nparams;
   switch (ls->t.token) {
   switch (ls->t.token) {
-    case l_c('('): {  /* funcargs -> `(' [ explist1 ] `)' */
+    case '(': {  /* funcargs -> `(' [ explist1 ] `)' */
       int line = ls->linenumber;
       int line = ls->linenumber;
       if (line != ls->lastline)
       if (line != ls->lastline)
-        luaK_error(ls, l_s("ambiguous syntax (function call x new statement)"));
+        luaK_error(ls, "ambiguous syntax (function call x new statement)");
       next(ls);
       next(ls);
-      if (ls->t.token == l_c(')'))  /* arg list is empty? */
+      if (ls->t.token == ')')  /* arg list is empty? */
         args.k = VVOID;
         args.k = VVOID;
       else {
       else {
         explist1(ls, &args);
         explist1(ls, &args);
         luaK_setcallreturns(fs, &args, LUA_MULTRET);
         luaK_setcallreturns(fs, &args, LUA_MULTRET);
       }
       }
-      check_match(ls, l_c(')'), l_c('('), line);
+      check_match(ls, ')', '(', line);
       break;
       break;
     }
     }
-    case l_c('{'): {  /* funcargs -> constructor */
+    case '{': {  /* funcargs -> constructor */
       constructor(ls, &args);
       constructor(ls, &args);
       break;
       break;
     }
     }
@@ -443,7 +442,7 @@ static void funcargs (LexState *ls, expdesc *f) {
       break;
       break;
     }
     }
     default: {
     default: {
-      luaK_error(ls, l_s("function arguments expected"));
+      luaK_error(ls, "function arguments expected");
       break;
       break;
     }
     }
   }
   }
@@ -480,13 +479,13 @@ static void recfield (LexState *ls, expdesc *t) {
       checkname(ls, &key);
       checkname(ls, &key);
       break;
       break;
     }
     }
-    case l_c('['): {
+    case '[': {
       luaY_index(ls, &key);
       luaY_index(ls, &key);
       break;
       break;
     }
     }
-    default: luaK_error(ls, l_s("<name> or `[' expected"));
+    default: luaK_error(ls, "<name> or `[' expected");
   }
   }
-  check(ls, l_c('='));
+  check(ls, '=');
   luaK_exp2RK(fs, &key);
   luaK_exp2RK(fs, &key);
   expr(ls, &val);
   expr(ls, &val);
   luaK_exp2anyreg(fs, &val);
   luaK_exp2anyreg(fs, &val);
@@ -497,9 +496,9 @@ static void recfield (LexState *ls, expdesc *t) {
 
 
 
 
 static int anotherfield (LexState *ls) {
 static int anotherfield (LexState *ls) {
-  if (ls->t.token != l_c(',')) return 0;
+  if (ls->t.token != ',') return 0;
   next(ls);  /* skip the comma */
   next(ls);  /* skip the comma */
-  return (ls->t.token != l_c(';') && ls->t.token != l_c('}'));
+  return (ls->t.token != ';' && ls->t.token != '}');
 }
 }
 
 
 
 
@@ -508,7 +507,7 @@ static int recfields (LexState *ls, expdesc *t) {
   int n = 0;
   int n = 0;
   do {  /* at least one element */
   do {  /* at least one element */
     recfield(ls, t);
     recfield(ls, t);
-    luaX_checklimit(ls, n, MAX_INT, l_s("items in a constructor"));
+    luaX_checklimit(ls, n, MAX_INT, "items in a constructor");
     n++;
     n++;
   } while (anotherfield(ls));
   } while (anotherfield(ls));
   return n;
   return n;
@@ -525,7 +524,7 @@ static int listfields (LexState *ls, expdesc *t) {
   expr(ls, &v);
   expr(ls, &v);
   while (anotherfield(ls)) {
   while (anotherfield(ls)) {
     luaK_exp2nextreg(fs, &v);
     luaK_exp2nextreg(fs, &v);
-    luaX_checklimit(ls, n, MAXARG_Bc, l_s("items in a constructor"));
+    luaX_checklimit(ls, n, MAXARG_Bc, "items in a constructor");
     if (n%LFIELDS_PER_FLUSH == 0) {
     if (n%LFIELDS_PER_FLUSH == 0) {
       luaK_codeABc(fs, OP_SETLIST, t->u.i.info, n-1);  /* flush */
       luaK_codeABc(fs, OP_SETLIST, t->u.i.info, n-1);  /* flush */
       fs->freereg = reg;  /* free registers */
       fs->freereg = reg;  /* free registers */
@@ -548,18 +547,18 @@ static int listfields (LexState *ls, expdesc *t) {
 
 
 static void constructor_part (LexState *ls, expdesc *t, Constdesc *cd) {
 static void constructor_part (LexState *ls, expdesc *t, Constdesc *cd) {
   switch (ls->t.token) {
   switch (ls->t.token) {
-    case l_c(';'): case l_c('}'): {  /* constructor_part -> empty */
+    case ';': case '}': {  /* constructor_part -> empty */
       cd->narray = cd->nhash = 0;
       cd->narray = cd->nhash = 0;
       cd->k = ls->t.token;
       cd->k = ls->t.token;
       break;
       break;
     }
     }
     case TK_NAME: {  /* may be listfields or recfields */
     case TK_NAME: {  /* may be listfields or recfields */
       lookahead(ls);
       lookahead(ls);
-      if (ls->lookahead.token != l_c('='))  /* expression? */
+      if (ls->lookahead.token != '=')  /* expression? */
         goto case_default;
         goto case_default;
       /* else go through to recfields */
       /* else go through to recfields */
     }
     }
-    case l_c('['): {  /* constructor_part -> recfields */
+    case '[': {  /* constructor_part -> recfields */
       cd->nhash = recfields(ls, t);
       cd->nhash = recfields(ls, t);
       cd->narray = 0;
       cd->narray = 0;
       cd->k = 1;  /* record */
       cd->k = 1;  /* record */
@@ -586,18 +585,18 @@ static void constructor (LexState *ls, expdesc *t) {
   pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
   pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
   init_exp(t, VRELOCABLE, pc);
   init_exp(t, VRELOCABLE, pc);
   luaK_exp2nextreg(ls->fs, t);  /* fix it at stack top (for gc) */
   luaK_exp2nextreg(ls->fs, t);  /* fix it at stack top (for gc) */
-  check(ls, l_c('{'));
+  check(ls, '{');
   constructor_part(ls, t, &cd);
   constructor_part(ls, t, &cd);
   na = cd.narray;
   na = cd.narray;
   nh = cd.nhash;
   nh = cd.nhash;
-  if (optional(ls, l_c(';'))) {
+  if (optional(ls, ';')) {
     Constdesc other_cd;
     Constdesc other_cd;
     constructor_part(ls, t, &other_cd);
     constructor_part(ls, t, &other_cd);
-    check_condition(ls,(cd.k != other_cd.k), l_s("invalid constructor syntax"));
+    check_condition(ls,(cd.k != other_cd.k), "invalid constructor syntax");
     na += other_cd.narray;
     na += other_cd.narray;
     nh += other_cd.nhash;
     nh += other_cd.nhash;
   }
   }
-  check_match(ls, l_c('}'), l_c('{'), line);
+  check_match(ls, '}', '{', line);
   if (na > 0)
   if (na > 0)
     SETARG_B(fs->f->code[pc], luaO_log2(na-1)+2);  /* set initial table size */
     SETARG_B(fs->f->code[pc], luaO_log2(na-1)+2);  /* set initial table size */
   SETARG_C(fs->f->code[pc], luaO_log2(nh)+1);  /* set initial table size */
   SETARG_C(fs->f->code[pc], luaO_log2(nh)+1);  /* set initial table size */
@@ -618,10 +617,10 @@ static void constructor (LexState *ls, expdesc *t) {
 static void prefixexp (LexState *ls, expdesc *v) {
 static void prefixexp (LexState *ls, expdesc *v) {
   /* prefixexp -> NAME | '(' expr ')' */
   /* prefixexp -> NAME | '(' expr ')' */
   switch (ls->t.token) {
   switch (ls->t.token) {
-    case l_c('('): {
+    case '(': {
       next(ls);
       next(ls);
       expr(ls, v);
       expr(ls, v);
-      check(ls, l_c(')'));
+      check(ls, ')');
       luaK_dischargevars(ls->fs, v);
       luaK_dischargevars(ls->fs, v);
       return;
       return;
     }
     }
@@ -630,15 +629,15 @@ static void prefixexp (LexState *ls, expdesc *v) {
       next(ls);
       next(ls);
       return;
       return;
     }
     }
-    case l_c('%'): {  /* for compatibility only */
+    case '%': {  /* for compatibility only */
       next(ls);  /* skip `%' */
       next(ls);  /* skip `%' */
       singlevar(ls->fs, str_checkname(ls), v, 1);
       singlevar(ls->fs, str_checkname(ls), v, 1);
-      check_condition(ls, v->k == VUPVAL, l_s("global upvalues are obsolete"));
+      check_condition(ls, v->k == VUPVAL, "global upvalues are obsolete");
       next(ls);
       next(ls);
       return;
       return;
     }
     }
     default: {
     default: {
-      luaK_error(ls, l_s("unexpected symbol"));
+      luaK_error(ls, "unexpected symbol");
       return;
       return;
     }
     }
   }
   }
@@ -652,18 +651,18 @@ static void primaryexp (LexState *ls, expdesc *v) {
   prefixexp(ls, v);
   prefixexp(ls, v);
   for (;;) {
   for (;;) {
     switch (ls->t.token) {
     switch (ls->t.token) {
-      case l_c('.'): {  /* field */
+      case '.': {  /* field */
         luaY_field(ls, v);
         luaY_field(ls, v);
         break;
         break;
       }
       }
-      case l_c('['): {  /* `[' exp1 `]' */
+      case '[': {  /* `[' exp1 `]' */
         expdesc key;
         expdesc key;
         luaK_exp2anyreg(fs, v);
         luaK_exp2anyreg(fs, v);
         luaY_index(ls, &key);
         luaY_index(ls, &key);
         luaK_indexed(fs, v, &key);
         luaK_indexed(fs, v, &key);
         break;
         break;
       }
       }
-      case l_c(':'): {  /* `:' NAME funcargs */
+      case ':': {  /* `:' NAME funcargs */
         expdesc key;
         expdesc key;
         next(ls);
         next(ls);
         checkname(ls, &key);
         checkname(ls, &key);
@@ -671,7 +670,7 @@ static void primaryexp (LexState *ls, expdesc *v) {
         funcargs(ls, v);
         funcargs(ls, v);
         break;
         break;
       }
       }
-      case l_c('('): case TK_STRING: case l_c('{'): {  /* funcargs */
+      case '(': case TK_STRING: case '{': {  /* funcargs */
         luaK_exp2nextreg(fs, v);
         luaK_exp2nextreg(fs, v);
         funcargs(ls, v);
         funcargs(ls, v);
         break;
         break;
@@ -702,7 +701,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
       next(ls);
       next(ls);
       break;
       break;
     }
     }
-    case l_c('{'): {  /* constructor */
+    case '{': {  /* constructor */
       constructor(ls, v);
       constructor(ls, v);
       break;
       break;
     }
     }
@@ -724,7 +723,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
 static UnOpr getunopr (int op) {
 static UnOpr getunopr (int op) {
   switch (op) {
   switch (op) {
     case TK_NOT: return OPR_NOT;
     case TK_NOT: return OPR_NOT;
-    case l_c('-'): return OPR_MINUS;
+    case '-': return OPR_MINUS;
     default: return OPR_NOUNOPR;
     default: return OPR_NOUNOPR;
   }
   }
 }
 }
@@ -732,17 +731,17 @@ static UnOpr getunopr (int op) {
 
 
 static BinOpr getbinopr (int op) {
 static BinOpr getbinopr (int op) {
   switch (op) {
   switch (op) {
-    case l_c('+'): return OPR_ADD;
-    case l_c('-'): return OPR_SUB;
-    case l_c('*'): return OPR_MULT;
-    case l_c('/'): return OPR_DIV;
-    case l_c('^'): return OPR_POW;
+    case '+': return OPR_ADD;
+    case '-': return OPR_SUB;
+    case '*': return OPR_MULT;
+    case '/': return OPR_DIV;
+    case '^': return OPR_POW;
     case TK_CONCAT: return OPR_CONCAT;
     case TK_CONCAT: return OPR_CONCAT;
     case TK_NE: return OPR_NE;
     case TK_NE: return OPR_NE;
     case TK_EQ: return OPR_EQ;
     case TK_EQ: return OPR_EQ;
-    case l_c('<'): return OPR_LT;
+    case '<': return OPR_LT;
     case TK_LE: return OPR_LE;
     case TK_LE: return OPR_LE;
-    case l_c('>'): return OPR_GT;
+    case '>': return OPR_GT;
     case TK_GE: return OPR_GE;
     case TK_GE: return OPR_GE;
     case TK_AND: return OPR_AND;
     case TK_AND: return OPR_AND;
     case TK_OR: return OPR_OR;
     case TK_OR: return OPR_OR;
@@ -870,8 +869,8 @@ static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {
 static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
 static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
   expdesc e;
   expdesc e;
   check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
   check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED,
-                      l_s("syntax error!"));
-  if (ls->t.token == l_c(',')) {  /* assignment -> `,' primaryexp assignment */
+                      "syntax error!");
+  if (ls->t.token == ',') {  /* assignment -> `,' primaryexp assignment */
     struct LHS_assign nv;
     struct LHS_assign nv;
     nv.prev = lh;
     nv.prev = lh;
     next(ls);
     next(ls);
@@ -882,7 +881,7 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
   }
   }
   else {  /* assignment -> `=' explist1 */
   else {  /* assignment -> `=' explist1 */
     int nexps;
     int nexps;
-    check(ls, l_c('='));
+    check(ls, '=');
     nexps = explist1(ls, &e);
     nexps = explist1(ls, &e);
     if (nexps != nvars) {
     if (nexps != nvars) {
       adjust_assign(ls, nvars, nexps, &e);
       adjust_assign(ls, nvars, nexps, &e);
@@ -965,19 +964,19 @@ static void forbody (LexState *ls, int nvar, OpCode prepfor, OpCode loopfor) {
 static void fornum (LexState *ls, TString *varname) {
 static void fornum (LexState *ls, TString *varname) {
   /* fornum -> NAME = exp1,exp1[,exp1] forbody */
   /* fornum -> NAME = exp1,exp1[,exp1] forbody */
   FuncState *fs = ls->fs;
   FuncState *fs = ls->fs;
-  check(ls, l_c('='));
+  check(ls, '=');
   exp1(ls);  /* initial value */
   exp1(ls);  /* initial value */
-  check(ls, l_c(','));
+  check(ls, ',');
   exp1(ls);  /* limit */
   exp1(ls);  /* limit */
-  if (optional(ls, l_c(',')))
+  if (optional(ls, ','))
     exp1(ls);  /* optional step */
     exp1(ls);  /* optional step */
   else {
   else {
     luaK_codeAsBc(fs, OP_LOADINT, fs->freereg, 1);  /* default step */
     luaK_codeAsBc(fs, OP_LOADINT, fs->freereg, 1);  /* default step */
     luaK_reserveregs(fs, 1);
     luaK_reserveregs(fs, 1);
   }
   }
   new_localvar(ls, varname, 0);
   new_localvar(ls, varname, 0);
-  new_localvarstr(ls, l_s("(limit)"), 1);
-  new_localvarstr(ls, l_s("(step)"), 2);
+  new_localvarstr(ls, "(limit)", 1);
+  new_localvarstr(ls, "(step)", 2);
   forbody(ls, 3, OP_FORPREP, OP_FORLOOP);
   forbody(ls, 3, OP_FORPREP, OP_FORLOOP);
 }
 }
 
 
@@ -985,13 +984,13 @@ static void fornum (LexState *ls, TString *varname) {
 static void forlist (LexState *ls, TString *indexname) {
 static void forlist (LexState *ls, TString *indexname) {
   /* forlist -> NAME,NAME IN exp1 forbody */
   /* forlist -> NAME,NAME IN exp1 forbody */
   TString *valname;
   TString *valname;
-  check(ls, l_c(','));
+  check(ls, ',');
   valname = str_checkname(ls);
   valname = str_checkname(ls);
   next(ls);  /* skip var name */
   next(ls);  /* skip var name */
   check(ls, TK_IN);
   check(ls, TK_IN);
   exp1(ls);  /* table */
   exp1(ls);  /* table */
-  new_localvarstr(ls, l_s("(table)"), 0);
-  new_localvarstr(ls, l_s("(index)"), 1);
+  new_localvarstr(ls, "(table)", 0);
+  new_localvarstr(ls, "(index)", 1);
   new_localvar(ls, indexname, 2);
   new_localvar(ls, indexname, 2);
   new_localvar(ls, valname, 3);
   new_localvar(ls, valname, 3);
   luaK_reserveregs(ls->fs, 3);  /* registers for control, index and val */
   luaK_reserveregs(ls->fs, 3);  /* registers for control, index and val */
@@ -1009,9 +1008,9 @@ static void forstat (LexState *ls, int line) {
   varname = str_checkname(ls);  /* first variable name */
   varname = str_checkname(ls);  /* first variable name */
   next(ls);  /* skip var name */
   next(ls);  /* skip var name */
   switch (ls->t.token) {
   switch (ls->t.token) {
-    case l_c('='): fornum(ls, varname); break;
-    case l_c(','): forlist(ls, varname); break;
-    default: luaK_error(ls, l_s("`=' or `,' expected"));
+    case '=': fornum(ls, varname); break;
+    case ',': forlist(ls, varname); break;
+    default: luaK_error(ls, "`=' or `,' expected");
   }
   }
   check_match(ls, TK_END, TK_FOR, line);
   check_match(ls, TK_END, TK_FOR, line);
   leavebreak(fs, &bl);
   leavebreak(fs, &bl);
@@ -1060,8 +1059,8 @@ static void localstat (LexState *ls) {
     next(ls);  /* skip LOCAL or `,' */
     next(ls);  /* skip LOCAL or `,' */
     new_localvar(ls, str_checkname(ls), nvars++);
     new_localvar(ls, str_checkname(ls), nvars++);
     next(ls);  /* skip var name */
     next(ls);  /* skip var name */
-  } while (ls->t.token == l_c(','));
-  if (optional(ls, l_c('=')))
+  } while (ls->t.token == ',');
+  if (optional(ls, '='))
     nexps = explist1(ls, &e);
     nexps = explist1(ls, &e);
   else {
   else {
     e.k = VVOID;
     e.k = VVOID;
@@ -1077,10 +1076,10 @@ static int funcname (LexState *ls, expdesc *v) {
   int needself = 0;
   int needself = 0;
   singlevar(ls->fs, str_checkname(ls), v, 1);
   singlevar(ls->fs, str_checkname(ls), v, 1);
   next(ls);  /* skip var name */
   next(ls);  /* skip var name */
-  while (ls->t.token == l_c('.')) {
+  while (ls->t.token == '.') {
     luaY_field(ls, v);
     luaY_field(ls, v);
   }
   }
-  if (ls->t.token == l_c(':')) {
+  if (ls->t.token == ':') {
     needself = 1;
     needself = 1;
     luaY_field(ls, v);
     luaY_field(ls, v);
   }
   }
@@ -1120,7 +1119,7 @@ static void retstat (LexState *ls) {
   expdesc e;
   expdesc e;
   int first, nret;  /* registers with returned values */
   int first, nret;  /* registers with returned values */
   next(ls);  /* skip RETURN */
   next(ls);  /* skip RETURN */
-  if (block_follow(ls->t.token) || ls->t.token == l_c(';'))
+  if (block_follow(ls->t.token) || ls->t.token == ';')
     first = nret = 0;  /* return no values */
     first = nret = 0;  /* return no values */
   else {
   else {
     explist1(ls, &e);  /* optional return values */
     explist1(ls, &e);  /* optional return values */
@@ -1145,7 +1144,7 @@ static void breakstat (LexState *ls) {
   FuncState *fs = ls->fs;
   FuncState *fs = ls->fs;
   Breaklabel *bl = fs->bl;
   Breaklabel *bl = fs->bl;
   if (!bl)
   if (!bl)
-    luaK_error(ls, l_s("no loop to break"));
+    luaK_error(ls, "no loop to break");
   next(ls);  /* skip BREAK */
   next(ls);  /* skip BREAK */
   closelevel(ls, bl->nactloc);
   closelevel(ls, bl->nactloc);
   luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
   luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
@@ -1205,15 +1204,15 @@ static void parlist (LexState *ls) {
   /* parlist -> [ param { `,' param } ] */
   /* parlist -> [ param { `,' param } ] */
   int nparams = 0;
   int nparams = 0;
   short dots = 0;
   short dots = 0;
-  if (ls->t.token != l_c(')')) {  /* is `parlist' not empty? */
+  if (ls->t.token != ')') {  /* is `parlist' not empty? */
     do {
     do {
       switch (ls->t.token) {
       switch (ls->t.token) {
         case TK_DOTS: dots = 1; break;
         case TK_DOTS: dots = 1; break;
         case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break;
         case TK_NAME: new_localvar(ls, str_checkname(ls), nparams++); break;
-        default: luaK_error(ls, l_s("<name> or `...' expected"));
+        default: luaK_error(ls, "<name> or `...' expected");
       }
       }
       next(ls);
       next(ls);
-    } while (!dots && optional(ls, l_c(',')));
+    } while (!dots && optional(ls, ','));
   }
   }
   code_params(ls, nparams, dots);
   code_params(ls, nparams, dots);
 }
 }
@@ -1224,13 +1223,13 @@ static void body (LexState *ls, expdesc *e, int needself, int line) {
   FuncState new_fs;
   FuncState new_fs;
   open_func(ls, &new_fs);
   open_func(ls, &new_fs);
   new_fs.f->lineDefined = line;
   new_fs.f->lineDefined = line;
-  check(ls, l_c('('));
+  check(ls, '(');
   if (needself) {
   if (needself) {
-    new_localvarstr(ls, l_s("self"), 0);
+    new_localvarstr(ls, "self", 0);
     adjustlocalvars(ls, 1);
     adjustlocalvars(ls, 1);
   }
   }
   parlist(ls);
   parlist(ls);
-  check(ls, l_c(')'));
+  check(ls, ')');
   chunk(ls);
   chunk(ls);
   check_match(ls, TK_END, TK_FUNCTION, line);
   check_match(ls, TK_END, TK_FUNCTION, line);
   close_func(ls);
   close_func(ls);
@@ -1246,7 +1245,7 @@ static void chunk (LexState *ls) {
   int islast = 0;
   int islast = 0;
   while (!islast && !block_follow(ls->t.token)) {
   while (!islast && !block_follow(ls->t.token)) {
     islast = statement(ls);
     islast = statement(ls);
-    optional(ls, l_c(';'));
+    optional(ls, ';');
     lua_assert(ls->fs->freereg >= ls->fs->nactloc);
     lua_assert(ls->fs->freereg >= ls->fs->nactloc);
     ls->fs->freereg = ls->fs->nactloc;  /* free registers */
     ls->fs->freereg = ls->fs->nactloc;  /* free registers */
   }
   }

+ 2 - 3
lstate.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.c,v 1.71 2001/10/31 19:58:11 roberto Exp $
+** $Id: lstate.c,v 1.72 2001/11/06 21:40:51 roberto Exp $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <stdio.h>
 #include <stdio.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldo.h"
 #include "ldo.h"
@@ -120,7 +119,7 @@ static void close_state (lua_State *L, lua_State *OL) {
     lua_assert(G(L)->roottable == NULL);
     lua_assert(G(L)->roottable == NULL);
     luaS_freeall(L);
     luaS_freeall(L);
     luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM);
     luaM_freearray(L, G(L)->TMtable, G(L)->sizeTM, struct TM);
-    luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, l_char);
+    luaM_freearray(L, G(L)->Mbuffer, G(L)->Mbuffsize, char);
     luaM_freelem(NULL, L->_G);
     luaM_freelem(NULL, L->_G);
   }
   }
   luaM_freearray(OL, L->stack, L->stacksize, TObject);
   luaM_freearray(OL, L->stack, L->stacksize, TObject);

+ 6 - 7
lstring.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstring.c,v 1.66 2001/08/27 15:16:28 roberto Exp $
+** $Id: lstring.c,v 1.67 2001/08/31 19:46:07 roberto Exp $
 ** String table (keeps all strings handled by Lua)
 ** String table (keeps all strings handled by Lua)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 
 
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lmem.h"
 #include "lmem.h"
@@ -47,15 +46,15 @@ void luaS_resize (lua_State *L, int newsize) {
 }
 }
 
 
 
 
-static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) {
+static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) {
   TString *ts = cast(TString *, luaM_malloc(L, sizestring(l)));
   TString *ts = cast(TString *, luaM_malloc(L, sizestring(l)));
   stringtable *tb;
   stringtable *tb;
   ts->tsv.nexthash = NULL;
   ts->tsv.nexthash = NULL;
   ts->tsv.len = l;
   ts->tsv.len = l;
   ts->tsv.hash = h;
   ts->tsv.hash = h;
   ts->tsv.marked = 0;
   ts->tsv.marked = 0;
-  memcpy(getstr(ts), str, l*sizeof(l_char));
-  getstr(ts)[l] = l_c('\0');  /* ending 0 */
+  memcpy(getstr(ts), str, l*sizeof(char));
+  getstr(ts)[l] = '\0';  /* ending 0 */
   tb = &G(L)->strt;
   tb = &G(L)->strt;
   h = lmod(h, tb->size);
   h = lmod(h, tb->size);
   ts->tsv.nexthash = tb->hash[h];  /* chain new entry */
   ts->tsv.nexthash = tb->hash[h];  /* chain new entry */
@@ -67,13 +66,13 @@ static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) {
 }
 }
 
 
 
 
-TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l) {
+TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
   TString *ts;
   TString *ts;
   lu_hash h = l;  /* seed */
   lu_hash h = l;  /* seed */
   size_t step = (l>>5)+1;  /* if string is too long, don't hash all its chars */
   size_t step = (l>>5)+1;  /* if string is too long, don't hash all its chars */
   size_t l1;
   size_t l1;
   for (l1=l; l1>=step; l1-=step)  /* compute hash */
   for (l1=l; l1>=step; l1-=step)  /* compute hash */
-    h = h ^ ((h<<5)+(h>>2)+uchar(str[l1-1]));
+    h = h ^ ((h<<5)+(h>>2)+(unsigned char)(str[l1-1]));
   for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
   for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
        ts != NULL;
        ts != NULL;
        ts = ts->tsv.nexthash) {
        ts = ts->tsv.nexthash) {

+ 5 - 5
lstring.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstring.h,v 1.33 2001/06/15 20:36:57 roberto Exp $
+** $Id: lstring.h,v 1.34 2001/08/31 19:46:07 roberto Exp $
 ** String table (keep all strings handled by Lua)
 ** String table (keep all strings handled by Lua)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -22,18 +22,18 @@
 
 
 
 
 #define sizestring(l)	(cast(lu_mem, sizeof(union TString))+ \
 #define sizestring(l)	(cast(lu_mem, sizeof(union TString))+ \
-                         (cast(lu_mem, l)+1)*sizeof(l_char))
+                         (cast(lu_mem, l)+1)*sizeof(char))
 
 
 #define sizeudata(l)	(cast(lu_mem, sizeof(union Udata))+(l))
 #define sizeudata(l)	(cast(lu_mem, sizeof(union Udata))+(l))
 
 
 #define luaS_new(L, s)	(luaS_newlstr(L, s, strlen(s)))
 #define luaS_new(L, s)	(luaS_newlstr(L, s, strlen(s)))
-#define luaS_newliteral(L, s)	(luaS_newlstr(L, l_s("") s, \
-                                 (sizeof(s)/sizeof(l_char))-1))
+#define luaS_newliteral(L, s)	(luaS_newlstr(L, "" s, \
+                                 (sizeof(s)/sizeof(char))-1))
 
 
 void luaS_resize (lua_State *L, int newsize);
 void luaS_resize (lua_State *L, int newsize);
 Udata *luaS_newudata (lua_State *L, size_t s);
 Udata *luaS_newudata (lua_State *L, size_t s);
 void luaS_freeall (lua_State *L);
 void luaS_freeall (lua_State *L);
-TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l);
+TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
 
 
 
 
 #endif
 #endif

+ 141 - 136
lstrlib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstrlib.c,v 1.72 2001/10/16 17:41:43 roberto Exp $
+** $Id: lstrlib.c,v 1.73 2001/10/26 17:33:30 roberto Exp $
 ** Standard library for string operations and pattern-matching
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -11,13 +11,18 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lauxlib.h"
 #include "lauxlib.h"
 #include "lualib.h"
 #include "lualib.h"
 
 
 
 
+/* macro to `unsign' a character */
+#ifndef uchar
+#define uchar(c)        ((unsigned char)(c))
+#endif
+
+
 typedef long sint32;	/* a signed version for size_t */
 typedef long sint32;	/* a signed version for size_t */
 
 
 
 
@@ -37,14 +42,14 @@ static sint32 posrelat (sint32 pos, size_t len) {
 
 
 static int str_sub (lua_State *L) {
 static int str_sub (lua_State *L) {
   size_t l;
   size_t l;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
+  const char *s = luaL_check_lstr(L, 1, &l);
   sint32 start = posrelat(luaL_check_long(L, 2), l);
   sint32 start = posrelat(luaL_check_long(L, 2), l);
   sint32 end = posrelat(luaL_opt_long(L, 3, -1), l);
   sint32 end = posrelat(luaL_opt_long(L, 3, -1), l);
   if (start < 1) start = 1;
   if (start < 1) start = 1;
   if (end > (sint32)l) end = l;
   if (end > (sint32)l) end = l;
   if (start <= end)
   if (start <= end)
     lua_pushlstring(L, s+start-1, end-start+1);
     lua_pushlstring(L, s+start-1, end-start+1);
-  else lua_pushliteral(L, l_s(""));
+  else lua_pushliteral(L, "");
   return 1;
   return 1;
 }
 }
 
 
@@ -53,7 +58,7 @@ static int str_lower (lua_State *L) {
   size_t l;
   size_t l;
   size_t i;
   size_t i;
   luaL_Buffer b;
   luaL_Buffer b;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
+  const char *s = luaL_check_lstr(L, 1, &l);
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   for (i=0; i<l; i++)
   for (i=0; i<l; i++)
     luaL_putchar(&b, tolower(uchar(s[i])));
     luaL_putchar(&b, tolower(uchar(s[i])));
@@ -66,7 +71,7 @@ static int str_upper (lua_State *L) {
   size_t l;
   size_t l;
   size_t i;
   size_t i;
   luaL_Buffer b;
   luaL_Buffer b;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
+  const char *s = luaL_check_lstr(L, 1, &l);
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   for (i=0; i<l; i++)
   for (i=0; i<l; i++)
     luaL_putchar(&b, toupper(uchar(s[i])));
     luaL_putchar(&b, toupper(uchar(s[i])));
@@ -77,7 +82,7 @@ static int str_upper (lua_State *L) {
 static int str_rep (lua_State *L) {
 static int str_rep (lua_State *L) {
   size_t l;
   size_t l;
   luaL_Buffer b;
   luaL_Buffer b;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
+  const char *s = luaL_check_lstr(L, 1, &l);
   int n = luaL_check_int(L, 2);
   int n = luaL_check_int(L, 2);
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   while (n-- > 0)
   while (n-- > 0)
@@ -108,9 +113,9 @@ static int str_concat (lua_State *L) {
 
 
 static int str_byte (lua_State *L) {
 static int str_byte (lua_State *L) {
   size_t l;
   size_t l;
-  const l_char *s = luaL_check_lstr(L, 1, &l);
+  const char *s = luaL_check_lstr(L, 1, &l);
   sint32 pos = posrelat(luaL_opt_long(L, 2, 1), l);
   sint32 pos = posrelat(luaL_opt_long(L, 2, 1), l);
-  luaL_arg_check(L, 0 < pos && (size_t)(pos) <= l, 2,  l_s("out of range"));
+  luaL_arg_check(L, 0 < pos && (size_t)(pos) <= l, 2,  "out of range");
   lua_pushnumber(L, uchar(s[pos-1]));
   lua_pushnumber(L, uchar(s[pos-1]));
   return 1;
   return 1;
 }
 }
@@ -123,7 +128,7 @@ static int str_char (lua_State *L) {
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   for (i=1; i<=n; i++) {
   for (i=1; i<=n; i++) {
     int c = luaL_check_int(L, i);
     int c = luaL_check_int(L, i);
-    luaL_arg_check(L, uchar(c) == c, i, l_s("invalid value"));
+    luaL_arg_check(L, uchar(c) == c, i, "invalid value");
     luaL_putchar(&b, uchar(c));
     luaL_putchar(&b, uchar(c));
   }
   }
   luaL_pushresult(&b);
   luaL_pushresult(&b);
@@ -147,25 +152,25 @@ static int str_char (lua_State *L) {
 #define CAP_POSITION	(-2)
 #define CAP_POSITION	(-2)
 
 
 typedef struct MatchState {
 typedef struct MatchState {
-  const l_char *src_init;  /* init of source string */
-  const l_char *src_end;  /* end (`\0') of source string */
+  const char *src_init;  /* init of source string */
+  const char *src_end;  /* end (`\0') of source string */
   int level;  /* total number of captures (finished or unfinished) */
   int level;  /* total number of captures (finished or unfinished) */
   struct {
   struct {
-    const l_char *init;
+    const char *init;
     sint32 len;
     sint32 len;
   } capture[MAX_CAPTURES];
   } capture[MAX_CAPTURES];
   lua_State *L;
   lua_State *L;
 } MatchState;
 } MatchState;
 
 
 
 
-#define ESC		l_c('%')
-#define SPECIALS	l_s("^$*+?.([%-")
+#define ESC		'%'
+#define SPECIALS	"^$*+?.([%-"
 
 
 
 
 static int check_capture (MatchState *ms, int l) {
 static int check_capture (MatchState *ms, int l) {
-  l -= l_c('1');
+  l -= '1';
   if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
   if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
-    lua_error(ms->L, l_s("invalid capture index"));
+    lua_error(ms->L, "invalid capture index");
   return l;
   return l;
 }
 }
 
 
@@ -174,25 +179,25 @@ static int capture_to_close (MatchState *ms) {
   int level = ms->level;
   int level = ms->level;
   for (level--; level>=0; level--)
   for (level--; level>=0; level--)
     if (ms->capture[level].len == CAP_UNFINISHED) return level;
     if (ms->capture[level].len == CAP_UNFINISHED) return level;
-  lua_error(ms->L, l_s("invalid pattern capture"));
+  lua_error(ms->L, "invalid pattern capture");
   return 0;  /* to avoid warnings */
   return 0;  /* to avoid warnings */
 }
 }
 
 
 
 
-static const l_char *luaI_classend (MatchState *ms, const l_char *p) {
+static const char *luaI_classend (MatchState *ms, const char *p) {
   switch (*p++) {
   switch (*p++) {
     case ESC:
     case ESC:
-      if (*p == l_c('\0'))
-        lua_error(ms->L, l_s("malformed pattern (ends with `%')"));
+      if (*p == '\0')
+        lua_error(ms->L, "malformed pattern (ends with `%')");
       return p+1;
       return p+1;
-    case l_c('['):
-      if (*p == l_c('^')) p++;
+    case '[':
+      if (*p == '^') p++;
       do {  /* look for a `]' */
       do {  /* look for a `]' */
-        if (*p == l_c('\0'))
-          lua_error(ms->L, l_s("malformed pattern (missing `]')"));
-        if (*(p++) == ESC && *p != l_c('\0'))
+        if (*p == '\0')
+          lua_error(ms->L, "malformed pattern (missing `]')");
+        if (*(p++) == ESC && *p != '\0')
           p++;  /* skip escapes (e.g. `%]') */
           p++;  /* skip escapes (e.g. `%]') */
-      } while (*p != l_c(']'));
+      } while (*p != ']');
       return p+1;
       return p+1;
     default:
     default:
       return p;
       return p;
@@ -200,28 +205,28 @@ static const l_char *luaI_classend (MatchState *ms, const l_char *p) {
 }
 }
 
 
 
 
-static int match_class (l_charint c, l_charint cl) {
+static int match_class (int c, int cl) {
   int res;
   int res;
   switch (tolower(cl)) {
   switch (tolower(cl)) {
-    case l_c('a') : res = isalpha(c); break;
-    case l_c('c') : res = iscntrl(c); break;
-    case l_c('d') : res = isdigit(c); break;
-    case l_c('l') : res = islower(c); break;
-    case l_c('p') : res = ispunct(c); break;
-    case l_c('s') : res = isspace(c); break;
-    case l_c('u') : res = isupper(c); break;
-    case l_c('w') : res = isalnum(c); break;
-    case l_c('x') : res = isxdigit(c); break;
-    case l_c('z') : res = (c == 0); break;
+    case 'a' : res = isalpha(c); break;
+    case 'c' : res = iscntrl(c); break;
+    case 'd' : res = isdigit(c); break;
+    case 'l' : res = islower(c); break;
+    case 'p' : res = ispunct(c); break;
+    case 's' : res = isspace(c); break;
+    case 'u' : res = isupper(c); break;
+    case 'w' : res = isalnum(c); break;
+    case 'x' : res = isxdigit(c); break;
+    case 'z' : res = (c == 0); break;
     default: return (cl == c);
     default: return (cl == c);
   }
   }
   return (islower(cl) ? res : !res);
   return (islower(cl) ? res : !res);
 }
 }
 
 
 
 
-static int matchbracketclass (l_charint c, const l_char *p, const l_char *ec) {
+static int matchbracketclass (int c, const char *p, const char *ec) {
   int sig = 1;
   int sig = 1;
-  if (*(p+1) == l_c('^')) {
+  if (*(p+1) == '^') {
     sig = 0;
     sig = 0;
     p++;  /* skip the `^' */
     p++;  /* skip the `^' */
   }
   }
@@ -231,7 +236,7 @@ static int matchbracketclass (l_charint c, const l_char *p, const l_char *ec) {
       if (match_class(c, *p))
       if (match_class(c, *p))
         return sig;
         return sig;
     }
     }
-    else if ((*(p+1) == l_c('-')) && (p+2 < ec)) {
+    else if ((*(p+1) == '-') && (p+2 < ec)) {
       p+=2;
       p+=2;
       if (uchar(*(p-2)) <= c && c <= uchar(*p))
       if (uchar(*(p-2)) <= c && c <= uchar(*p))
         return sig;
         return sig;
@@ -242,13 +247,13 @@ static int matchbracketclass (l_charint c, const l_char *p, const l_char *ec) {
 }
 }
 
 
 
 
-static int luaI_singlematch (l_charint c, const l_char *p, const l_char *ep) {
+static int luaI_singlematch (int c, const char *p, const char *ep) {
   switch (*p) {
   switch (*p) {
-    case l_c('.'):  /* matches any char */
+    case '.':  /* matches any char */
       return 1;
       return 1;
     case ESC:
     case ESC:
       return match_class(c, *(p+1));
       return match_class(c, *(p+1));
-    case l_c('['):
+    case '[':
       return matchbracketclass(c, p, ep-1);
       return matchbracketclass(c, p, ep-1);
     default:
     default:
       return (uchar(*p) == c);
       return (uchar(*p) == c);
@@ -256,13 +261,13 @@ static int luaI_singlematch (l_charint c, const l_char *p, const l_char *ep) {
 }
 }
 
 
 
 
-static const l_char *match (MatchState *ms, const l_char *s, const l_char *p);
+static const char *match (MatchState *ms, const char *s, const char *p);
 
 
 
 
-static const l_char *matchbalance (MatchState *ms, const l_char *s,
-                                   const l_char *p) {
+static const char *matchbalance (MatchState *ms, const char *s,
+                                   const char *p) {
   if (*p == 0 || *(p+1) == 0)
   if (*p == 0 || *(p+1) == 0)
-    lua_error(ms->L, l_s("unbalanced pattern"));
+    lua_error(ms->L, "unbalanced pattern");
   if (*s != *p) return NULL;
   if (*s != *p) return NULL;
   else {
   else {
     int b = *p;
     int b = *p;
@@ -279,14 +284,14 @@ static const l_char *matchbalance (MatchState *ms, const l_char *s,
 }
 }
 
 
 
 
-static const l_char *max_expand (MatchState *ms, const l_char *s,
-                                 const l_char *p, const l_char *ep) {
+static const char *max_expand (MatchState *ms, const char *s,
+                                 const char *p, const char *ep) {
   sint32 i = 0;  /* counts maximum expand for item */
   sint32 i = 0;  /* counts maximum expand for item */
   while ((s+i)<ms->src_end && luaI_singlematch(uchar(*(s+i)), p, ep))
   while ((s+i)<ms->src_end && luaI_singlematch(uchar(*(s+i)), p, ep))
     i++;
     i++;
   /* keeps trying to match with the maximum repetitions */
   /* keeps trying to match with the maximum repetitions */
   while (i>=0) {
   while (i>=0) {
-    const l_char *res = match(ms, (s+i), ep+1);
+    const char *res = match(ms, (s+i), ep+1);
     if (res) return res;
     if (res) return res;
     i--;  /* else didn't match; reduce 1 repetition to try again */
     i--;  /* else didn't match; reduce 1 repetition to try again */
   }
   }
@@ -294,10 +299,10 @@ static const l_char *max_expand (MatchState *ms, const l_char *s,
 }
 }
 
 
 
 
-static const l_char *min_expand (MatchState *ms, const l_char *s,
-                                 const l_char *p, const l_char *ep) {
+static const char *min_expand (MatchState *ms, const char *s,
+                                 const char *p, const char *ep) {
   for (;;) {
   for (;;) {
-    const l_char *res = match(ms, s, ep+1);
+    const char *res = match(ms, s, ep+1);
     if (res != NULL)
     if (res != NULL)
       return res;
       return res;
     else if (s<ms->src_end && luaI_singlematch(uchar(*s), p, ep))
     else if (s<ms->src_end && luaI_singlematch(uchar(*s), p, ep))
@@ -307,11 +312,11 @@ static const l_char *min_expand (MatchState *ms, const l_char *s,
 }
 }
 
 
 
 
-static const l_char *start_capture (MatchState *ms, const l_char *s,
-                                    const l_char *p, int what) {
-  const l_char *res;
+static const char *start_capture (MatchState *ms, const char *s,
+                                    const char *p, int what) {
+  const char *res;
   int level = ms->level;
   int level = ms->level;
-  if (level >= MAX_CAPTURES) lua_error(ms->L, l_s("too many captures"));
+  if (level >= MAX_CAPTURES) lua_error(ms->L, "too many captures");
   ms->capture[level].init = s;
   ms->capture[level].init = s;
   ms->capture[level].len = what;
   ms->capture[level].len = what;
   ms->level = level+1;
   ms->level = level+1;
@@ -321,10 +326,10 @@ static const l_char *start_capture (MatchState *ms, const l_char *s,
 }
 }
 
 
 
 
-static const l_char *end_capture (MatchState *ms, const l_char *s,
-                                  const l_char *p) {
+static const char *end_capture (MatchState *ms, const char *s,
+                                  const char *p) {
   int l = capture_to_close(ms);
   int l = capture_to_close(ms);
-  const l_char *res;
+  const char *res;
   ms->capture[l].len = s - ms->capture[l].init;  /* close capture */
   ms->capture[l].len = s - ms->capture[l].init;  /* close capture */
   if ((res = match(ms, s, p)) == NULL)  /* match failed? */
   if ((res = match(ms, s, p)) == NULL)  /* match failed? */
     ms->capture[l].len = CAP_UNFINISHED;  /* undo capture */
     ms->capture[l].len = CAP_UNFINISHED;  /* undo capture */
@@ -332,7 +337,7 @@ static const l_char *end_capture (MatchState *ms, const l_char *s,
 }
 }
 
 
 
 
-static const l_char *match_capture (MatchState *ms, const l_char *s, int l) {
+static const char *match_capture (MatchState *ms, const char *s, int l) {
   size_t len;
   size_t len;
   l = check_capture(ms, l);
   l = check_capture(ms, l);
   len = ms->capture[l].len;
   len = ms->capture[l].len;
@@ -343,15 +348,15 @@ static const l_char *match_capture (MatchState *ms, const l_char *s, int l) {
 }
 }
 
 
 
 
-static const l_char *match (MatchState *ms, const l_char *s, const l_char *p) {
+static const char *match (MatchState *ms, const char *s, const char *p) {
   init: /* using goto's to optimize tail recursion */
   init: /* using goto's to optimize tail recursion */
   switch (*p) {
   switch (*p) {
-    case l_c('('):  /* start capture */
-      if (*(p+1) == l_c(')'))  /* position capture? */
+    case '(':  /* start capture */
+      if (*(p+1) == ')')  /* position capture? */
         return start_capture(ms, s, p+2, CAP_POSITION);
         return start_capture(ms, s, p+2, CAP_POSITION);
       else
       else
         return start_capture(ms, s, p+1, CAP_UNFINISHED);
         return start_capture(ms, s, p+1, CAP_UNFINISHED);
-    case l_c(')'):  /* end capture */
+    case ')':  /* end capture */
       return end_capture(ms, s, p+1);
       return end_capture(ms, s, p+1);
     case ESC:  /* may be %[0-9] or %b */
     case ESC:  /* may be %[0-9] or %b */
       if (isdigit(uchar(*(p+1)))) {  /* capture? */
       if (isdigit(uchar(*(p+1)))) {  /* capture? */
@@ -359,33 +364,33 @@ static const l_char *match (MatchState *ms, const l_char *s, const l_char *p) {
         if (s == NULL) return NULL;
         if (s == NULL) return NULL;
         p+=2; goto init;  /* else return match(ms, s, p+2) */
         p+=2; goto init;  /* else return match(ms, s, p+2) */
       }
       }
-      else if (*(p+1) == l_c('b')) {  /* balanced string? */
+      else if (*(p+1) == 'b') {  /* balanced string? */
         s = matchbalance(ms, s, p+2);
         s = matchbalance(ms, s, p+2);
         if (s == NULL) return NULL;
         if (s == NULL) return NULL;
         p+=4; goto init;  /* else return match(ms, s, p+4); */
         p+=4; goto init;  /* else return match(ms, s, p+4); */
       }
       }
       else goto dflt;  /* case default */
       else goto dflt;  /* case default */
-    case l_c('\0'):  /* end of pattern */
+    case '\0':  /* end of pattern */
       return s;  /* match succeeded */
       return s;  /* match succeeded */
-    case l_c('$'):
-      if (*(p+1) == l_c('\0'))  /* is the `$' the last char in pattern? */
+    case '$':
+      if (*(p+1) == '\0')  /* is the `$' the last char in pattern? */
         return (s == ms->src_end) ? s : NULL;  /* check end of string */
         return (s == ms->src_end) ? s : NULL;  /* check end of string */
       else goto dflt;
       else goto dflt;
     default: dflt: {  /* it is a pattern item */
     default: dflt: {  /* it is a pattern item */
-      const l_char *ep = luaI_classend(ms, p);  /* points to what is next */
+      const char *ep = luaI_classend(ms, p);  /* points to what is next */
       int m = s<ms->src_end && luaI_singlematch(uchar(*s), p, ep);
       int m = s<ms->src_end && luaI_singlematch(uchar(*s), p, ep);
       switch (*ep) {
       switch (*ep) {
-        case l_c('?'): {  /* optional */
-          const l_char *res;
+        case '?': {  /* optional */
+          const char *res;
           if (m && ((res=match(ms, s+1, ep+1)) != NULL))
           if (m && ((res=match(ms, s+1, ep+1)) != NULL))
             return res;
             return res;
           p=ep+1; goto init;  /* else return match(ms, s, ep+1); */
           p=ep+1; goto init;  /* else return match(ms, s, ep+1); */
         }
         }
-        case l_c('*'):  /* 0 or more repetitions */
+        case '*':  /* 0 or more repetitions */
           return max_expand(ms, s, p, ep);
           return max_expand(ms, s, p, ep);
-        case l_c('+'):  /* 1 or more repetitions */
+        case '+':  /* 1 or more repetitions */
           return (m ? max_expand(ms, s+1, p, ep) : NULL);
           return (m ? max_expand(ms, s+1, p, ep) : NULL);
-        case l_c('-'):  /* 0 or more repetitions (minimum) */
+        case '-':  /* 0 or more repetitions (minimum) */
           return min_expand(ms, s, p, ep);
           return min_expand(ms, s, p, ep);
         default:
         default:
           if (!m) return NULL;
           if (!m) return NULL;
@@ -397,15 +402,15 @@ static const l_char *match (MatchState *ms, const l_char *s, const l_char *p) {
 
 
 
 
 
 
-static const l_char *lmemfind (const l_char *s1, size_t l1,
-                               const l_char *s2, size_t l2) {
+static const char *lmemfind (const char *s1, size_t l1,
+                               const char *s2, size_t l2) {
   if (l2 == 0) return s1;  /* empty strings are everywhere */
   if (l2 == 0) return s1;  /* empty strings are everywhere */
   else if (l2 > l1) return NULL;  /* avoids a negative `l1' */
   else if (l2 > l1) return NULL;  /* avoids a negative `l1' */
   else {
   else {
-    const l_char *init;  /* to search for a `*s2' inside `s1' */
+    const char *init;  /* to search for a `*s2' inside `s1' */
     l2--;  /* 1st char will be checked by `memchr' */
     l2--;  /* 1st char will be checked by `memchr' */
     l1 = l1-l2;  /* `s2' cannot be found after that */
     l1 = l1-l2;  /* `s2' cannot be found after that */
-    while (l1 > 0 && (init = (const l_char *)memchr(s1, *s2, l1)) != NULL) {
+    while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
       init++;   /* 1st char is already checked */
       init++;   /* 1st char is already checked */
       if (memcmp(init, s2+1, l2) == 0)
       if (memcmp(init, s2+1, l2) == 0)
         return init-1;
         return init-1;
@@ -421,7 +426,7 @@ static const l_char *lmemfind (const l_char *s1, size_t l1,
 
 
 static void push_onecapture (MatchState *ms, int i) {
 static void push_onecapture (MatchState *ms, int i) {
   int l = ms->capture[i].len;
   int l = ms->capture[i].len;
-  if (l == CAP_UNFINISHED) lua_error(ms->L, l_s("unfinished capture"));
+  if (l == CAP_UNFINISHED) lua_error(ms->L, "unfinished capture");
   if (l == CAP_POSITION)
   if (l == CAP_POSITION)
     lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1);
     lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1);
   else
   else
@@ -431,7 +436,7 @@ static void push_onecapture (MatchState *ms, int i) {
 
 
 static int push_captures (MatchState *ms) {
 static int push_captures (MatchState *ms) {
   int i;
   int i;
-  luaL_check_stack(ms->L, ms->level, l_s("too many captures"));
+  luaL_check_stack(ms->L, ms->level, "too many captures");
   for (i=0; i<ms->level; i++)
   for (i=0; i<ms->level; i++)
     push_onecapture(ms, i);
     push_onecapture(ms, i);
   return ms->level;  /* number of strings pushed */
   return ms->level;  /* number of strings pushed */
@@ -440,13 +445,13 @@ static int push_captures (MatchState *ms) {
 
 
 static int str_find (lua_State *L) {
 static int str_find (lua_State *L) {
   size_t l1, l2;
   size_t l1, l2;
-  const l_char *s = luaL_check_lstr(L, 1, &l1);
-  const l_char *p = luaL_check_lstr(L, 2, &l2);
+  const char *s = luaL_check_lstr(L, 1, &l1);
+  const char *p = luaL_check_lstr(L, 2, &l2);
   sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1;
   sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1;
-  luaL_arg_check(L, 0 <= init && (size_t)(init) <= l1, 3, l_s("out of range"));
+  luaL_arg_check(L, 0 <= init && (size_t)(init) <= l1, 3, "out of range");
   if (lua_gettop(L) > 3 ||  /* extra argument? */
   if (lua_gettop(L) > 3 ||  /* extra argument? */
       strpbrk(p, SPECIALS) == NULL) {  /* or no special characters? */
       strpbrk(p, SPECIALS) == NULL) {  /* or no special characters? */
-    const l_char *s2 = lmemfind(s+init, l1-init, p, l2);
+    const char *s2 = lmemfind(s+init, l1-init, p, l2);
     if (s2) {
     if (s2) {
       lua_pushnumber(L, s2-s+1);
       lua_pushnumber(L, s2-s+1);
       lua_pushnumber(L, s2-s+l2);
       lua_pushnumber(L, s2-s+l2);
@@ -455,13 +460,13 @@ static int str_find (lua_State *L) {
   }
   }
   else {
   else {
     MatchState ms;
     MatchState ms;
-    int anchor = (*p == l_c('^')) ? (p++, 1) : 0;
-    const l_char *s1=s+init;
+    int anchor = (*p == '^') ? (p++, 1) : 0;
+    const char *s1=s+init;
     ms.L = L;
     ms.L = L;
     ms.src_init = s;
     ms.src_init = s;
     ms.src_end = s+l1;
     ms.src_end = s+l1;
     do {
     do {
-      const l_char *res;
+      const char *res;
       ms.level = 0;
       ms.level = 0;
       if ((res=match(&ms, s1, p)) != NULL) {
       if ((res=match(&ms, s1, p)) != NULL) {
         lua_pushnumber(L, s1-s+1);  /* start */
         lua_pushnumber(L, s1-s+1);  /* start */
@@ -478,7 +483,7 @@ static int str_find (lua_State *L) {
 static void add_s (MatchState *ms, luaL_Buffer *b) {
 static void add_s (MatchState *ms, luaL_Buffer *b) {
   lua_State *L = ms->L;
   lua_State *L = ms->L;
   if (lua_isstring(L, 3)) {
   if (lua_isstring(L, 3)) {
-    const l_char *news = lua_tostring(L, 3);
+    const char *news = lua_tostring(L, 3);
     size_t l = lua_strlen(L, 3);
     size_t l = lua_strlen(L, 3);
     size_t i;
     size_t i;
     for (i=0; i<l; i++) {
     for (i=0; i<l; i++) {
@@ -511,22 +516,22 @@ static void add_s (MatchState *ms, luaL_Buffer *b) {
 
 
 static int str_gsub (lua_State *L) {
 static int str_gsub (lua_State *L) {
   size_t srcl;
   size_t srcl;
-  const l_char *src = luaL_check_lstr(L, 1, &srcl);
-  const l_char *p = luaL_check_string(L, 2);
+  const char *src = luaL_check_lstr(L, 1, &srcl);
+  const char *p = luaL_check_string(L, 2);
   int max_s = luaL_opt_int(L, 4, srcl+1);
   int max_s = luaL_opt_int(L, 4, srcl+1);
-  int anchor = (*p == l_c('^')) ? (p++, 1) : 0;
+  int anchor = (*p == '^') ? (p++, 1) : 0;
   int n = 0;
   int n = 0;
   MatchState ms;
   MatchState ms;
   luaL_Buffer b;
   luaL_Buffer b;
   luaL_arg_check(L,
   luaL_arg_check(L,
     lua_gettop(L) >= 3 && (lua_isstring(L, 3) || lua_isfunction(L, 3)),
     lua_gettop(L) >= 3 && (lua_isstring(L, 3) || lua_isfunction(L, 3)),
-    3, l_s("string or function expected"));
+    3, "string or function expected");
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   ms.L = L;
   ms.L = L;
   ms.src_init = src;
   ms.src_init = src;
   ms.src_end = src+srcl;
   ms.src_end = src+srcl;
   while (n < max_s) {
   while (n < max_s) {
-    const l_char *e;
+    const char *e;
     ms.level = 0;
     ms.level = 0;
     e = match(&ms, src, p);
     e = match(&ms, src, p);
     if (e) {
     if (e) {
@@ -557,40 +562,40 @@ static int str_gsub (lua_State *L) {
 
 
 static void luaI_addquoted (lua_State *L, luaL_Buffer *b, int arg) {
 static void luaI_addquoted (lua_State *L, luaL_Buffer *b, int arg) {
   size_t l;
   size_t l;
-  const l_char *s = luaL_check_lstr(L, arg, &l);
-  luaL_putchar(b, l_c('"'));
+  const char *s = luaL_check_lstr(L, arg, &l);
+  luaL_putchar(b, '"');
   while (l--) {
   while (l--) {
     switch (*s) {
     switch (*s) {
-      case l_c('"'):  case l_c('\\'):  case l_c('\n'):
-        luaL_putchar(b, l_c('\\'));
+      case '"':  case '\\':  case '\n':
+        luaL_putchar(b, '\\');
         luaL_putchar(b, *s);
         luaL_putchar(b, *s);
         break;
         break;
-      case l_c('\0'): luaL_addlstring(b, l_s("\\000"), 4); break;
+      case '\0': luaL_addlstring(b, "\\000", 4); break;
       default: luaL_putchar(b, *s);
       default: luaL_putchar(b, *s);
     }
     }
     s++;
     s++;
   }
   }
-  luaL_putchar(b, l_c('"'));
+  luaL_putchar(b, '"');
 }
 }
 
 
 
 
-static const l_char *scanformat (lua_State *L, const l_char *strfrmt,
-                                 l_char *form, int *hasprecision) {
-  const l_char *p = strfrmt;
-  while (strchr(l_s("-+ #0"), *p)) p++;  /* skip flags */
+static const char *scanformat (lua_State *L, const char *strfrmt,
+                                 char *form, int *hasprecision) {
+  const char *p = strfrmt;
+  while (strchr("-+ #0", *p)) p++;  /* skip flags */
   if (isdigit(uchar(*p))) p++;  /* skip width */
   if (isdigit(uchar(*p))) p++;  /* skip width */
   if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
   if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
-  if (*p == l_c('.')) {
+  if (*p == '.') {
     p++;
     p++;
     *hasprecision = 1;
     *hasprecision = 1;
     if (isdigit(uchar(*p))) p++;  /* skip precision */
     if (isdigit(uchar(*p))) p++;  /* skip precision */
     if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
     if (isdigit(uchar(*p))) p++;  /* (2 digits at most) */
   }
   }
   if (isdigit(uchar(*p)))
   if (isdigit(uchar(*p)))
-    lua_error(L, l_s("invalid format (width or precision too long)"));
+    lua_error(L, "invalid format (width or precision too long)");
   if (p-strfrmt+2 > MAX_FORMAT)  /* +2 to include `%' and the specifier */
   if (p-strfrmt+2 > MAX_FORMAT)  /* +2 to include `%' and the specifier */
-    lua_error(L, l_s("invalid format (too long)"));
-  form[0] = l_c('%');
+    lua_error(L, "invalid format (too long)");
+  form[0] = '%';
   strncpy(form+1, strfrmt, p-strfrmt+1);
   strncpy(form+1, strfrmt, p-strfrmt+1);
   form[p-strfrmt+2] = 0;
   form[p-strfrmt+2] = 0;
   return p;
   return p;
@@ -600,40 +605,40 @@ static const l_char *scanformat (lua_State *L, const l_char *strfrmt,
 static int str_format (lua_State *L) {
 static int str_format (lua_State *L) {
   int arg = 1;
   int arg = 1;
   size_t sfl;
   size_t sfl;
-  const l_char *strfrmt = luaL_check_lstr(L, arg, &sfl);
-  const l_char *strfrmt_end = strfrmt+sfl;
+  const char *strfrmt = luaL_check_lstr(L, arg, &sfl);
+  const char *strfrmt_end = strfrmt+sfl;
   luaL_Buffer b;
   luaL_Buffer b;
   luaL_buffinit(L, &b);
   luaL_buffinit(L, &b);
   while (strfrmt < strfrmt_end) {
   while (strfrmt < strfrmt_end) {
-    if (*strfrmt != l_c('%'))
+    if (*strfrmt != '%')
       luaL_putchar(&b, *strfrmt++);
       luaL_putchar(&b, *strfrmt++);
-    else if (*++strfrmt == l_c('%'))
+    else if (*++strfrmt == '%')
       luaL_putchar(&b, *strfrmt++);  /* %% */
       luaL_putchar(&b, *strfrmt++);  /* %% */
     else { /* format item */
     else { /* format item */
-      l_char form[MAX_FORMAT];  /* to store the format (`%...') */
-      l_char buff[MAX_ITEM];  /* to store the formatted item */
+      char form[MAX_FORMAT];  /* to store the format (`%...') */
+      char buff[MAX_ITEM];  /* to store the formatted item */
       int hasprecision = 0;
       int hasprecision = 0;
-      if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == l_c('$'))
-        lua_error(L, l_s("obsolete `format' option (d$)"));
+      if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$')
+        lua_error(L, "obsolete `format' option (d$)");
       arg++;
       arg++;
       strfrmt = scanformat(L, strfrmt, form, &hasprecision);
       strfrmt = scanformat(L, strfrmt, form, &hasprecision);
       switch (*strfrmt++) {
       switch (*strfrmt++) {
-        case l_c('c'):  case l_c('d'):  case l_c('i'):
+        case 'c':  case 'd':  case 'i':
           sprintf(buff, form, luaL_check_int(L, arg));
           sprintf(buff, form, luaL_check_int(L, arg));
           break;
           break;
-        case l_c('o'):  case l_c('u'):  case l_c('x'):  case l_c('X'):
+        case 'o':  case 'u':  case 'x':  case 'X':
           sprintf(buff, form, (unsigned int)(luaL_check_number(L, arg)));
           sprintf(buff, form, (unsigned int)(luaL_check_number(L, arg)));
           break;
           break;
-        case l_c('e'):  case l_c('E'): case l_c('f'):
-        case l_c('g'): case l_c('G'):
+        case 'e':  case 'E': case 'f':
+        case 'g': case 'G':
           sprintf(buff, form, luaL_check_number(L, arg));
           sprintf(buff, form, luaL_check_number(L, arg));
           break;
           break;
-        case l_c('q'):
+        case 'q':
           luaI_addquoted(L, &b, arg);
           luaI_addquoted(L, &b, arg);
           continue;  /* skip the `addsize' at the end */
           continue;  /* skip the `addsize' at the end */
-        case l_c('s'): {
+        case 's': {
           size_t l;
           size_t l;
-          const l_char *s = luaL_check_lstr(L, arg, &l);
+          const char *s = luaL_check_lstr(L, arg, &l);
           if (!hasprecision && l >= 100) {
           if (!hasprecision && l >= 100) {
             /* no precision and string is too long to be formatted;
             /* no precision and string is too long to be formatted;
                keep original string */
                keep original string */
@@ -647,7 +652,7 @@ static int str_format (lua_State *L) {
           }
           }
         }
         }
         default:  /* also treat cases `pnLlh' */
         default:  /* also treat cases `pnLlh' */
-          lua_error(L, l_s("invalid option in `format'"));
+          lua_error(L, "invalid option in `format'");
       }
       }
       luaL_addlstring(&b, buff, strlen(buff));
       luaL_addlstring(&b, buff, strlen(buff));
     }
     }
@@ -658,17 +663,17 @@ static int str_format (lua_State *L) {
 
 
 
 
 static const luaL_reg strlib[] = {
 static const luaL_reg strlib[] = {
-{l_s("strlen"), str_len},
-{l_s("strsub"), str_sub},
-{l_s("strlower"), str_lower},
-{l_s("strupper"), str_upper},
-{l_s("strchar"), str_char},
-{l_s("strrep"), str_rep},
-{l_s("strbyte"), str_byte},
-{l_s("concat"), str_concat},
-{l_s("format"), str_format},
-{l_s("strfind"), str_find},
-{l_s("gsub"), str_gsub}
+{"strlen", str_len},
+{"strsub", str_sub},
+{"strlower", str_lower},
+{"strupper", str_upper},
+{"strchar", str_char},
+{"strrep", str_rep},
+{"strbyte", str_byte},
+{"concat", str_concat},
+{"format", str_format},
+{"strfind", str_find},
+{"gsub", str_gsub}
 };
 };
 
 
 
 

+ 5 - 6
ltable.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltable.c,v 1.87 2001/10/25 19:14:14 roberto Exp $
+** $Id: ltable.c,v 1.88 2001/11/16 16:29:51 roberto Exp $
 ** Lua tables (hash)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -23,7 +23,6 @@
 
 
 
 
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldo.h"
 #include "ldo.h"
@@ -101,7 +100,7 @@ int luaH_index (lua_State *L, Table *t, const TObject *key) {
   else {
   else {
     const TObject *v = luaH_get(t, key);
     const TObject *v = luaH_get(t, key);
     if (v == &luaO_nilobject)
     if (v == &luaO_nilobject)
-      luaD_error(L, l_s("invalid key for `next'"));
+      luaD_error(L, "invalid key for `next'");
     i = cast(int, (cast(const lu_byte *, v) -
     i = cast(int, (cast(const lu_byte *, v) -
                    cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node));
                    cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node));
     return i + t->sizearray;  /* hash elements are numbered after array ones */
     return i + t->sizearray;  /* hash elements are numbered after array ones */
@@ -193,7 +192,7 @@ static void numuse (const Table *t, int *narray, int *nhash) {
 static void setarrayvector (lua_State *L, Table *t, int size) {
 static void setarrayvector (lua_State *L, Table *t, int size) {
   int i;
   int i;
   if (size > twoto(MAXBITS))
   if (size > twoto(MAXBITS))
-    luaD_error(L, l_s("table overflow"));
+    luaD_error(L, "table overflow");
   luaM_reallocvector(L, t->array, t->sizearray, size, TObject);
   luaM_reallocvector(L, t->array, t->sizearray, size, TObject);
   for (i=t->sizearray; i<size; i++)
   for (i=t->sizearray; i<size; i++)
      setnilvalue(&t->array[i]);
      setnilvalue(&t->array[i]);
@@ -206,7 +205,7 @@ static void setnodevector (lua_State *L, Table *t, int lsize) {
   int size;
   int size;
   if (lsize < MINHASHSIZE) lsize = MINHASHSIZE;
   if (lsize < MINHASHSIZE) lsize = MINHASHSIZE;
   else if (lsize > MAXBITS)
   else if (lsize > MAXBITS)
-    luaD_error(L, l_s("table overflow"));
+    luaD_error(L, "table overflow");
   size = twoto(lsize);
   size = twoto(lsize);
   t->node = luaM_newvector(L, size, Node);
   t->node = luaM_newvector(L, size, Node);
   for (i=0; i<size; i++) {
   for (i=0; i<size; i++) {
@@ -417,7 +416,7 @@ void luaH_set (lua_State *L, Table *t, const TObject *key, const TObject *val) {
     settableval(p, val);
     settableval(p, val);
   }
   }
   else {
   else {
-    if (ttype(key) == LUA_TNIL) luaD_error(L, l_s("table index is nil"));
+    if (ttype(key) == LUA_TNIL) luaD_error(L, "table index is nil");
     newkey(L, t, key, val);
     newkey(L, t, key, val);
   }
   }
 }
 }

+ 107 - 108
ltests.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltests.c,v 1.95 2001/10/26 17:33:30 roberto Exp $
+** $Id: ltests.c,v 1.96 2001/11/06 21:41:43 roberto Exp $
 ** Internal Module for Debugging of the Lua Implementation
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -12,7 +12,6 @@
 #include <string.h>
 #include <string.h>
 
 
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lapi.h"
 #include "lapi.h"
@@ -43,7 +42,7 @@ int islocked = 0;
 
 
 
 
 
 
-static void setnameval (lua_State *L, const l_char *name, int val) {
+static void setnameval (lua_State *L, const char *name, int val) {
   lua_pushstring(L, name);
   lua_pushstring(L, name);
   lua_pushnumber(L, val);
   lua_pushnumber(L, val);
   lua_settable(L, -3);
   lua_settable(L, -3);
@@ -139,21 +138,21 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) {
 */
 */
 
 
 
 
-static l_char *buildop (Proto *p, int pc, l_char *buff) {
+static char *buildop (Proto *p, int pc, char *buff) {
   Instruction i = p->code[pc];
   Instruction i = p->code[pc];
   OpCode o = GET_OPCODE(i);
   OpCode o = GET_OPCODE(i);
-  const l_char *name = luaP_opnames[o];
-  sprintf(buff, l_s("%4d - "), pc);
+  const char *name = luaP_opnames[o];
+  sprintf(buff, "%4d - ", pc);
   switch (getOpMode(o)) {  
   switch (getOpMode(o)) {  
     case iABC:
     case iABC:
-      sprintf(buff+strlen(buff), l_s("%-12s%4d %4d %4d"), name,
+      sprintf(buff+strlen(buff), "%-12s%4d %4d %4d", name,
               GETARG_A(i), GETARG_B(i), GETARG_C(i));
               GETARG_A(i), GETARG_B(i), GETARG_C(i));
       break;
       break;
     case iABc:
     case iABc:
-      sprintf(buff+strlen(buff), l_s("%-12s%4d %4d"), name, GETARG_A(i), GETARG_Bc(i));
+      sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_Bc(i));
       break;
       break;
     case iAsBc:
     case iAsBc:
-      sprintf(buff+strlen(buff), l_s("%-12s%4d %4d"), name, GETARG_A(i), GETARG_sBc(i));
+      sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_sBc(i));
       break;
       break;
   }
   }
   return buff;
   return buff;
@@ -164,13 +163,13 @@ static int listcode (lua_State *L) {
   int pc;
   int pc;
   Proto *p;
   Proto *p;
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
-                 1, l_s("Lua function expected"));
+                 1, "Lua function expected");
   p = clvalue(luaA_index(L, 1))->l.p;
   p = clvalue(luaA_index(L, 1))->l.p;
   lua_newtable(L);
   lua_newtable(L);
-  setnameval(L, l_s("maxstack"), p->maxstacksize);
-  setnameval(L, l_s("numparams"), p->numparams);
+  setnameval(L, "maxstack", p->maxstacksize);
+  setnameval(L, "numparams", p->numparams);
   for (pc=0; pc<p->sizecode; pc++) {
   for (pc=0; pc<p->sizecode; pc++) {
-    l_char buff[100];
+    char buff[100];
     lua_pushnumber(L, pc+1);
     lua_pushnumber(L, pc+1);
     lua_pushstring(L, buildop(p, pc, buff));
     lua_pushstring(L, buildop(p, pc, buff));
     lua_settable(L, -3);
     lua_settable(L, -3);
@@ -183,7 +182,7 @@ static int listk (lua_State *L) {
   Proto *p;
   Proto *p;
   int i;
   int i;
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
-                 1, l_s("Lua function expected"));
+                 1, "Lua function expected");
   p = clvalue(luaA_index(L, 1))->l.p;
   p = clvalue(luaA_index(L, 1))->l.p;
   lua_newtable(L);
   lua_newtable(L);
   for (i=0; i<p->sizek; i++) {
   for (i=0; i<p->sizek; i++) {
@@ -199,9 +198,9 @@ static int listlocals (lua_State *L) {
   Proto *p;
   Proto *p;
   int pc = luaL_check_int(L, 2) - 1;
   int pc = luaL_check_int(L, 2) - 1;
   int i = 0;
   int i = 0;
-  const l_char *name;
+  const char *name;
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
   luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
-                 1, l_s("Lua function expected"));
+                 1, "Lua function expected");
   p = clvalue(luaA_index(L, 1))->l.p;
   p = clvalue(luaA_index(L, 1))->l.p;
   while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
   while ((name = luaF_getlocalname(p, ++i, pc)) != NULL)
     lua_pushstring(L, name);
     lua_pushstring(L, name);
@@ -215,12 +214,12 @@ static int listlocals (lua_State *L) {
 
 
 static int get_limits (lua_State *L) {
 static int get_limits (lua_State *L) {
   lua_newtable(L);
   lua_newtable(L);
-  setnameval(L, l_s("BITS_INT"), BITS_INT);
-  setnameval(L, l_s("LFPF"), LFIELDS_PER_FLUSH);
-  setnameval(L, l_s("MAXLOCALS"), MAXLOCALS);
-  setnameval(L, l_s("MAXPARAMS"), MAXPARAMS);
-  setnameval(L, l_s("MAXSTACK"), MAXSTACK);
-  setnameval(L, l_s("MAXUPVALUES"), MAXUPVALUES);
+  setnameval(L, "BITS_INT", BITS_INT);
+  setnameval(L, "LFPF", LFIELDS_PER_FLUSH);
+  setnameval(L, "MAXLOCALS", MAXLOCALS);
+  setnameval(L, "MAXPARAMS", MAXPARAMS);
+  setnameval(L, "MAXSTACK", MAXSTACK);
+  setnameval(L, "MAXUPVALUES", MAXUPVALUES);
   return 1;
   return 1;
 }
 }
 
 
@@ -241,7 +240,7 @@ static int mem_query (lua_State *L) {
 
 
 static int hash_query (lua_State *L) {
 static int hash_query (lua_State *L) {
   if (lua_isnull(L, 2)) {
   if (lua_isnull(L, 2)) {
-    luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, l_s("string expected"));
+    luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, "string expected");
     lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash);
     lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash);
   }
   }
   else {
   else {
@@ -336,8 +335,8 @@ static int unref (lua_State *L) {
 
 
 static int newuserdata (lua_State *L) {
 static int newuserdata (lua_State *L) {
   size_t size = luaL_check_int(L, 1);
   size_t size = luaL_check_int(L, 1);
-  l_char *p = cast(l_char *, lua_newuserdata(L, size));
-  while (size--) *p++ = l_c('\0');
+  char *p = cast(char *, lua_newuserdata(L, size));
+  while (size--) *p++ = '\0';
   return 1;
   return 1;
 }
 }
 
 
@@ -383,7 +382,7 @@ static int s2d (lua_State *L) {
 
 
 static int d2s (lua_State *L) {
 static int d2s (lua_State *L) {
   double d = luaL_check_number(L, 1);
   double d = luaL_check_number(L, 1);
-  lua_pushlstring(L, cast(l_char *, &d), sizeof(d));
+  lua_pushlstring(L, cast(char *, &d), sizeof(d));
   return 1;
   return 1;
 }
 }
 
 
@@ -418,7 +417,7 @@ static int closestate (lua_State *L) {
 
 
 static int doremote (lua_State *L) {
 static int doremote (lua_State *L) {
   lua_State *L1;
   lua_State *L1;
-  const l_char *code = luaL_check_string(L, 2);
+  const char *code = luaL_check_string(L, 2);
   int status;
   int status;
   L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1)));
   L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1)));
   status = lua_dostring(L1, code);
   status = lua_dostring(L1, code);
@@ -438,7 +437,7 @@ static int doremote (lua_State *L) {
 
 
 static int settagmethod (lua_State *L) {
 static int settagmethod (lua_State *L) {
   int tag = luaL_check_int(L, 1);
   int tag = luaL_check_int(L, 1);
-  const l_char *event = luaL_check_string(L, 2);
+  const char *event = luaL_check_string(L, 2);
   luaL_check_any(L, 3);
   luaL_check_any(L, 3);
   lua_gettagmethod(L, tag, event);
   lua_gettagmethod(L, tag, event);
   lua_pushvalue(L, 3);
   lua_pushvalue(L, 3);
@@ -460,36 +459,36 @@ static int log2_aux (lua_State *L) {
 ** =======================================================
 ** =======================================================
 */
 */
 
 
-static const l_char *const delimits = l_s(" \t\n,;");
+static const char *const delimits = " \t\n,;";
 
 
-static void skip (const l_char **pc) {
-  while (**pc != l_c('\0') && strchr(delimits, **pc)) (*pc)++;
+static void skip (const char **pc) {
+  while (**pc != '\0' && strchr(delimits, **pc)) (*pc)++;
 }
 }
 
 
-static int getnum_aux (lua_State *L, const l_char **pc) {
+static int getnum_aux (lua_State *L, const char **pc) {
   int res = 0;
   int res = 0;
   int sig = 1;
   int sig = 1;
   skip(pc);
   skip(pc);
-  if (**pc == l_c('.')) {
+  if (**pc == '.') {
     res = cast(int, lua_tonumber(L, -1));
     res = cast(int, lua_tonumber(L, -1));
     lua_pop(L, 1);
     lua_pop(L, 1);
     (*pc)++;
     (*pc)++;
     return res;
     return res;
   }
   }
-  else if (**pc == l_c('-')) {
+  else if (**pc == '-') {
     sig = -1;
     sig = -1;
     (*pc)++;
     (*pc)++;
   }
   }
-  while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - l_c('0');
+  while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - '0';
   return sig*res;
   return sig*res;
 }
 }
   
   
-static const l_char *getname_aux (l_char *buff, const l_char **pc) {
+static const char *getname_aux (char *buff, const char **pc) {
   int i = 0;
   int i = 0;
   skip(pc);
   skip(pc);
-  while (**pc != l_c('\0') && !strchr(delimits, **pc))
+  while (**pc != '\0' && !strchr(delimits, **pc))
     buff[i++] = *(*pc)++;
     buff[i++] = *(*pc)++;
-  buff[i] = l_c('\0');
+  buff[i] = '\0';
   return buff;
   return buff;
 }
 }
 
 
@@ -501,134 +500,134 @@ static const l_char *getname_aux (l_char *buff, const l_char **pc) {
 
 
 
 
 static int testC (lua_State *L) {
 static int testC (lua_State *L) {
-  l_char buff[30];
-  const l_char *pc = luaL_check_string(L, 1);
+  char buff[30];
+  const char *pc = luaL_check_string(L, 1);
   for (;;) {
   for (;;) {
-    const l_char *inst = getname;
-    if EQ(l_s("")) return 0;
-    else if EQ(l_s("isnumber")) {
+    const char *inst = getname;
+    if EQ("") return 0;
+    else if EQ("isnumber") {
       lua_pushnumber(L, lua_isnumber(L, getnum));
       lua_pushnumber(L, lua_isnumber(L, getnum));
     }
     }
-    else if EQ(l_s("isstring")) {
+    else if EQ("isstring") {
       lua_pushnumber(L, lua_isstring(L, getnum));
       lua_pushnumber(L, lua_isstring(L, getnum));
     }
     }
-    else if EQ(l_s("istable")) {
+    else if EQ("istable") {
       lua_pushnumber(L, lua_istable(L, getnum));
       lua_pushnumber(L, lua_istable(L, getnum));
     }
     }
-    else if EQ(l_s("iscfunction")) {
+    else if EQ("iscfunction") {
       lua_pushnumber(L, lua_iscfunction(L, getnum));
       lua_pushnumber(L, lua_iscfunction(L, getnum));
     }
     }
-    else if EQ(l_s("isfunction")) {
+    else if EQ("isfunction") {
       lua_pushnumber(L, lua_isfunction(L, getnum));
       lua_pushnumber(L, lua_isfunction(L, getnum));
     }
     }
-    else if EQ(l_s("isuserdata")) {
+    else if EQ("isuserdata") {
       lua_pushnumber(L, lua_isuserdata(L, getnum));
       lua_pushnumber(L, lua_isuserdata(L, getnum));
     }
     }
-    else if EQ(l_s("isnil")) {
+    else if EQ("isnil") {
       lua_pushnumber(L, lua_isnil(L, getnum));
       lua_pushnumber(L, lua_isnil(L, getnum));
     }
     }
-    else if EQ(l_s("isnull")) {
+    else if EQ("isnull") {
       lua_pushnumber(L, lua_isnull(L, getnum));
       lua_pushnumber(L, lua_isnull(L, getnum));
     }
     }
-    else if EQ(l_s("tonumber")) {
+    else if EQ("tonumber") {
       lua_pushnumber(L, lua_tonumber(L, getnum));
       lua_pushnumber(L, lua_tonumber(L, getnum));
     }
     }
-    else if EQ(l_s("tostring")) {
-      const l_char *s = lua_tostring(L, getnum);
+    else if EQ("tostring") {
+      const char *s = lua_tostring(L, getnum);
       lua_pushstring(L, s);
       lua_pushstring(L, s);
     }
     }
-    else if EQ(l_s("tonumber")) {
+    else if EQ("tonumber") {
       lua_pushnumber(L, lua_tonumber(L, getnum));
       lua_pushnumber(L, lua_tonumber(L, getnum));
     }
     }
-    else if EQ(l_s("strlen")) {
+    else if EQ("strlen") {
       lua_pushnumber(L, lua_strlen(L, getnum));
       lua_pushnumber(L, lua_strlen(L, getnum));
     }
     }
-    else if EQ(l_s("tocfunction")) {
+    else if EQ("tocfunction") {
       lua_pushcfunction(L, lua_tocfunction(L, getnum));
       lua_pushcfunction(L, lua_tocfunction(L, getnum));
     }
     }
-    else if EQ(l_s("return")) {
+    else if EQ("return") {
       return getnum;
       return getnum;
     }
     }
-    else if EQ(l_s("gettop")) {
+    else if EQ("gettop") {
       lua_pushnumber(L, lua_gettop(L));
       lua_pushnumber(L, lua_gettop(L));
     }
     }
-    else if EQ(l_s("settop")) {
+    else if EQ("settop") {
       lua_settop(L, getnum);
       lua_settop(L, getnum);
     }
     }
-    else if EQ(l_s("pop")) {
+    else if EQ("pop") {
       lua_pop(L, getnum);
       lua_pop(L, getnum);
     }
     }
-    else if EQ(l_s("pushnum")) {
+    else if EQ("pushnum") {
       lua_pushnumber(L, getnum);
       lua_pushnumber(L, getnum);
     }
     }
-    else if EQ(l_s("pushvalue")) {
+    else if EQ("pushvalue") {
       lua_pushvalue(L, getnum);
       lua_pushvalue(L, getnum);
     }
     }
-    else if EQ(l_s("pushcclosure")) {
+    else if EQ("pushcclosure") {
       lua_pushcclosure(L, testC, getnum);
       lua_pushcclosure(L, testC, getnum);
     }
     }
-    else if EQ(l_s("pushupvalues")) {
+    else if EQ("pushupvalues") {
       lua_pushupvalues(L);
       lua_pushupvalues(L);
     }
     }
-    else if EQ(l_s("remove")) {
+    else if EQ("remove") {
       lua_remove(L, getnum);
       lua_remove(L, getnum);
     }
     }
-    else if EQ(l_s("insert")) {
+    else if EQ("insert") {
       lua_insert(L, getnum);
       lua_insert(L, getnum);
     }
     }
-    else if EQ(l_s("gettable")) {
+    else if EQ("gettable") {
       lua_gettable(L, getnum);
       lua_gettable(L, getnum);
     }
     }
-    else if EQ(l_s("settable")) {
+    else if EQ("settable") {
       lua_settable(L, getnum);
       lua_settable(L, getnum);
     }
     }
-    else if EQ(l_s("next")) {
+    else if EQ("next") {
       lua_next(L, -2);
       lua_next(L, -2);
     }
     }
-    else if EQ(l_s("concat")) {
+    else if EQ("concat") {
       lua_concat(L, getnum);
       lua_concat(L, getnum);
     }
     }
-    else if EQ(l_s("lessthan")) {
+    else if EQ("lessthan") {
       int a = getnum;
       int a = getnum;
       if (lua_lessthan(L, a, getnum))
       if (lua_lessthan(L, a, getnum))
         lua_pushnumber(L, 1);
         lua_pushnumber(L, 1);
       else
       else
         lua_pushnil(L);
         lua_pushnil(L);
     }
     }
-    else if EQ(l_s("equal")) {
+    else if EQ("equal") {
       int a = getnum;
       int a = getnum;
       if (lua_equal(L, a, getnum))
       if (lua_equal(L, a, getnum))
         lua_pushnumber(L, 1);
         lua_pushnumber(L, 1);
       else
       else
         lua_pushnil(L);
         lua_pushnil(L);
     }
     }
-    else if EQ(l_s("rawcall")) {
+    else if EQ("rawcall") {
       int narg = getnum;
       int narg = getnum;
       int nres = getnum;
       int nres = getnum;
       lua_rawcall(L, narg, nres);
       lua_rawcall(L, narg, nres);
     }
     }
-    else if EQ(l_s("call")) {
+    else if EQ("call") {
       int narg = getnum;
       int narg = getnum;
       int nres = getnum;
       int nres = getnum;
       lua_call(L, narg, nres);
       lua_call(L, narg, nres);
     }
     }
-    else if EQ(l_s("dostring")) {
+    else if EQ("dostring") {
       lua_dostring(L, luaL_check_string(L, getnum));
       lua_dostring(L, luaL_check_string(L, getnum));
     }
     }
-    else if EQ(l_s("settagmethod")) {
+    else if EQ("settagmethod") {
       int tag = getnum;
       int tag = getnum;
-      const l_char *event = getname;
+      const char *event = getname;
       lua_settagmethod(L, tag, event);
       lua_settagmethod(L, tag, event);
     }
     }
-    else if EQ(l_s("gettagmethod")) {
+    else if EQ("gettagmethod") {
       int tag = getnum;
       int tag = getnum;
-      const l_char *event = getname;
+      const char *event = getname;
       lua_gettagmethod(L, tag, event);
       lua_gettagmethod(L, tag, event);
     }
     }
-    else if EQ(l_s("type")) {
+    else if EQ("type") {
       lua_pushstring(L, lua_type(L, getnum));
       lua_pushstring(L, lua_type(L, getnum));
     }
     }
-    else luaL_verror(L, l_s("unknown instruction %.30s"), buff);
+    else luaL_verror(L, "unknown instruction %.30s", buff);
   }
   }
   return 0;
   return 0;
 }
 }
@@ -638,32 +637,32 @@ static int testC (lua_State *L) {
 
 
 
 
 static const struct luaL_reg tests_funcs[] = {
 static const struct luaL_reg tests_funcs[] = {
-  {l_s("hash"), hash_query},
-  {l_s("limits"), get_limits},
-  {l_s("listcode"), listcode},
-  {l_s("listk"), listk},
-  {l_s("listlocals"), listlocals},
-  {l_s("loadlib"), loadlib},
-  {l_s("querystr"), string_query},
-  {l_s("querytab"), table_query},
-  {l_s("testC"), testC},
-  {l_s("ref"), tref},
-  {l_s("getref"), getref},
-  {l_s("unref"), unref},
-  {l_s("d2s"), d2s},
-  {l_s("s2d"), s2d},
-  {l_s("newuserdata"), newuserdata},
-  {l_s("newuserdatabox"), newuserdatabox},
-  {l_s("settag"), settag},
-  {l_s("udataval"), udataval},
-  {l_s("newtag"), newtag},
-  {l_s("doonnewstack"), doonnewstack},
-  {l_s("newstate"), newstate},
-  {l_s("closestate"), closestate},
-  {l_s("doremote"), doremote},
-  {l_s("settagmethod"), settagmethod},
-  {l_s("log2"), log2_aux},
-  {l_s("totalmem"), mem_query}
+  {"hash", hash_query},
+  {"limits", get_limits},
+  {"listcode", listcode},
+  {"listk", listk},
+  {"listlocals", listlocals},
+  {"loadlib", loadlib},
+  {"querystr", string_query},
+  {"querytab", table_query},
+  {"testC", testC},
+  {"ref", tref},
+  {"getref", getref},
+  {"unref", unref},
+  {"d2s", d2s},
+  {"s2d", s2d},
+  {"newuserdata", newuserdata},
+  {"newuserdatabox", newuserdatabox},
+  {"settag", settag},
+  {"udataval", udataval},
+  {"newtag", newtag},
+  {"doonnewstack", doonnewstack},
+  {"newstate", newstate},
+  {"closestate", closestate},
+  {"doremote", doremote},
+  {"settagmethod", settagmethod},
+  {"log2", log2_aux},
+  {"totalmem", mem_query}
 };
 };
 
 
 
 
@@ -677,7 +676,7 @@ void luaB_opentests (lua_State *L) {
   lua_setglobals(L);
   lua_setglobals(L);
   luaL_openl(L, tests_funcs);  /* open functions inside new table */
   luaL_openl(L, tests_funcs);  /* open functions inside new table */
   lua_setglobals(L);  /* restore old table of globals */
   lua_setglobals(L);  /* restore old table of globals */
-  lua_setglobal(L, l_s("T"));  /* set new table as global T */
+  lua_setglobal(L, "T");  /* set new table as global T */
 }
 }
 
 
 #endif
 #endif

+ 21 - 22
ltm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.c,v 1.78 2001/08/31 19:46:07 roberto Exp $
+** $Id: ltm.c,v 1.80 2001/10/11 21:41:21 roberto Exp $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldo.h"
 #include "ldo.h"
@@ -20,16 +19,16 @@
 #include "ltm.h"
 #include "ltm.h"
 
 
 
 
-const l_char *const luaT_eventname[] = {  /* ORDER TM */
-  l_s("gettable"), l_s("settable"), l_s("index"), l_s("getglobal"),
-  l_s("setglobal"), l_s("add"), l_s("sub"), l_s("mul"), l_s("div"),
-  l_s("pow"), l_s("unm"), l_s("lt"), l_s("concat"), l_s("gc"),
-  l_s("function"),
+const char *const luaT_eventname[] = {  /* ORDER TM */
+  "gettable", "settable", "index", "getglobal",
+  "setglobal", "add", "sub", "mul", "div",
+  "pow", "unm", "lt", "concat", "gc",
+  "function",
   NULL
   NULL
 };
 };
 
 
 
 
-static int findevent (const l_char *name) {
+static int findevent (const char *name) {
   int i;
   int i;
   for (i=0; luaT_eventname[i]; i++)
   for (i=0; luaT_eventname[i]; i++)
     if (strcmp(luaT_eventname[i], name) == 0)
     if (strcmp(luaT_eventname[i], name) == 0)
@@ -38,10 +37,10 @@ static int findevent (const l_char *name) {
 }
 }
 
 
 
 
-static int luaI_checkevent (lua_State *L, const l_char *name) {
+static int luaI_checkevent (lua_State *L, const char *name) {
   int e = findevent(name);
   int e = findevent(name);
   if (e < 0)
   if (e < 0)
-    luaO_verror(L, l_s("`%.50s' is not a valid event name"), name);
+    luaO_verror(L, "`%.50s' is not a valid event name", name);
   return e;
   return e;
 }
 }
 
 
@@ -66,9 +65,9 @@ static int luaT_validevent (int t, int e) {  /* ORDER LUA_T */
 
 
 
 
 void luaT_init (lua_State *L) {
 void luaT_init (lua_State *L) {
-  static const l_char *const typenames[NUM_TAGS] = {
-    l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"),
-    l_s("table"), l_s("function")
+  static const char *const typenames[NUM_TAGS] = {
+    "userdata", "nil", "number", "string",
+    "table", "function"
   };
   };
   int i;
   int i;
   for (i=0; i<NUM_TAGS; i++)
   for (i=0; i<NUM_TAGS; i++)
@@ -76,12 +75,12 @@ void luaT_init (lua_State *L) {
 }
 }
 
 
 
 
-int luaT_newtag (lua_State *L, const l_char *name, int basictype) {
+int luaT_newtag (lua_State *L, const char *name, int basictype) {
   int tag;
   int tag;
   int i;
   int i;
   TString *ts = NULL;
   TString *ts = NULL;
   luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM,
   luaM_growvector(L, G(L)->TMtable, G(L)->ntag, G(L)->sizeTM, struct TM,
-                  MAX_INT, l_s("tag table overflow"));
+                  MAX_INT, "tag table overflow");
   tag = G(L)->ntag;
   tag = G(L)->ntag;
   if (name) {
   if (name) {
     const TObject *v;
     const TObject *v;
@@ -104,7 +103,7 @@ int luaT_newtag (lua_State *L, const l_char *name, int basictype) {
 
 
 static void checktag (lua_State *L, int tag) {
 static void checktag (lua_State *L, int tag) {
   if (!(0 <= tag && tag < G(L)->ntag))
   if (!(0 <= tag && tag < G(L)->ntag))
-    luaO_verror(L, l_s("%d is not a valid tag"), tag);
+    luaO_verror(L, "%d is not a valid tag", tag);
 }
 }
 
 
 
 
@@ -118,7 +117,7 @@ int luaT_tag (const TObject *o) {
 }
 }
 
 
 
 
-const l_char *luaT_typename (global_State *G, const TObject *o) {
+const char *luaT_typename (global_State *G, const TObject *o) {
   int t = ttype(o);
   int t = ttype(o);
   int tag;
   int tag;
   TString *ts;
   TString *ts;
@@ -139,7 +138,7 @@ const l_char *luaT_typename (global_State *G, const TObject *o) {
 }
 }
 
 
 
 
-LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
+LUA_API void lua_gettagmethod (lua_State *L, int t, const char *event) {
   int e;
   int e;
   lua_lock(L);
   lua_lock(L);
   e = luaI_checkevent(L, event);
   e = luaI_checkevent(L, event);
@@ -154,16 +153,16 @@ LUA_API void lua_gettagmethod (lua_State *L, int t, const l_char *event) {
 }
 }
 
 
 
 
-LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
+LUA_API void lua_settagmethod (lua_State *L, int t, const char *event) {
   int e;
   int e;
   lua_lock(L);
   lua_lock(L);
   e = luaI_checkevent(L, event);
   e = luaI_checkevent(L, event);
   checktag(L, t);
   checktag(L, t);
   if (!luaT_validevent(t, e))
   if (!luaT_validevent(t, e))
-    luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"),
+    luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s",
                 luaT_eventname[e], typenamebytag(G(L), t),
                 luaT_eventname[e], typenamebytag(G(L), t),
                 (t == LUA_TTABLE || t == LUA_TUSERDATA) ?
                 (t == LUA_TTABLE || t == LUA_TUSERDATA) ?
-                   l_s(" with default tag") : l_s(""));
+                   " with default tag" : "");
   switch (ttype(L->top - 1)) {
   switch (ttype(L->top - 1)) {
     case LUA_TNIL:
     case LUA_TNIL:
       luaT_gettm(G(L), t, e) = NULL;
       luaT_gettm(G(L), t, e) = NULL;
@@ -172,7 +171,7 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
       luaT_gettm(G(L), t, e) = clvalue(L->top - 1);
       luaT_gettm(G(L), t, e) = clvalue(L->top - 1);
       break;
       break;
     default:
     default:
-      luaD_error(L, l_s("tag method must be a function (or nil)"));
+      luaD_error(L, "tag method must be a function (or nil)");
   }
   }
   L->top--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);

+ 4 - 4
ltm.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltm.h,v 1.27 2001/08/27 15:13:59 roberto Exp $
+** $Id: ltm.h,v 1.28 2001/10/02 16:43:54 roberto Exp $
 ** Tag methods
 ** Tag methods
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -67,12 +67,12 @@ struct TM {
 
 
 #define validtag(G,t) (NUM_TAGS <= (t) && (t) < G->ntag)
 #define validtag(G,t) (NUM_TAGS <= (t) && (t) < G->ntag)
 
 
-extern const l_char *const luaT_eventname[];
+extern const char *const luaT_eventname[];
 
 
 
 
 void luaT_init (lua_State *L);
 void luaT_init (lua_State *L);
-int luaT_newtag (lua_State *L, const l_char *name, int basictype);
-const l_char *luaT_typename (global_State *G, const TObject *o);
+int luaT_newtag (lua_State *L, const char *name, int basictype);
+const char *luaT_typename (global_State *G, const TObject *o);
 int luaT_tag (const TObject *o);
 int luaT_tag (const TObject *o);
 
 
 
 

+ 58 - 59
lua.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.c,v 1.71 2001/10/17 21:12:57 roberto Exp $
+** $Id: lua.c,v 1.72 2001/11/27 20:56:47 roberto Exp $
 ** Lua stand-alone interpreter
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "luadebug.h"
 #include "luadebug.h"
@@ -25,12 +24,12 @@ static int isatty (int x) { return x==0; }  /* assume stdin is a tty */
 
 
 
 
 #ifndef LUA_PROGNAME
 #ifndef LUA_PROGNAME
-#define LUA_PROGNAME	l_s("lua: ")
+#define LUA_PROGNAME	"lua: "
 #endif
 #endif
 
 
 
 
 #ifndef PROMPT
 #ifndef PROMPT
-#define PROMPT		l_s("> ")
+#define PROMPT		"> "
 #endif
 #endif
 
 
 
 
@@ -62,7 +61,7 @@ static void lstop (void) {
   lua_setlinehook(L, old_linehook);
   lua_setlinehook(L, old_linehook);
   lua_setcallhook(L, old_callhook);
   lua_setcallhook(L, old_callhook);
   lreset();
   lreset();
-  lua_error(L, l_s("interrupted!"));
+  lua_error(L, "interrupted!");
 }
 }
 
 
 
 
@@ -75,7 +74,7 @@ static void laction (int i) {
 }
 }
 
 
 
 
-static int ldo (int (*f)(lua_State *l, const l_char *), const l_char *name,
+static int ldo (int (*f)(lua_State *l, const char *), const char *name,
                 int clear) {
                 int clear) {
   int res;
   int res;
   handler h = lreset();
   handler h = lreset();
@@ -86,45 +85,45 @@ static int ldo (int (*f)(lua_State *l, const l_char *), const l_char *name,
     lua_settop(L, top);  /* remove eventual results */
     lua_settop(L, top);  /* remove eventual results */
   /* Lua gives no message in such cases, so lua.c provides one */
   /* Lua gives no message in such cases, so lua.c provides one */
   if (res == LUA_ERRMEM) {
   if (res == LUA_ERRMEM) {
-    fprintf(stderr, LUA_PROGNAME l_s("memory allocation error\n"));
+    fprintf(stderr, LUA_PROGNAME "memory allocation error\n");
   }
   }
   else if (res == LUA_ERRERR)
   else if (res == LUA_ERRERR)
-    fprintf(stderr, LUA_PROGNAME l_s("error in error message\n"));
+    fprintf(stderr, LUA_PROGNAME "error in error message\n");
   return res;
   return res;
 }
 }
 
 
 
 
 static void print_message (void) {
 static void print_message (void) {
   fprintf(stderr,
   fprintf(stderr,
-  l_s("usage: lua [options].  Available options are:\n")
-  l_s("  -        execute stdin as a file\n")
-  l_s("  -c       close Lua when exiting\n")
-  l_s("  -e stat  execute string `stat'\n")
-  l_s("  -f name  execute file `name' with remaining arguments in table `arg'\n")
-  l_s("  -i       enter interactive mode with prompt\n")
-  l_s("  -q       enter interactive mode without prompt\n")
-  l_s("  -sNUM    set stack size to NUM (must be the first option)\n")
-  l_s("  -v       print version information\n")
-  l_s("  a=b      set global `a' to string `b'\n")
-  l_s("  name     execute file `name'\n")
+  "usage: lua [options].  Available options are:\n"
+  "  -        execute stdin as a file\n"
+  "  -c       close Lua when exiting\n"
+  "  -e stat  execute string `stat'\n"
+  "  -f name  execute file `name' with remaining arguments in table `arg'\n"
+  "  -i       enter interactive mode with prompt\n"
+  "  -q       enter interactive mode without prompt\n"
+  "  -sNUM    set stack size to NUM (must be the first option)\n"
+  "  -v       print version information\n"
+  "  a=b      set global `a' to string `b'\n"
+  "  name     execute file `name'\n"
 );
 );
 }
 }
 
 
 
 
 static void print_version (void) {
 static void print_version (void) {
-  printf(l_s("%.80s  %.80s\n"), l_s(LUA_VERSION), l_s(LUA_COPYRIGHT));
+  printf("%.80s  %.80s\n", LUA_VERSION, LUA_COPYRIGHT);
 }
 }
 
 
 
 
-static void assign (l_char *arg) {
-  l_char *eq = strchr(arg, l_c('='));
-  *eq = l_c('\0');  /* spilt `arg' in two strings (name & value) */
+static void assign (char *arg) {
+  char *eq = strchr(arg, '=');
+  *eq = '\0';  /* spilt `arg' in two strings (name & value) */
   lua_pushstring(L, eq+1);
   lua_pushstring(L, eq+1);
   lua_setglobal(L, arg);
   lua_setglobal(L, arg);
 }
 }
 
 
 
 
-static void getargs (l_char *argv[]) {
+static void getargs (char *argv[]) {
   int i;
   int i;
   lua_newtable(L);
   lua_newtable(L);
   for (i=0; argv[i]; i++) {
   for (i=0; argv[i]; i++) {
@@ -134,24 +133,24 @@ static void getargs (l_char *argv[]) {
     lua_settable(L, -3);
     lua_settable(L, -3);
   }
   }
   /* arg.n = maximum index in table `arg' */
   /* arg.n = maximum index in table `arg' */
-  lua_pushliteral(L, l_s("n"));
+  lua_pushliteral(L, "n");
   lua_pushnumber(L, i-1);
   lua_pushnumber(L, i-1);
   lua_settable(L, -3);
   lua_settable(L, -3);
 }
 }
 
 
 
 
 static int l_getargs (lua_State *l) {
 static int l_getargs (lua_State *l) {
-  l_char **argv = (l_char **)lua_touserdata(l, lua_upvalueindex(1));
+  char **argv = (char **)lua_touserdata(l, lua_upvalueindex(1));
   getargs(argv);
   getargs(argv);
   return 1;
   return 1;
 }
 }
 
 
 
 
-static int file_input (const l_char *argv) {
+static int file_input (const char *argv) {
   int result = ldo(lua_dofile, argv, 1);
   int result = ldo(lua_dofile, argv, 1);
   if (result) {
   if (result) {
     if (result == LUA_ERRFILE) {
     if (result == LUA_ERRFILE) {
-      fprintf(stderr, LUA_PROGNAME l_s("cannot execute file "));
+      fprintf(stderr, LUA_PROGNAME "cannot execute file ");
       perror(argv);
       perror(argv);
     }
     }
     return EXIT_FAILURE;
     return EXIT_FAILURE;
@@ -167,12 +166,12 @@ static int file_input (const l_char *argv) {
 #endif
 #endif
 
 
 
 
-static const l_char *get_prompt (int prompt) {
+static const char *get_prompt (int prompt) {
   if (!prompt)
   if (!prompt)
-    return l_s("");
+    return "";
   else {
   else {
-    const l_char *s;
-    lua_getglobal(L, l_s("_PROMPT"));
+    const char *s;
+    lua_getglobal(L, "_PROMPT");
     s = lua_tostring(L, -1);
     s = lua_tostring(L, -1);
     if (!s) s = PROMPT;
     if (!s) s = PROMPT;
     lua_pop(L, 1);  /* remove global */
     lua_pop(L, 1);  /* remove global */
@@ -188,20 +187,20 @@ static void manual_input (int version, int prompt) {
     int toprint = 0;
     int toprint = 0;
     fputs(get_prompt(prompt), stdout);  /* show prompt */
     fputs(get_prompt(prompt), stdout);  /* show prompt */
     for(;;) {
     for(;;) {
-      l_char buffer[MAXINPUT];
+      char buffer[MAXINPUT];
       size_t l;
       size_t l;
       if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
       if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
-        printf(l_s("\n"));
+        printf("\n");
         return;
         return;
       }
       }
-      if (firstline && buffer[0] == l_c('=')) {
-        buffer[0] = l_c(' ');
-        lua_pushstring(L, l_s("return"));
+      if (firstline && buffer[0] == '=') {
+        buffer[0] = ' ';
+        lua_pushstring(L, "return");
         toprint = 1;
         toprint = 1;
       }
       }
       l = strlen(buffer);
       l = strlen(buffer);
-      if (buffer[l-1] == l_c('\n') && buffer[l-2] == l_c('\\')) {
-        buffer[l-2] = l_c('\n');
+      if (buffer[l-1] == '\n' && buffer[l-2] == '\\') {
+        buffer[l-2] = '\n';
         lua_pushlstring(L, buffer, l-1);
         lua_pushlstring(L, buffer, l-1);
       }
       }
       else {
       else {
@@ -214,7 +213,7 @@ static void manual_input (int version, int prompt) {
     ldo(lua_dostring, lua_tostring(L, 1), 0);
     ldo(lua_dostring, lua_tostring(L, 1), 0);
     lua_remove(L, 1);  /* remove ran string */
     lua_remove(L, 1);  /* remove ran string */
     if (toprint && lua_gettop(L) > 0) {  /* any result to print? */
     if (toprint && lua_gettop(L) > 0) {  /* any result to print? */
-      lua_getglobal(L, l_s("print"));
+      lua_getglobal(L, "print");
       lua_insert(L, 1);
       lua_insert(L, 1);
       lua_call(L, lua_gettop(L)-1, 0);
       lua_call(L, lua_gettop(L)-1, 0);
     }
     }
@@ -224,7 +223,7 @@ static void manual_input (int version, int prompt) {
 }
 }
 
 
 
 
-static int handle_argv (l_char *argv[], int *toclose) {
+static int handle_argv (char *argv[], int *toclose) {
   if (*argv == NULL) {  /* no more arguments? */
   if (*argv == NULL) {  /* no more arguments? */
     if (isatty(0)) {
     if (isatty(0)) {
       manual_input(1, 1);
       manual_input(1, 1);
@@ -235,8 +234,8 @@ static int handle_argv (l_char *argv[], int *toclose) {
   else {  /* other arguments; loop over them */
   else {  /* other arguments; loop over them */
     int i;
     int i;
     for (i = 0; argv[i] != NULL; i++) {
     for (i = 0; argv[i] != NULL; i++) {
-      if (argv[i][0] != l_c('-')) {  /* not an option? */
-        if (strchr(argv[i], l_c('=')))
+      if (argv[i][0] != '-') {  /* not an option? */
+        if (strchr(argv[i], '='))
           assign(argv[i]);
           assign(argv[i]);
         else
         else
           if (file_input(argv[i]) != EXIT_SUCCESS)
           if (file_input(argv[i]) != EXIT_SUCCESS)
@@ -247,49 +246,49 @@ static int handle_argv (l_char *argv[], int *toclose) {
             ldo(lua_dofile, NULL, 1);  /* executes stdin as a file */
             ldo(lua_dofile, NULL, 1);  /* executes stdin as a file */
             break;
             break;
           }
           }
-          case l_c('i'): {
+          case 'i': {
             manual_input(0, 1);
             manual_input(0, 1);
             break;
             break;
           }
           }
-          case l_c('q'): {
+          case 'q': {
             manual_input(0, 0);
             manual_input(0, 0);
             break;
             break;
           }
           }
-          case l_c('c'): {
+          case 'c': {
             *toclose = 1;
             *toclose = 1;
             break;
             break;
           }
           }
-          case l_c('v'): {
+          case 'v': {
             print_version();
             print_version();
             break;
             break;
           }
           }
-          case l_c('e'): {
+          case 'e': {
             i++;
             i++;
             if (argv[i] == NULL) {
             if (argv[i] == NULL) {
               print_message();
               print_message();
               return EXIT_FAILURE;
               return EXIT_FAILURE;
             }
             }
             if (ldo(lua_dostring, argv[i], 1) != 0) {
             if (ldo(lua_dostring, argv[i], 1) != 0) {
-              fprintf(stderr, LUA_PROGNAME l_s("error running argument `%.99s'\n"),
+              fprintf(stderr, LUA_PROGNAME "error running argument `%.99s'\n",
                       argv[i]);
                       argv[i]);
               return EXIT_FAILURE;
               return EXIT_FAILURE;
             }
             }
             break;
             break;
           }
           }
-          case l_c('f'): {
+          case 'f': {
             i++;
             i++;
             if (argv[i] == NULL) {
             if (argv[i] == NULL) {
               print_message();
               print_message();
               return EXIT_FAILURE;
               return EXIT_FAILURE;
             }
             }
             getargs(argv+i);  /* collect remaining arguments */
             getargs(argv+i);  /* collect remaining arguments */
-            lua_setglobal(L, l_s("arg"));
+            lua_setglobal(L, "arg");
             return file_input(argv[i]);  /* stop scanning arguments */
             return file_input(argv[i]);  /* stop scanning arguments */
           }
           }
-          case l_c('s'): {
+          case 's': {
             if (i == 0) break;  /* option already handled */
             if (i == 0) break;  /* option already handled */
             fprintf(stderr,
             fprintf(stderr,
-               LUA_PROGNAME l_s("stack size (`-s') must be the first option\n"));
+               LUA_PROGNAME "stack size (`-s') must be the first option\n");
             return EXIT_FAILURE;
             return EXIT_FAILURE;
           }
           }
           default: {
           default: {
@@ -303,12 +302,12 @@ static int handle_argv (l_char *argv[], int *toclose) {
 }
 }
 
 
 
 
-static int getstacksize (int argc, l_char *argv[]) {
+static int getstacksize (int argc, char *argv[]) {
   int stacksize = 0;
   int stacksize = 0;
-  if (argc >= 2 && argv[1][0] == l_c('-') && argv[1][1] == l_c('s')) {
+  if (argc >= 2 && argv[1][0] == '-' && argv[1][1] == 's') {
     stacksize = strtol(&argv[1][2], NULL, 10);
     stacksize = strtol(&argv[1][2], NULL, 10);
     if (stacksize <= 0) {
     if (stacksize <= 0) {
-      fprintf(stderr, LUA_PROGNAME l_s("invalid stack size ('%.20s')\n"),
+      fprintf(stderr, LUA_PROGNAME "invalid stack size ('%.20s')\n",
               &argv[1][2]);
               &argv[1][2]);
       exit(EXIT_FAILURE);
       exit(EXIT_FAILURE);
     }
     }
@@ -317,10 +316,10 @@ static int getstacksize (int argc, l_char *argv[]) {
 }
 }
 
 
 
 
-static void register_getargs (l_char *argv[]) {
+static void register_getargs (char *argv[]) {
   lua_newuserdatabox(L, argv);
   lua_newuserdatabox(L, argv);
   lua_pushcclosure(L, l_getargs, 1);
   lua_pushcclosure(L, l_getargs, 1);
-  lua_setglobal(L, l_s("getargs"));
+  lua_setglobal(L, "getargs");
 }
 }
 
 
 
 
@@ -333,7 +332,7 @@ static void openstdlibs (lua_State *l) {
 }
 }
 
 
 
 
-int main (int argc, l_char *argv[]) {
+int main (int argc, char *argv[]) {
   int status;
   int status;
   int toclose = 0;
   int toclose = 0;
   L = lua_open(getstacksize(argc, argv));  /* create state */
   L = lua_open(getstacksize(argc, argv));  /* create state */

+ 28 - 57
lua.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.h,v 1.106 2001/10/31 19:40:14 roberto Exp roberto $
+** $Id: lua.h,v 1.107 2001/10/31 19:58:11 roberto Exp $
 ** Lua - An Extensible Extension Language
 ** Lua - An Extensible Extension Language
 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
 ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
 ** e-mail: [email protected]
 ** e-mail: [email protected]
@@ -91,12 +91,6 @@ typedef int (*lua_CFunction) (lua_State *L);
 #endif
 #endif
 typedef LUA_NUMBER lua_Number;
 typedef LUA_NUMBER lua_Number;
 
 
-/* Lua character type */
-#ifndef L_CHAR
-#define L_CHAR	char
-#endif
-typedef L_CHAR lua_char;
-
 
 
 /* mark for all API functions */
 /* mark for all API functions */
 #ifndef LUA_API
 #ifndef LUA_API
@@ -126,7 +120,7 @@ LUA_API int   lua_stackspace (lua_State *L);
 ** access functions (stack -> C)
 ** access functions (stack -> C)
 */
 */
 
 
-LUA_API const lua_char *lua_type (lua_State *L, int index);
+LUA_API const char *lua_type (lua_State *L, int index);
 LUA_API int             lua_isnumber (lua_State *L, int index);
 LUA_API int             lua_isnumber (lua_State *L, int index);
 LUA_API int             lua_isstring (lua_State *L, int index);
 LUA_API int             lua_isstring (lua_State *L, int index);
 LUA_API int             lua_iscfunction (lua_State *L, int index);
 LUA_API int             lua_iscfunction (lua_State *L, int index);
@@ -137,7 +131,7 @@ LUA_API int            lua_equal (lua_State *L, int index1, int index2);
 LUA_API int            lua_lessthan (lua_State *L, int index1, int index2);
 LUA_API int            lua_lessthan (lua_State *L, int index1, int index2);
 
 
 LUA_API lua_Number      lua_tonumber (lua_State *L, int index);
 LUA_API lua_Number      lua_tonumber (lua_State *L, int index);
-LUA_API const lua_char *lua_tostring (lua_State *L, int index);
+LUA_API const char *lua_tostring (lua_State *L, int index);
 LUA_API size_t          lua_strlen (lua_State *L, int index);
 LUA_API size_t          lua_strlen (lua_State *L, int index);
 LUA_API lua_CFunction   lua_tocfunction (lua_State *L, int index);
 LUA_API lua_CFunction   lua_tocfunction (lua_State *L, int index);
 LUA_API void	       *lua_touserdata (lua_State *L, int index);
 LUA_API void	       *lua_touserdata (lua_State *L, int index);
@@ -149,19 +143,19 @@ LUA_API const void     *lua_topointer (lua_State *L, int index);
 */
 */
 LUA_API void  lua_pushnil (lua_State *L);
 LUA_API void  lua_pushnil (lua_State *L);
 LUA_API void  lua_pushnumber (lua_State *L, lua_Number n);
 LUA_API void  lua_pushnumber (lua_State *L, lua_Number n);
-LUA_API void  lua_pushlstring (lua_State *L, const lua_char *s, size_t len);
-LUA_API void  lua_pushstring (lua_State *L, const lua_char *s);
+LUA_API void  lua_pushlstring (lua_State *L, const char *s, size_t len);
+LUA_API void  lua_pushstring (lua_State *L, const char *s);
 LUA_API void  lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
 LUA_API void  lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
 
 
 
 
 /*
 /*
 ** get functions (Lua -> stack)
 ** get functions (Lua -> stack)
 */
 */
-LUA_API void  lua_getglobal (lua_State *L, const lua_char *name);
+LUA_API void  lua_getglobal (lua_State *L, const char *name);
 LUA_API void  lua_gettable (lua_State *L, int index);
 LUA_API void  lua_gettable (lua_State *L, int index);
 LUA_API void  lua_rawget (lua_State *L, int index);
 LUA_API void  lua_rawget (lua_State *L, int index);
 LUA_API void  lua_rawgeti (lua_State *L, int index, int n);
 LUA_API void  lua_rawgeti (lua_State *L, int index, int n);
-LUA_API void  lua_gettagmethod (lua_State *L, int tag, const lua_char *event);
+LUA_API void  lua_gettagmethod (lua_State *L, int tag, const char *event);
 LUA_API void  lua_newtable (lua_State *L);
 LUA_API void  lua_newtable (lua_State *L);
 LUA_API void  lua_getweakregistry (lua_State *L);
 LUA_API void  lua_getweakregistry (lua_State *L);
 
 
@@ -169,12 +163,12 @@ LUA_API void  lua_getweakregistry (lua_State *L);
 /*
 /*
 ** set functions (stack -> Lua)
 ** set functions (stack -> Lua)
 */
 */
-LUA_API void  lua_setglobal (lua_State *L, const lua_char *name);
+LUA_API void  lua_setglobal (lua_State *L, const char *name);
 LUA_API void  lua_settable (lua_State *L, int index);
 LUA_API void  lua_settable (lua_State *L, int index);
 LUA_API void  lua_rawset (lua_State *L, int index);
 LUA_API void  lua_rawset (lua_State *L, int index);
 LUA_API void  lua_rawseti (lua_State *L, int index, int n);
 LUA_API void  lua_rawseti (lua_State *L, int index, int n);
 LUA_API void  lua_setglobals (lua_State *L);
 LUA_API void  lua_setglobals (lua_State *L);
-LUA_API void  lua_settagmethod (lua_State *L, int tag, const lua_char *event);
+LUA_API void  lua_settagmethod (lua_State *L, int tag, const char *event);
 
 
 
 
 /*
 /*
@@ -182,13 +176,13 @@ LUA_API void  lua_settagmethod (lua_State *L, int tag, const lua_char *event);
 */
 */
 LUA_API int   lua_call (lua_State *L, int nargs, int nresults);
 LUA_API int   lua_call (lua_State *L, int nargs, int nresults);
 LUA_API void  lua_rawcall (lua_State *L, int nargs, int nresults);
 LUA_API void  lua_rawcall (lua_State *L, int nargs, int nresults);
-LUA_API int   lua_loadfile (lua_State *L, const lua_char *filename);
-LUA_API int   lua_dofile (lua_State *L, const lua_char *filename);
-LUA_API int   lua_dostring (lua_State *L, const lua_char *str);
-LUA_API int   lua_loadbuffer (lua_State *L, const lua_char *buff, size_t size,
-                            const lua_char *name);
-LUA_API int   lua_dobuffer (lua_State *L, const lua_char *buff, size_t size,
-                            const lua_char *name);
+LUA_API int   lua_loadfile (lua_State *L, const char *filename);
+LUA_API int   lua_dofile (lua_State *L, const char *filename);
+LUA_API int   lua_dostring (lua_State *L, const char *str);
+LUA_API int   lua_loadbuffer (lua_State *L, const char *buff, size_t size,
+                            const char *name);
+LUA_API int   lua_dobuffer (lua_State *L, const char *buff, size_t size,
+                            const char *name);
 
 
 /*
 /*
 ** Garbage-collection functions
 ** Garbage-collection functions
@@ -200,13 +194,13 @@ LUA_API void  lua_setgcthreshold (lua_State *L, int newthreshold);
 /*
 /*
 ** miscellaneous functions
 ** miscellaneous functions
 */
 */
-LUA_API int   lua_newtype (lua_State *L, const lua_char *name, int basictype);
+LUA_API int   lua_newtype (lua_State *L, const char *name, int basictype);
 LUA_API void  lua_settag (lua_State *L, int tag);
 LUA_API void  lua_settag (lua_State *L, int tag);
 
 
-LUA_API int             lua_name2tag (lua_State *L, const lua_char *name);
-LUA_API const lua_char *lua_tag2name (lua_State *L, int tag);
+LUA_API int             lua_name2tag (lua_State *L, const char *name);
+LUA_API const char *lua_tag2name (lua_State *L, int tag);
 
 
-LUA_API void  lua_error (lua_State *L, const lua_char *s);
+LUA_API void  lua_error (lua_State *L, const char *s);
 
 
 LUA_API int   lua_next (lua_State *L, int index);
 LUA_API int   lua_next (lua_State *L, int index);
 LUA_API int   lua_getn (lua_State *L, int index);
 LUA_API int   lua_getn (lua_State *L, int index);
@@ -240,8 +234,8 @@ LUA_API int   lua_getweakmode (lua_State *L, int index);
 #define lua_isnil(L,n)		(lua_rawtag(L,n) == LUA_TNIL)
 #define lua_isnil(L,n)		(lua_rawtag(L,n) == LUA_TNIL)
 #define lua_isnull(L,n)		(lua_rawtag(L,n) == LUA_TNONE)
 #define lua_isnull(L,n)		(lua_rawtag(L,n) == LUA_TNONE)
 
 
-#define lua_pushliteral(L, s)	lua_pushlstring(L, s, \
-                                                (sizeof(s)/sizeof(lua_char))-1)
+#define lua_pushliteral(L, s)	lua_pushlstring(L, "" s, \
+                                                (sizeof(s)/sizeof(char))-1)
 
 
 #define lua_getregistry(L)	lua_pushvalue(L, LUA_REGISTRYINDEX);
 #define lua_getregistry(L)	lua_pushvalue(L, LUA_REGISTRYINDEX);
 #define lua_getglobals(L)	lua_pushvalue(L, LUA_GLOBALSINDEX);
 #define lua_getglobals(L)	lua_pushvalue(L, LUA_GLOBALSINDEX);
@@ -264,7 +258,7 @@ LUA_API void lua_pushupvalues (lua_State *L);
 #define LUA_REFNIL	(-1)
 #define LUA_REFNIL	(-1)
 
 
 #define lua_ref(L,lock)	((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
 #define lua_ref(L,lock)	((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
-		(lua_error(L, l_s("unlocked references are obsolete")), 0))
+		(lua_error(L, "unlocked references are obsolete"), 0))
 
 
 #define lua_unref(L,ref)	luaL_unref(L, LUA_REGISTRYINDEX, (ref))
 #define lua_unref(L,ref)	luaL_unref(L, LUA_REGISTRYINDEX, (ref))
 
 
@@ -277,43 +271,21 @@ LUA_API void lua_pushupvalues (lua_State *L);
 /*
 /*
 ** {======================================================================
 ** {======================================================================
 ** useful definitions for Lua kernel and libraries
 ** useful definitions for Lua kernel and libraries
+** =======================================================================
 */
 */
-#ifdef LUA_PRIVATE
-
-#define l_char	lua_char
-
-/* macro to control type of literal strings */
-#ifndef l_s
-#define l_s(x)  x
-#endif
-
-/* macro to control type of literal chars */
-#ifndef l_c
-#define l_c(x)  x
-#endif
-
-/* macro to `unsign' a character */
-#ifndef uchar
-#define uchar(c)        ((unsigned char)(c))
-#endif
-
-/* integer type to hold the result of fgetc */
-#ifndef l_charint
-#define l_charint	int
-#endif
 
 
-/*
-** formats for Lua numbers
-*/
+/* formats for Lua numbers */
 #ifndef LUA_NUMBER_SCAN
 #ifndef LUA_NUMBER_SCAN
 #define LUA_NUMBER_SCAN		"%lf"
 #define LUA_NUMBER_SCAN		"%lf"
 #endif
 #endif
+
 #ifndef LUA_NUMBER_FMT
 #ifndef LUA_NUMBER_FMT
 #define LUA_NUMBER_FMT		"%.16g"
 #define LUA_NUMBER_FMT		"%.16g"
 #endif
 #endif
+
 /* function to convert a lua_Number to a string */
 /* function to convert a lua_Number to a string */
 #ifndef lua_number2str
 #ifndef lua_number2str
-#define lua_number2str(s,n)     sprintf((s), l_s(LUA_NUMBER_FMT), (n))
+#define lua_number2str(s,n)     sprintf((s), LUA_NUMBER_FMT, (n))
 #endif
 #endif
 
 
 /* function to convert a string to a lua_Number */
 /* function to convert a string to a lua_Number */
@@ -321,7 +293,6 @@ LUA_API void lua_pushupvalues (lua_State *L);
 #define lua_str2number(s,p)     strtod((s), (p))
 #define lua_str2number(s,p)     strtod((s), (p))
 #endif
 #endif
 
 
-#endif
 /* }====================================================================== */
 /* }====================================================================== */
 
 
 
 

+ 10 - 10
luadebug.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: luadebug.h,v 1.19 2001/03/07 18:09:25 roberto Exp roberto $
+** $Id: luadebug.h,v 1.20 2001/04/06 21:17:37 roberto Exp $
 ** Debugging API
 ** Debugging API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -18,9 +18,9 @@ typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
 
 
 
 
 LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
 LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
-LUA_API int lua_getinfo (lua_State *L, const lua_char *what, lua_Debug *ar);
-LUA_API const lua_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
-LUA_API const lua_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
+LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
+LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
 
 
 LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
 LUA_API lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
 LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
 LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
@@ -29,15 +29,15 @@ LUA_API lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
 #define LUA_IDSIZE	60
 #define LUA_IDSIZE	60
 
 
 struct lua_Debug {
 struct lua_Debug {
-  const lua_char *event;     /* `call', `return' */
+  const char *event;     /* `call', `return' */
   int currentline;       /* (l) */
   int currentline;       /* (l) */
-  const lua_char *name;      /* (n) */
-  const lua_char *namewhat;  /* (n) `global', `tag method', `local', `field' */
+  const char *name;      /* (n) */
+  const char *namewhat;  /* (n) `global', `tag method', `local', `field' */
   int nups;              /* (u) number of upvalues */
   int nups;              /* (u) number of upvalues */
   int linedefined;       /* (S) */
   int linedefined;       /* (S) */
-  const lua_char *what;      /* (S) `Lua' function, `C' function, Lua `main' */
-  const lua_char *source;    /* (S) */
-  lua_char short_src[LUA_IDSIZE]; /* (S) */
+  const char *what;      /* (S) `Lua' function, `C' function, Lua `main' */
+  const char *source;    /* (S) */
+  char short_src[LUA_IDSIZE]; /* (S) */
   /* private part */
   /* private part */
   struct CallInfo *_ci;  /* active function */
   struct CallInfo *_ci;  /* active function */
 };
 };

+ 34 - 35
lundump.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lundump.c,v 1.36 2001/07/19 14:34:06 lhf Exp lhf $
+** $Id: lundump.c,v 1.43 2001/07/24 21:57:19 roberto Exp $
 ** load pre-compiled Lua chunks
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -7,7 +7,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "ldebug.h"
 #include "ldebug.h"
@@ -20,15 +19,15 @@
 #define	LoadByte		ezgetc
 #define	LoadByte		ezgetc
 #define	LoadShort		(short) LoadInt
 #define	LoadShort		(short) LoadInt
 
 
-static const l_char* ZNAME (ZIO* Z)
+static const char* ZNAME (ZIO* Z)
 {
 {
- const l_char* s=zname(Z);
- return (*s==l_c('@')) ? s+1 : s;
+ const char* s=zname(Z);
+ return (*s=='@') ? s+1 : s;
 }
 }
 
 
 static void unexpectedEOZ (lua_State* L, ZIO* Z)
 static void unexpectedEOZ (lua_State* L, ZIO* Z)
 {
 {
- luaO_verror(L,l_s("unexpected end of file in `%.99s'"),ZNAME(Z));
+ luaO_verror(L,"unexpected end of file in `%.99s'",ZNAME(Z));
 }
 }
 
 
 static int ezgetc (lua_State* L, ZIO* Z)
 static int ezgetc (lua_State* L, ZIO* Z)
@@ -48,9 +47,9 @@ static void LoadBlock (lua_State* L, void* b, size_t size, ZIO* Z, int swap)
 {
 {
  if (swap)
  if (swap)
  {
  {
-  l_char *p=(l_char*) b+size-1;
+  char *p=(char*) b+size-1;
   int n=size;
   int n=size;
-  while (n--) *p--=(l_char)ezgetc(L,Z);
+  while (n--) *p--=(char)ezgetc(L,Z);
  }
  }
  else
  else
   ezread(L,Z,b,size);
   ezread(L,Z,b,size);
@@ -60,12 +59,12 @@ static void LoadVector (lua_State* L, void* b, int m, size_t size, ZIO* Z, int s
 {
 {
  if (swap)
  if (swap)
  {
  {
-  l_char *q=(l_char*) b;
+  char *q=(char*) b;
   while (m--)
   while (m--)
   {
   {
-   l_char *p=q+size-1;
+   char *p=q+size-1;
    int n=size;
    int n=size;
-   while (n--) *p--=(l_char)ezgetc(L,Z);
+   while (n--) *p--=(char)ezgetc(L,Z);
    q+=size;
    q+=size;
   }
   }
  }
  }
@@ -101,7 +100,7 @@ static TString* LoadString (lua_State* L, ZIO* Z, int swap)
   return NULL;
   return NULL;
  else
  else
  {
  {
-  l_char* s=luaO_openspace(L,size,l_char);
+  char* s=luaO_openspace(L,size,char);
   LoadBlock(L,s,size,Z,0);
   LoadBlock(L,s,size,Z,0);
   return luaS_newlstr(L,s,size-1);	/* remove trailing '\0' */
   return luaS_newlstr(L,s,size-1);	/* remove trailing '\0' */
  }
  }
@@ -159,7 +158,7 @@ static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap)
 	tsvalue(o)=LoadString(L,Z,swap);
 	tsvalue(o)=LoadString(L,Z,swap);
 	break;
 	break;
    default:
    default:
-	luaO_verror(L,l_s("bad constant type (%d) in `%.99s'"),ttype(o),ZNAME(Z));
+	luaO_verror(L,"bad constant type (%d) in `%.99s'",ttype(o),ZNAME(Z));
 	break;
 	break;
   }
   }
  }
  }
@@ -183,25 +182,25 @@ static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap)
  LoadConstants(L,f,Z,swap);
  LoadConstants(L,f,Z,swap);
  LoadCode(L,f,Z,swap);
  LoadCode(L,f,Z,swap);
 #ifndef TRUST_BINARIES
 #ifndef TRUST_BINARIES
- if (!luaG_checkcode(f)) luaO_verror(L,l_s("bad code in `%.99s'"),ZNAME(Z));
+ if (!luaG_checkcode(f)) luaO_verror(L,"bad code in `%.99s'",ZNAME(Z));
 #endif
 #endif
  return f;
  return f;
 }
 }
 
 
 static void LoadSignature (lua_State* L, ZIO* Z)
 static void LoadSignature (lua_State* L, ZIO* Z)
 {
 {
- const l_char* s=l_s(LUA_SIGNATURE);
+ const char* s=LUA_SIGNATURE;
  while (*s!=0 && ezgetc(L,Z)==*s)
  while (*s!=0 && ezgetc(L,Z)==*s)
   ++s;
   ++s;
- if (*s!=0) luaO_verror(L,l_s("bad signature in `%.99s'"),ZNAME(Z));
+ if (*s!=0) luaO_verror(L,"bad signature in `%.99s'",ZNAME(Z));
 }
 }
 
 
-static void TestSize (lua_State* L, int s, const l_char* what, ZIO* Z)
+static void TestSize (lua_State* L, int s, const char* what, ZIO* Z)
 {
 {
  int r=LoadByte(L,Z);
  int r=LoadByte(L,Z);
  if (r!=s)
  if (r!=s)
-  luaO_verror(L,l_s("virtual machine mismatch in `%.99s':\n")
-	l_s("  size of %.20s is %d but read %d"),ZNAME(Z),what,s,r);
+  luaO_verror(L,"virtual machine mismatch in `%.99s':\n"
+	"  size of %.20s is %d but read %d",ZNAME(Z),what,s,r);
 }
 }
 
 
 #define TESTSIZE(s,w)	TestSize(L,s,w,Z)
 #define TESTSIZE(s,w)	TestSize(L,s,w,Z)
@@ -214,26 +213,26 @@ static int LoadHeader (lua_State* L, ZIO* Z)
  LoadSignature(L,Z);
  LoadSignature(L,Z);
  version=LoadByte(L,Z);
  version=LoadByte(L,Z);
  if (version>VERSION)
  if (version>VERSION)
-  luaO_verror(L,l_s("`%.99s' too new:\n")
-	l_s("  read version %d.%d; expected at most %d.%d"),
+  luaO_verror(L,"`%.99s' too new:\n"
+	"  read version %d.%d; expected at most %d.%d",
 	ZNAME(Z),V(version),V(VERSION));
 	ZNAME(Z),V(version),V(VERSION));
  if (version<VERSION0)			/* check last major change */
  if (version<VERSION0)			/* check last major change */
-  luaO_verror(L,l_s("`%.99s' too old:\n")
-	l_s("  read version %d.%d; expected at least %d.%d"),
+  luaO_verror(L,"`%.99s' too old:\n"
+	"  read version %d.%d; expected at least %d.%d",
 	ZNAME(Z),V(version),V(VERSION));
 	ZNAME(Z),V(version),V(VERSION));
  swap=(luaU_endianness()!=LoadByte(L,Z));	/* need to swap bytes? */
  swap=(luaU_endianness()!=LoadByte(L,Z));	/* need to swap bytes? */
- TESTSIZE(sizeof(int),l_s("int"));
- TESTSIZE(sizeof(size_t), l_s("size_t"));
- TESTSIZE(sizeof(Instruction), l_s("size_t"));
- TESTSIZE(SIZE_OP, l_s("OP"));
- TESTSIZE(SIZE_A, l_s("A"));
- TESTSIZE(SIZE_B, l_s("B"));
- TESTSIZE(SIZE_C, l_s("C"));
- TESTSIZE(sizeof(lua_Number), l_s("number"));
+ TESTSIZE(sizeof(int),"int");
+ TESTSIZE(sizeof(size_t), "size_t");
+ TESTSIZE(sizeof(Instruction), "size_t");
+ TESTSIZE(SIZE_OP, "OP");
+ TESTSIZE(SIZE_A, "A");
+ TESTSIZE(SIZE_B, "B");
+ TESTSIZE(SIZE_C, "C");
+ TESTSIZE(sizeof(lua_Number), "number");
  x=LoadNumber(L,Z,swap);
  x=LoadNumber(L,Z,swap);
  if ((long)x!=(long)tx)		/* disregard errors in last bits of fraction */
  if ((long)x!=(long)tx)		/* disregard errors in last bits of fraction */
-  luaO_verror(L,l_s("unknown number format in `%.99s':\n")
-      l_s("  read ") l_s(LUA_NUMBER_FMT) l_s("; expected ") l_s(LUA_NUMBER_FMT),
+  luaO_verror(L,"unknown number format in `%.99s':\n"
+      "  read " LUA_NUMBER_FMT "; expected " LUA_NUMBER_FMT,
       ZNAME(Z),x,tx);
       ZNAME(Z),x,tx);
  return swap;
  return swap;
 }
 }
@@ -250,7 +249,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
 {
 {
  Proto* f=LoadChunk(L,Z);
  Proto* f=LoadChunk(L,Z);
  if (zgetc(Z)!=EOZ)
  if (zgetc(Z)!=EOZ)
-  luaO_verror(L,l_s("`%.99s' apparently contains more than one chunk"),ZNAME(Z));
+  luaO_verror(L,"`%.99s' apparently contains more than one chunk",ZNAME(Z));
  return f;
  return f;
 }
 }
 
 
@@ -260,5 +259,5 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
 int luaU_endianness (void)
 int luaU_endianness (void)
 {
 {
  int x=1;
  int x=1;
- return *(l_char*)&x;
+ return *(char*)&x;
 }
 }

+ 23 - 24
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 1.197 2001/10/31 19:58:11 roberto Exp $
+** $Id: lvm.c,v 1.198 2001/11/06 21:41:53 roberto Exp $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lapi.h"
 #include "lapi.h"
@@ -54,7 +53,7 @@ int luaV_tostring (lua_State *L, TObject *obj) {
   if (ttype(obj) != LUA_TNUMBER)
   if (ttype(obj) != LUA_TNUMBER)
     return 1;
     return 1;
   else {
   else {
-    l_char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
+    char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
     lua_number2str(s, nvalue(obj));  /* convert `s' to number */
     lua_number2str(s, nvalue(obj));  /* convert `s' to number */
     setsvalue(obj, luaS_new(L, s));
     setsvalue(obj, luaS_new(L, s));
     return 0;
     return 0;
@@ -86,7 +85,7 @@ static void traceexec (lua_State *L, lua_Hook linehook) {
 /* maximum stack used by a call to a tag method (func + args) */
 /* maximum stack used by a call to a tag method (func + args) */
 #define MAXSTACK_TM	4
 #define MAXSTACK_TM	4
 
 
-static StkId callTM (lua_State *L, Closure *f, const l_char *fmt, ...) {
+static StkId callTM (lua_State *L, Closure *f, const char *fmt, ...) {
   va_list argp;
   va_list argp;
   StkId base = L->top;
   StkId base = L->top;
   lua_assert(strlen(fmt)+1 <= MAXSTACK_TM);
   lua_assert(strlen(fmt)+1 <= MAXSTACK_TM);
@@ -95,11 +94,11 @@ static StkId callTM (lua_State *L, Closure *f, const l_char *fmt, ...) {
   setclvalue(L->top, f);  /* push function */
   setclvalue(L->top, f);  /* push function */
   L->top++;
   L->top++;
   while (*fmt) {
   while (*fmt) {
-    if (*fmt++ == l_c('o')) {
+    if (*fmt++ == 'o') {
         setobj(L->top, va_arg(argp, TObject *));
         setobj(L->top, va_arg(argp, TObject *));
     }
     }
     else {
     else {
-      lua_assert(*(fmt-1) == l_c('s'));
+      lua_assert(*(fmt-1) == 's');
       setsvalue(L->top, va_arg(argp, TString *));
       setsvalue(L->top, va_arg(argp, TString *));
     }
     }
     L->top++;
     L->top++;
@@ -146,9 +145,9 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) {
   } else {  /* not a table; try a `gettable' tag method */
   } else {  /* not a table; try a `gettable' tag method */
     tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE);
     tm = luaT_gettmbyObj(G(L), t, TM_GETTABLE);
     if (tm == NULL)  /* no tag method? */
     if (tm == NULL)  /* no tag method? */
-      luaG_typeerror(L, t, l_s("index"));
+      luaG_typeerror(L, t, "index");
   }
   }
-  setTMresult(L, res, callTM(L, tm, l_s("oo"), t, key));
+  setTMresult(L, res, callTM(L, tm, "oo", t, key));
 }
 }
 
 
 
 
@@ -169,9 +168,9 @@ void luaV_settable (lua_State *L, StkId t, TObject *key, StkId val) {
   } else {  /* not a table; try a `settable' tag method */
   } else {  /* not a table; try a `settable' tag method */
     tm = luaT_gettmbyObj(G(L), t, TM_SETTABLE);
     tm = luaT_gettmbyObj(G(L), t, TM_SETTABLE);
     if (tm == NULL)  /* no tag method? */
     if (tm == NULL)  /* no tag method? */
-      luaG_typeerror(L, t, l_s("index"));
+      luaG_typeerror(L, t, "index");
   }
   }
-  setTM(L, callTM(L, tm, l_s("ooo"), t, key, val));
+  setTM(L, callTM(L, tm, "ooo", t, key, val));
 }
 }
 
 
 
 
@@ -183,7 +182,7 @@ void luaV_getglobal (lua_State *L, TString *name, StkId res) {
     setobj(res, value);  /* default behavior */
     setobj(res, value);  /* default behavior */
   }
   }
   else
   else
-    setTMresult(L, res, callTM(L, tm, l_s("so"), name, value));
+    setTMresult(L, res, callTM(L, tm, "so", name, value));
 }
 }
 
 
 
 
@@ -198,7 +197,7 @@ void luaV_setglobal (lua_State *L, TString *name, StkId val) {
       settableval(oldvalue, val);  /* warning: tricky optimization! */
       settableval(oldvalue, val);  /* warning: tricky optimization! */
   }
   }
   else
   else
-    setTM(L, callTM(L, tm, l_s("soo"), name, oldvalue, val));
+    setTM(L, callTM(L, tm, "soo", name, oldvalue, val));
 }
 }
 
 
 
 
@@ -213,7 +212,7 @@ static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,
         return 0;  /* no tag method */
         return 0;  /* no tag method */
     }
     }
   }
   }
-  setTMresult(L, res, callTM(L, tm, l_s("oo"), p1, p2));
+  setTMresult(L, res, callTM(L, tm, "oo", p1, p2));
   return 1;
   return 1;
 }
 }
 
 
@@ -226,9 +225,9 @@ static void call_arith (lua_State *L, StkId p1, TObject *p2,
 
 
 
 
 static int luaV_strlessthan (const TString *ls, const TString *rs) {
 static int luaV_strlessthan (const TString *ls, const TString *rs) {
-  const l_char *l = getstr(ls);
+  const char *l = getstr(ls);
   size_t ll = ls->tsv.len;
   size_t ll = ls->tsv.len;
-  const l_char *r = getstr(rs);
+  const char *r = getstr(rs);
   size_t lr = rs->tsv.len;
   size_t lr = rs->tsv.len;
   for (;;) {
   for (;;) {
     int temp = strcoll(l, r);
     int temp = strcoll(l, r);
@@ -271,14 +270,14 @@ void luaV_strconc (lua_State *L, int total, StkId top) {
       /* at least two string values; get as many as possible */
       /* at least two string values; get as many as possible */
       lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) +
       lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) +
                   cast(lu_mem, tsvalue(top-2)->tsv.len);
                   cast(lu_mem, tsvalue(top-2)->tsv.len);
-      l_char *buffer;
+      char *buffer;
       int i;
       int i;
       while (n < total && !tostring(L, top-n-1)) {  /* collect total length */
       while (n < total && !tostring(L, top-n-1)) {  /* collect total length */
         tl += tsvalue(top-n-1)->tsv.len;
         tl += tsvalue(top-n-1)->tsv.len;
         n++;
         n++;
       }
       }
-      if (tl > MAX_SIZET) luaD_error(L, l_s("string size overflow"));
-      buffer = luaO_openspace(L, tl, l_char);
+      if (tl > MAX_SIZET) luaD_error(L, "string size overflow");
+      buffer = luaO_openspace(L, tl, char);
       tl = 0;
       tl = 0;
       for (i=n; i>0; i--) {  /* concat all strings */
       for (i=n; i>0; i--) {  /* concat all strings */
         size_t l = tsvalue(top-i)->tsv.len;
         size_t l = tsvalue(top-i)->tsv.len;
@@ -301,7 +300,7 @@ static void luaV_pack (lua_State *L, StkId firstelem) {
     luaH_setnum(L, htab, i+1, firstelem+i);
     luaH_setnum(L, htab, i+1, firstelem+i);
   /* store counter in field `n' */
   /* store counter in field `n' */
   setnvalue(&n, i);
   setnvalue(&n, i);
-  luaH_setstr(L, htab, luaS_newliteral(L, l_s("n")), &n);
+  luaH_setstr(L, htab, luaS_newliteral(L, "n"), &n);
   L->top = firstelem;  /* remove elements from the stack */
   L->top = firstelem;  /* remove elements from the stack */
   sethvalue(L->top, htab);
   sethvalue(L->top, htab);
   incr_top;
   incr_top;
@@ -567,11 +566,11 @@ StkId luaV_execute (lua_State *L, const LClosure *cl, StkId base) {
       }
       }
       case OP_FORPREP: {
       case OP_FORPREP: {
         if (luaV_tonumber(ra, ra) == NULL)
         if (luaV_tonumber(ra, ra) == NULL)
-          luaD_error(L, l_s("`for' initial value must be a number"));
+          luaD_error(L, "`for' initial value must be a number");
         if (luaV_tonumber(ra+1, ra+1) == NULL)
         if (luaV_tonumber(ra+1, ra+1) == NULL)
-          luaD_error(L, l_s("`for' limit must be a number"));
+          luaD_error(L, "`for' limit must be a number");
         if (luaV_tonumber(ra+2, ra+2) == NULL)
         if (luaV_tonumber(ra+2, ra+2) == NULL)
-          luaD_error(L, l_s("`for' step must be a number"));
+          luaD_error(L, "`for' step must be a number");
         /* decrement index (to be incremented) */
         /* decrement index (to be incremented) */
         chgnvalue(ra, nvalue(ra) - nvalue(ra+2));
         chgnvalue(ra, nvalue(ra) - nvalue(ra+2));
         pc += -GETARG_sBc(i);  /* `jump' to loop end (delta is negated here) */
         pc += -GETARG_sBc(i);  /* `jump' to loop end (delta is negated here) */
@@ -583,7 +582,7 @@ StkId luaV_execute (lua_State *L, const LClosure *cl, StkId base) {
         runtime_check(L, ttype(ra+1) == LUA_TNUMBER &&
         runtime_check(L, ttype(ra+1) == LUA_TNUMBER &&
                          ttype(ra+2) == LUA_TNUMBER);
                          ttype(ra+2) == LUA_TNUMBER);
         if (ttype(ra) != LUA_TNUMBER)
         if (ttype(ra) != LUA_TNUMBER)
-          luaD_error(L, l_s("`for' index must be a number"));
+          luaD_error(L, "`for' index must be a number");
         chgnvalue(ra+1, nvalue(ra+1) - 1);  /* decrement counter */
         chgnvalue(ra+1, nvalue(ra+1) - 1);  /* decrement counter */
         if (nvalue(ra+1) >= 0) {
         if (nvalue(ra+1) >= 0) {
           chgnvalue(ra, nvalue(ra) + nvalue(ra+2));  /* increment index */
           chgnvalue(ra, nvalue(ra) + nvalue(ra+2));  /* increment index */
@@ -593,7 +592,7 @@ StkId luaV_execute (lua_State *L, const LClosure *cl, StkId base) {
       }
       }
       case OP_TFORPREP: {
       case OP_TFORPREP: {
         if (ttype(ra) != LUA_TTABLE)
         if (ttype(ra) != LUA_TTABLE)
-          luaD_error(L, l_s("`for' table must be a table"));
+          luaD_error(L, "`for' table must be a table");
         setnvalue(ra+1, -1);  /* initial index */
         setnvalue(ra+1, -1);  /* initial index */
         setnilvalue(ra+2);
         setnilvalue(ra+2);
         setnilvalue(ra+3);
         setnilvalue(ra+3);

+ 1 - 2
lzio.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lzio.c,v 1.13 2000/06/12 13:52:05 roberto Exp roberto $
+** $Id: lzio.c,v 1.14 2001/03/26 14:31:49 roberto Exp $
 ** a generic input stream interface
 ** a generic input stream interface
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -9,7 +9,6 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <string.h>
 #include <string.h>
 
 
-#define LUA_PRIVATE
 #include "lua.h"
 #include "lua.h"
 
 
 #include "lzio.h"
 #include "lzio.h"