Changeset 555

Show
Ignore:
Timestamp:
06/17/08 20:01:11 (4 months ago)
Author:
goodea
Message:

Upgrade lua to 5.1.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/lua51/Makefile.orig

    r531 r555  
    100100 
    101101macosx: 
    102         $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX 
    103 # use this on Mac OS X 10.4 
    104 #       $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline" 
     102        $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline" 
     103# use this on Mac OS X 10.3- 
     104#       $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX 
    105105 
    106106mingw: 
     
    149149lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ 
    150150  ltm.h lzio.h lmem.h ldo.h 
    151 loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \ 
    152   lualib.h 
     151loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h 
    153152lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \ 
    154153  ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h 
  • trunk/lib/lua51/lapi.c

    r270 r555  
    11/* 
    2 ** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $ 
     2** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $ 
    33** Lua API 
    44** See Copyright Notice in lua.h 
     
    124124 
    125125 
     126LUA_API void lua_setlevel (lua_State *from, lua_State *to) { 
     127  to->nCcalls = from->nCcalls; 
     128} 
     129 
     130 
    126131LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { 
    127132  lua_CFunction old; 
     
    750755      break; 
    751756  } 
    752   luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); 
     757  if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); 
    753758  L->top--; 
    754759  lua_unlock(L); 
  • trunk/lib/lua51/lapi.h

    r269 r555  
    11/* 
    2 ** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $ 
     2** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Auxiliary functions from Lua API 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lauxlib.c

    r270 r555  
    11/* 
    2 ** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $ 
     2** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ 
    33** Auxiliary functions for building Lua libraries 
    44** See Copyright Notice in lua.h 
     
    245245    int size = libsize(l); 
    246246    /* check whether lib already exists */ 
    247     luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size); 
     247    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); 
    248248    lua_getfield(L, -1, libname);  /* get _LOADED[libname] */ 
    249249    if (!lua_istable(L, -1)) {  /* not found? */ 
     
    536536  } 
    537537  if (feof(lf->f)) return NULL; 
    538   *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); 
     538  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); 
    539539  return (*size > 0) ? lf->buff : NULL; 
    540540} 
     
    571571    if (c == '\n') c = getc(lf.f); 
    572572  } 
    573   if (c == LUA_SIGNATURE[0] && lf.f != stdin) {  /* binary file? */ 
    574     fclose(lf.f); 
    575     lf.f = fopen(filename, "rb");  /* reopen in binary mode */ 
     573  if (c == LUA_SIGNATURE[0] && filename) {  /* binary file? */ 
     574    lf.f = freopen(filename, "rb", lf.f);  /* reopen in binary mode */ 
    576575    if (lf.f == NULL) return errfile(L, "reopen", fnameindex); 
    577576    /* skip eventual `#!...' */ 
     
    582581  status = lua_load(L, getF, &lf, lua_tostring(L, -1)); 
    583582  readstatus = ferror(lf.f); 
    584   if (lf.f != stdin) fclose(lf.f);  /* close file (even in case of errors) */ 
     583  if (filename) fclose(lf.f);  /* close file (even in case of errors) */ 
    585584  if (readstatus) { 
    586585    lua_settop(L, fnameindex);  /* ignore results from `lua_load' */ 
  • trunk/lib/lua51/lauxlib.h

    r270 r555  
    11/* 
    2 ** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 roberto Exp $ 
     2** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Auxiliary functions for building Lua libraries 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lbaselib.c

    r531 r555  
    11/* 
    2 ** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ 
     2** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $ 
    33** Basic library 
    44** See Copyright Notice in lua.h 
     
    478478*/ 
    479479 
     480#define CO_RUN  0       /* running */ 
     481#define CO_SUS  1       /* suspended */ 
     482#define CO_NOR  2       /* 'normal' (it resumed another coroutine) */ 
     483#define CO_DEAD 3 
     484 
     485static const char *const statnames[] = 
     486    {"running", "suspended", "normal", "dead"}; 
     487 
     488static int costatus (lua_State *L, lua_State *co) { 
     489  if (L == co) return CO_RUN; 
     490  switch (lua_status(co)) { 
     491    case LUA_YIELD: 
     492      return CO_SUS; 
     493    case 0: { 
     494      lua_Debug ar; 
     495      if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */ 
     496        return CO_NOR;  /* it is running */ 
     497      else if (lua_gettop(co) == 0) 
     498          return CO_DEAD; 
     499      else 
     500        return CO_SUS;  /* initial state */ 
     501    } 
     502    default:  /* some error occured */ 
     503      return CO_DEAD; 
     504  } 
     505} 
     506 
     507 
     508static int luaB_costatus (lua_State *L) { 
     509  lua_State *co = lua_tothread(L, 1); 
     510  luaL_argcheck(L, co, 1, "coroutine expected"); 
     511  lua_pushstring(L, statnames[costatus(L, co)]); 
     512  return 1; 
     513} 
     514 
     515 
    480516static int auxresume (lua_State *L, lua_State *co, int narg) { 
    481   int status
     517  int status = costatus(L, co)
    482518  if (!lua_checkstack(co, narg)) 
    483519    luaL_error(L, "too many arguments to resume"); 
    484   if (lua_status(co) == 0 && lua_gettop(co) == 0) { 
    485     lua_pushliteral(L, "cannot resume dead coroutine"); 
     520  if (status != CO_SUS) { 
     521    lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); 
    486522    return -1;  /* error flag */ 
    487523  } 
    488524  lua_xmove(L, co, narg); 
     525  lua_setlevel(L, co); 
    489526  status = lua_resume(co, narg); 
    490527  if (status == 0 || status == LUA_YIELD) { 
     
    557594 
    558595 
    559 static int luaB_costatus (lua_State *L) { 
    560   lua_State *co = lua_tothread(L, 1); 
    561   luaL_argcheck(L, co, 1, "coroutine expected"); 
    562   if (L == co) lua_pushliteral(L, "running"); 
    563   else { 
    564     switch (lua_status(co)) { 
    565       case LUA_YIELD: 
    566         lua_pushliteral(L, "suspended"); 
    567         break; 
    568       case 0: { 
    569         lua_Debug ar; 
    570         if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */ 
    571           lua_pushliteral(L, "normal");  /* it is running */ 
    572         else if (lua_gettop(co) == 0) 
    573             lua_pushliteral(L, "dead"); 
    574         else 
    575           lua_pushliteral(L, "suspended");  /* initial state */ 
    576         break; 
    577       } 
    578       default:  /* some error occured */ 
    579         lua_pushliteral(L, "dead"); 
    580         break; 
    581     } 
    582   } 
    583   return 1; 
    584 } 
    585  
    586  
    587596static int luaB_corunning (lua_State *L) { 
    588597  if (lua_pushthread(L)) 
    589     return 0;  /* main thread is not a coroutine */ 
    590   else 
    591     return 1; 
     598    lua_pushnil(L);  /* main thread is not a coroutine */ 
     599  return 1; 
    592600} 
    593601 
  • trunk/lib/lua51/ldblib.c

    r269 r555  
    11/* 
    2 ** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $ 
     2** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ 
    33** Interface from Lua to its debug API 
    44** See Copyright Notice in lua.h 
     
    256256 
    257257static int db_sethook (lua_State *L) { 
    258   int arg; 
     258  int arg, mask, count; 
     259  lua_Hook func; 
    259260  lua_State *L1 = getthread(L, &arg); 
    260261  if (lua_isnoneornil(L, arg+1)) { 
    261262    lua_settop(L, arg+1); 
    262     lua_sethook(L1, NULL, 0, 0);  /* turn off hooks */ 
     263    func = NULL; mask = 0; count = 0;  /* turn off hooks */ 
    263264  } 
    264265  else { 
    265266    const char *smask = luaL_checkstring(L, arg+2); 
    266     int count = luaL_optint(L, arg+3, 0); 
    267267    luaL_checktype(L, arg+1, LUA_TFUNCTION); 
    268     lua_sethook(L1, hookf, makemask(smask, count), count); 
    269   } 
    270   gethooktable(L1); 
    271   lua_pushlightuserdata(L1, L1); 
     268    count = luaL_optint(L, arg+3, 0); 
     269    func = hookf; mask = makemask(smask, count); 
     270  } 
     271  gethooktable(L); 
     272  lua_pushlightuserdata(L, L1); 
    272273  lua_pushvalue(L, arg+1); 
    273   lua_xmove(L, L1, 1); 
    274   lua_rawset(L1, -3);  /* set new hook */ 
    275   lua_pop(L1, 1);  /* remove hook table */ 
     274  lua_rawset(L, -3);  /* set new hook */ 
     275  lua_pop(L, 1);  /* remove hook table */ 
     276  lua_sethook(L1, func, mask, count);  /* set hooks */ 
    276277  return 0; 
    277278} 
     
    287288    lua_pushliteral(L, "external hook"); 
    288289  else { 
    289     gethooktable(L1); 
    290     lua_pushlightuserdata(L1, L1); 
    291     lua_rawget(L1, -2);   /* get hook */ 
    292     lua_remove(L1, -2);  /* remove hook table */ 
    293     lua_xmove(L1, L, 1); 
     290    gethooktable(L); 
     291    lua_pushlightuserdata(L, L1); 
     292    lua_rawget(L, -2);   /* get hook */ 
     293    lua_remove(L, -2);  /* remove hook table */ 
    294294  } 
    295295  lua_pushstring(L, unmakemask(mask, buff)); 
  • trunk/lib/lua51/ldebug.c

    r533 r555  
    11/* 
    2 ** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $ 
     2** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $ 
    33** Debug Interface 
    44** See Copyright Notice in lua.h 
     
    563563 
    564564void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { 
    565   if (ttisstring(p1)) p1 = p2; 
    566   lua_assert(!ttisstring(p1)); 
     565  if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; 
     566  lua_assert(!ttisstring(p1) && !ttisnumber(p1)); 
    567567  luaG_typeerror(L, p1, "concatenate"); 
    568568} 
  • trunk/lib/lua51/ldebug.h

    r269 r555  
    11/* 
    2 ** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $ 
     2** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Auxiliary functions from Debug Interface module 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/ldo.c

    r270 r555  
    11/* 
    2 ** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $ 
     2** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ 
    33** Stack and Call structure of Lua 
    44** See Copyright Notice in lua.h 
     
    8484  luaF_close(L, L->base);  /* close eventual pending closures */ 
    8585  luaD_seterrorobj(L, status, L->base); 
    86   L->nCcalls = 0
     86  L->nCcalls = L->baseCcalls
    8787  L->allowhook = 1; 
    8888  restore_stack_limit(L); 
     
    333333  luaD_callhook(L, LUA_HOOKRET, -1); 
    334334  if (f_isLua(L->ci)) {  /* Lua function? */ 
    335     while (L->ci->tailcalls--)  /* call hook for eventual tail calls */ 
     335    while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ 
    336336      luaD_callhook(L, LUA_HOOKTAILRET, -1); 
    337337  } 
     
    418418  int status; 
    419419  lua_lock(L); 
    420   if (L->status != LUA_YIELD) { 
    421     if (L->status != 0) 
    422       return resume_error(L, "cannot resume dead coroutine"); 
    423     else if (L->ci != L->base_ci) 
     420  if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) 
    424421      return resume_error(L, "cannot resume non-suspended coroutine"); 
    425   } 
     422  if (L->nCcalls >= LUAI_MAXCCALLS) 
     423    return resume_error(L, "C stack overflow"); 
    426424  luai_userstateresume(L, nargs); 
    427   lua_assert(L->errfunc == 0 && L->nCcalls == 0); 
     425  lua_assert(L->errfunc == 0); 
     426  L->baseCcalls = ++L->nCcalls; 
    428427  status = luaD_rawrunprotected(L, resume, L->top - nargs); 
    429428  if (status != 0) {  /* error? */ 
     
    432431    L->ci->top = L->top; 
    433432  } 
    434   else 
     433  else { 
     434    lua_assert(L->nCcalls == L->baseCcalls); 
    435435    status = L->status; 
     436  } 
     437  --L->nCcalls; 
    436438  lua_unlock(L); 
    437439  return status; 
     
    442444  luai_userstateyield(L, nresults); 
    443445  lua_lock(L); 
    444   if (L->nCcalls > 0
     446  if (L->nCcalls > L->baseCcalls
    445447    luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); 
    446448  L->base = L->top - nresults;  /* protect stack slots below */ 
  • trunk/lib/lua51/ldo.h

    r269 r555  
    11/* 
    2 ** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $ 
     2** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Stack and Call structure of Lua 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/ldump.c

    r269 r555  
    11/* 
    2 ** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $ 
     2** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** save precompiled Lua chunks 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lfunc.c

    r531 r555  
    11/* 
    2 ** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $ 
     2** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ 
    33** Auxiliary functions to manipulate prototypes and closures 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lfunc.h

    r269 r555  
    11/* 
    2 ** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $ 
     2** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Auxiliary functions to manipulate prototypes and closures 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lgc.c

    r270 r555  
    11/* 
    2 ** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $ 
     2** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Garbage Collector 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lgc.h

    r269 r555  
    11/* 
    2 ** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $ 
     2** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Garbage Collector 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/linit.c

    r532 r555  
    11/* 
    2 ** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $ 
     2** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Initialization of libraries for lua.c 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/liolib.c

    r270 r555  
    11/* 
    2 ** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $ 
     2** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ 
    33** Standard I/O (and system) library 
    44** See Copyright Notice in lua.h 
     
    5252 
    5353 
    54 #define topfile(L)    ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) 
     54#define tofilep(L)    ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) 
    5555 
    5656 
     
    7171 
    7272static FILE *tofile (lua_State *L) { 
    73   FILE **f = topfile(L); 
     73  FILE **f = tofilep(L); 
    7474  if (*f == NULL) 
    7575    luaL_error(L, "attempt to use a closed file"); 
     
    9494 
    9595/* 
    96 ** this function has a separated environment, which defines the 
    97 ** correct __close for 'popen' files 
     96** function to (not) close the standard files stdin, stdout, and stderr 
     97*/ 
     98static int io_noclose (lua_State *L) { 
     99  lua_pushnil(L); 
     100  lua_pushliteral(L, "cannot close standard file"); 
     101  return 2; 
     102
     103 
     104 
     105/* 
     106** function to close 'popen' files 
    98107*/ 
    99108static int io_pclose (lua_State *L) { 
    100   FILE **p = topfile(L); 
     109  FILE **p = tofilep(L); 
    101110  int ok = lua_pclose(L, *p); 
    102111  *p = NULL; 
     
    105114 
    106115 
     116/* 
     117** function to close regular files 
     118*/ 
    107119static int io_fclose (lua_State *L) { 
    108   FILE **p = topfile(L); 
     120  FILE **p = tofilep(L); 
    109121  int ok = (fclose(*p) == 0); 
    110122  *p = NULL; 
     
    129141 
    130142static int io_gc (lua_State *L) { 
    131   FILE *f = *topfile(L); 
    132   /* ignore closed files and standard files */ 
    133   if (f != NULL && f != stdin && f != stdout && f != stderr
     143  FILE *f = *tofilep(L); 
     144  /* ignore closed files */ 
     145  if (f != NULL
    134146    aux_close(L); 
    135147  return 0; 
     
    138150 
    139151static int io_tostring (lua_State *L) { 
    140   FILE *f = *topfile(L); 
     152  FILE *f = *tofilep(L); 
    141153  if (f == NULL) 
    142     lua_pushstring(L, "file (closed)"); 
     154    lua_pushliteral(L, "file (closed)"); 
    143155  else 
    144156    lua_pushfstring(L, "file (%p)", f); 
     
    156168 
    157169 
     170/* 
     171** this function has a separated environment, which defines the 
     172** correct __close for 'popen' files 
     173*/ 
    158174static int io_popen (lua_State *L) { 
    159175  const char *filename = luaL_checkstring(L, 1); 
     
    281297    if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) {  /* eof? */ 
    282298      luaL_pushresult(&b);  /* close buffer */ 
    283       return (lua_strlen(L, -1) > 0);  /* check whether read something */ 
     299      return (lua_objlen(L, -1) > 0);  /* check whether read something */ 
    284300    } 
    285301    l = strlen(p); 
     
    309325  } while (n > 0 && nr == rlen);  /* until end of count or eof */ 
    310326  luaL_pushresult(&b);  /* close buffer */ 
    311   return (n == 0 || lua_strlen(L, -1) > 0); 
     327  return (n == 0 || lua_objlen(L, -1) > 0); 
    312328} 
    313329 
     
    503519    lua_rawseti(L, LUA_ENVIRONINDEX, k); 
    504520  } 
    505   lua_setfield(L, -2, fname); 
     521  lua_pushvalue(L, -2);  /* copy environment */ 
     522  lua_setfenv(L, -2);  /* set it */ 
     523  lua_setfield(L, -3, fname); 
     524
     525 
     526 
     527static void newfenv (lua_State *L, lua_CFunction cls) { 
     528  lua_createtable(L, 0, 1); 
     529  lua_pushcfunction(L, cls); 
     530  lua_setfield(L, -2, "__close"); 
    506531} 
    507532 
     
    510535  createmeta(L); 
    511536  /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ 
    512   lua_createtable(L, 2, 1); 
     537  newfenv(L, io_fclose); 
    513538  lua_replace(L, LUA_ENVIRONINDEX); 
    514539  /* open library */ 
    515540  luaL_register(L, LUA_IOLIBNAME, iolib); 
    516541  /* create (and set) default files */ 
     542  newfenv(L, io_noclose);  /* close function for default files */ 
    517543  createstdfile(L, stdin, IO_INPUT, "stdin"); 
    518544  createstdfile(L, stdout, IO_OUTPUT, "stdout"); 
    519545  createstdfile(L, stderr, 0, "stderr"); 
    520   /* create environment for 'popen' */ 
     546  lua_pop(L, 1);  /* pop environment for default files */ 
    521547  lua_getfield(L, -1, "popen"); 
    522   lua_createtable(L, 0, 1); 
    523   lua_pushcfunction(L, io_pclose); 
    524   lua_setfield(L, -2, "__close"); 
    525   lua_setfenv(L, -2); 
     548  newfenv(L, io_pclose);  /* create environment for 'popen' */ 
     549  lua_setfenv(L, -2);  /* set fenv for 'popen' */ 
    526550  lua_pop(L, 1);  /* pop 'popen' */ 
    527   /* set default close function */ 
    528   lua_pushcfunction(L, io_fclose); 
    529   lua_setfield(L, LUA_ENVIRONINDEX, "__close"); 
    530551  return 1; 
    531552} 
  • trunk/lib/lua51/llex.c

    r533 r555  
    11/* 
    2 ** $Id: llex.c,v 2.20 2006/03/09 18:14:31 roberto Exp $ 
     2** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Lexical Analyzer 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/llex.h

    r533 r555  
    11/* 
    2 ** $Id: llex.h,v 1.58 2006/03/23 18:23:32 roberto Exp $ 
     2** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Lexical Analyzer 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/llimits.h

    r269 r555  
    11/* 
    2 ** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $ 
     2** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Limits, basic types, and some other `installation-dependent' definitions 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lmathlib.c

    r532 r555  
    11/* 
    2 ** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $ 
     2** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Standard mathematical library 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lmem.c

    r269 r555  
    11/* 
    2 ** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $ 
     2** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Interface to Memory Manager 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lmem.h

    r269 r555  
    11/* 
    2 ** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $ 
     2** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Interface to Memory Manager 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/loadlib.c

    r531 r555  
    11/* 
    2 ** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ 
     2** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $ 
    33** Dynamic library loader for Lua 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lobject.c

    r269 r555  
    11/* 
    2 ** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $ 
     2** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Some generic functions over Lua objects 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lobject.h

    r269 r555  
    11/* 
    2 ** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $ 
     2** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Type definitions for Lua objects 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lopcodes.c

    r269 r555  
    11/* 
    2 ** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $ 
     2** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** See Copyright Notice in lua.h 
    44*/ 
  • trunk/lib/lua51/lopcodes.h

    r270 r555  
    11/* 
    2 ** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $ 
     2** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Opcodes for Lua virtual machine 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/loslib.c

    r532 r555  
    11/* 
    2 ** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $ 
     2** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ 
    33** Standard Operating System library 
    44** See Copyright Notice in lua.h 
     
    218218static int os_exit (lua_State *L) { 
    219219  exit(luaL_optint(L, 1, EXIT_SUCCESS)); 
    220   return 0;  /* to avoid warnings */ 
    221220} 
    222221 
  • trunk/lib/lua51/lparser.c

    r533 r555  
    11/* 
    2 ** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $ 
     2** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ 
    33** Lua Parser 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lparser.h

    r533 r555  
    11/* 
    2 ** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $ 
     2** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Lua Parser 
    44** See Copyright Notice in lua.h 
     
    1313 
    1414 
    15 /* 
    16 ** Expression descriptor 
    17 */ 
    1815 
    1916LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 
  • trunk/lib/lua51/lstate.c

    r270 r555  
    11/* 
    2 ** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $ 
     2** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ 
    33** Global State 
    44** See Copyright Notice in lua.h 
     
    9494  L->openupval = NULL; 
    9595  L->size_ci = 0; 
    96   L->nCcalls = 0; 
     96  L->nCcalls = L->baseCcalls = 0; 
    9797  L->status = 0; 
    9898  L->base_ci = L->ci = NULL; 
     
    206206    L->ci = L->base_ci; 
    207207    L->base = L->top = L->ci->base; 
    208     L->nCcalls = 0; 
     208    L->nCcalls = L->baseCcalls = 0; 
    209209  } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); 
    210210  lua_assert(G(L)->tmudata == NULL); 
  • trunk/lib/lua51/lstate.h

    r269 r555  
    11/* 
    2 ** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $ 
     2** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ 
    33** Global State 
    44** See Copyright Notice in lua.h 
     
    113113  int size_ci;  /* size of array `base_ci' */ 
    114114  unsigned short nCcalls;  /* number of nested C calls */ 
     115  unsigned short baseCcalls;  /* nested C calls when resuming coroutine */ 
    115116  lu_byte hookmask; 
    116117  lu_byte allowhook; 
  • trunk/lib/lua51/lstring.c

    r269 r555  
    11/* 
    2 ** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $ 
     2** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** String table (keeps all strings handled by Lua) 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lstring.h

    r269 r555  
    11/* 
    2 ** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $ 
     2** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** String table (keep all strings handled by Lua) 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lstrlib.c

    r532 r555  
    11/* 
    2 ** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ 
     2** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $ 
    33** Standard library for string operations and pattern-matching 
    44** See Copyright Notice in lua.h 
     
    630630      break; 
    631631    } 
    632     default: { 
    633       luaL_argerror(L, 3, "string/function/table expected");  
    634       return; 
    635     } 
    636632  } 
    637633  if (!lua_toboolean(L, -1)) {  /* nil or false? */ 
     
    649645  const char *src = luaL_checklstring(L, 1, &srcl); 
    650646  const char *p = luaL_checkstring(L, 2); 
     647  int  tr = lua_type(L, 3); 
    651648  int max_s = luaL_optint(L, 4, srcl+1); 
    652649  int anchor = (*p == '^') ? (p++, 1) : 0; 
     
    654651  MatchState ms; 
    655652  luaL_Buffer b; 
     653  luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || 
     654                   tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, 
     655                      "string/function/table expected"); 
    656656  luaL_buffinit(L, &b); 
    657657  ms.L = L; 
  • trunk/lib/lua51/ltable.c

    r269 r555  
    11/* 
    2 ** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $ 
     2** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ 
    33** Lua tables (hash) 
    44** See Copyright Notice in lua.h 
     
    8585  unsigned int a[numints]; 
    8686  int i; 
    87   n += 1;  /* normalize number (avoid -0) */ 
    88   lua_assert(sizeof(a) <= sizeof(n)); 
     87  if (luai_numeq(n, 0))  /* avoid problems with -0 */ 
     88    return gnode(t, 0); 
    8989  memcpy(a, &n, sizeof(a)); 
    9090  for (i = 1; i < numints; i++) a[0] += a[i]; 
  • trunk/lib/lua51/ltable.h

    r269 r555  
    11/* 
    2 ** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $ 
     2** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Lua tables (hash) 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/ltablib.c

    r269 r555  
    11/* 
    2 ** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $ 
     2** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $ 
    33** Library for Table Manipulation 
    44** See Copyright Notice in lua.h 
     
    119119  int e = aux_getn(L, 1); 
    120120  int pos = luaL_optint(L, 2, e); 
    121   if (e == 0) return 0;  /* table is `empty' */ 
     121  if (!(1 <= pos && pos <= e))  /* position is outside bounds? */ 
     122   return 0;  /* nothing to remove */ 
    122123  luaL_setn(L, 1, e - 1);  /* t.n = n-1 */ 
    123124  lua_rawgeti(L, 1, pos);  /* result = t[pos] */ 
  • trunk/lib/lua51/ltm.c

    r269 r555  
    11/* 
    2 ** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $ 
     2** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Tag methods 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/ltm.h

    r269 r555  
    11/* 
    2 ** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $ 
     2** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 
    33** Tag methods 
    44** See Copyright Notice in lua.h 
  • trunk/lib/lua51/lua.c

    r270 r555  
    11/* 
    2 ** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp $ 
     2** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $ 
    33** Lua stand-alone interpreter 
    44** See Copyright Notice in lua.h 
     
    7575 
    7676static int traceback (lua_State *L) { 
     77  if (!lua_isstring(L, 1))  /* 'message' not a string? */ 
     78    return 1;  /* keep it intact */ 
    7779  lua_getfield(L, LUA_GLOBALSINDEX, "debug"); 
    7880  if (!lua_istable(L, -1)) { 
     
    145147  lua_getglobal(L, "require"); 
    146148<