History

Lua 5.1.3-rc1

Lua Team committed 18 years ago

Commit ea97e791 parent 4d388a360 files · +732 −439Browse files

Showing the changes to src (54 of 60 files). Show all

Unified · Split

54 files
  1. src/Makefile +1 −2
  2. src/lapi.c +7 −2
  3. src/lapi.h +1 −1
  4. src/lauxlib.c +2 −2
  5. src/lauxlib.h +1 −1
  6. src/lbaselib.c +41 −32
  7. src/lcode.c +2 −2
  8. src/lcode.h +1 −1
  9. src/ldblib.c +1 −1
  10. src/ldebug.c +3 −3
  11. src/ldebug.h +1 −1
  12. src/ldo.c +12 −10
  13. src/ldo.h +1 −1
  14. src/ldump.c +1 −1
  15. src/lfunc.c +1 −1
  16. src/lfunc.h +1 −1
  17. src/lgc.c +1 −1
  18. src/lgc.h +1 −1
  19. src/linit.c +1 −1
  20. src/liolib.c +7 −5
  21. src/llex.c +1 −1
  22. src/llex.h +1 −1
  23. src/llimits.h +1 −1
  24. src/lmathlib.c +1 −1
  25. src/lmem.c +1 −1
  26. src/lmem.h +1 −1
  27. src/loadlib.c +1 −1
  28. src/lobject.c +1 −1
  29. src/lobject.h +1 −1
  30. src/lopcodes.c +1 −1
  31. src/lopcodes.h +1 −1
  32. src/loslib.c +1 −1
  33. src/lparser.c +3 −1
  34. src/lparser.h +1 −1
  35. src/lstate.c +3 −3
  36. src/lstate.h +2 −1
  37. src/lstring.c +1 −1
  38. src/lstring.h +1 −1
  39. src/lstrlib.c +5 −5
  40. src/ltable.c +3 −3
  41. src/ltable.h +1 −1
  42. src/ltablib.c +3 −2
  43. src/ltm.c +1 −1
  44. src/ltm.h +1 −1
  45. src/lua.c +4 −2
  46. src/lua.h +7 −4
  47. src/luaconf.h +3 −2
  48. src/lualib.h +1 −1
  49. src/lundump.c +1 −1
  50. src/lundump.h +1 −1
  51. src/lvm.c +4 −6
  52. src/lvm.h +1 −1
  53. src/lzio.c +1 −1
  54. src/lzio.h +1 −1
src/Makefile+1−2
@@ -148,8 +148,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ · 147 unmodified lines
148lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h148lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
149lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \149lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
150 ltm.h lzio.h lmem.h ldo.h150 ltm.h lzio.h lmem.h ldo.h
151loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \151loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
152 lualib.h
153lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \152lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
154 ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h153 ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
155lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h154lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
src/lapi.c+7−2
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua API3** Lua API
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -123,6 +123,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { · 117 unmodified lines
123}123}
124 124
125 125
126LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
127 to->nCcalls = from->nCcalls;
128}
129
130
126LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {131LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
127 lua_CFunction old;132 lua_CFunction old;
128 lua_lock(L);133 lua_lock(L);
@@ -749,7 +754,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) { · 620 unmodified lines
749 res = 0;754 res = 0;
750 break;755 break;
751 }756 }
752 luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));757 if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
753 L->top--;758 L->top--;
754 lua_unlock(L);759 lua_unlock(L);
755 return res;760 return res;
src/lapi.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Auxiliary functions from Lua API3** Auxiliary functions from Lua API
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lauxlib.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $2** $Id: lauxlib.c,v 1.159.1.2 2008/01/17 14:04:41 roberto Exp $
3** Auxiliary functions for building Lua libraries3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -244,7 +244,7 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname, · 238 unmodified lines
244 if (libname) {244 if (libname) {
245 int size = libsize(l);245 int size = libsize(l);
246 /* check whether lib already exists */246 /* check whether lib already exists */
247 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);247 luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
248 lua_getfield(L, -1, libname); /* get _LOADED[libname] */248 lua_getfield(L, -1, libname); /* get _LOADED[libname] */
249 if (!lua_istable(L, -1)) { /* not found? */249 if (!lua_istable(L, -1)) { /* not found? */
250 lua_pop(L, 1); /* remove previous result */250 lua_pop(L, 1); /* remove previous result */
src/lauxlib.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Auxiliary functions for building Lua libraries3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lbaselib.c+41−32
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $2** $Id: lbaselib.c,v 1.191.1.3 2008/01/03 15:20:39 roberto Exp $
3** Basic library3** Basic library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -477,15 +477,52 @@ static const luaL_Reg base_funcs[] = { · 471 unmodified lines
477** =======================================================477** =======================================================
478*/478*/
479 479
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
480static int auxresume (lua_State *L, lua_State *co, int narg) {516static int auxresume (lua_State *L, lua_State *co, int narg) {
481 int status;517 int status = costatus(L, co);
482 if (!lua_checkstack(co, narg))518 if (!lua_checkstack(co, narg))
483 luaL_error(L, "too many arguments to resume");519 luaL_error(L, "too many arguments to resume");
484 if (lua_status(co) == 0 && lua_gettop(co) == 0) {520 if (status != CO_SUS) {
485 lua_pushliteral(L, "cannot resume dead coroutine");521 lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
486 return -1; /* error flag */522 return -1; /* error flag */
487 }523 }
488 lua_xmove(L, co, narg);524 lua_xmove(L, co, narg);
525 lua_setlevel(L, co);
489 status = lua_resume(co, narg);526 status = lua_resume(co, narg);
490 if (status == 0 || status == LUA_YIELD) {527 if (status == 0 || status == LUA_YIELD) {
491 int nres = lua_gettop(co);528 int nres = lua_gettop(co);
@@ -556,34 +593,6 @@ static int luaB_yield (lua_State *L) { · 64 unmodified lines
556}593}
557 594
558 595
559static 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
587static int luaB_corunning (lua_State *L) {596static int luaB_corunning (lua_State *L) {
588 if (lua_pushthread(L))597 if (lua_pushthread(L))
589 return 0; /* main thread is not a coroutine */598 return 0; /* main thread is not a coroutine */
src/lcode.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $2** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
3** Code generator for Lua3** Code generator for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -699,7 +699,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { · 693 unmodified lines
699 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;699 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
700 switch (op) {700 switch (op) {
701 case OPR_MINUS: {701 case OPR_MINUS: {
702 if (e->k == VK)702 if (!isnumeral(e))
703 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */703 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
704 codearith(fs, OP_UNM, e, &e2);704 codearith(fs, OP_UNM, e, &e2);
705 break;705 break;
src/lcode.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $2** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
3** Code generator for Lua3** Code generator for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ldblib.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $2** $Id: ldblib.c,v 1.104.1.1 2007/12/27 13:02:25 roberto Exp $
3** Interface from Lua to its debug API3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ldebug.c+3−3
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Debug Interface3** Debug Interface
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -563,8 +563,8 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { · 557 unmodified lines
563 563
564 564
565void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {565void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
566 if (ttisstring(p1)) p1 = p2;566 if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
567 lua_assert(!ttisstring(p1));567 lua_assert(!ttisstring(p1) && !ttisnumber(p1));
568 luaG_typeerror(L, p1, "concatenate");568 luaG_typeerror(L, p1, "concatenate");
569}569}
570 570
src/ldebug.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Auxiliary functions from Debug Interface module3** Auxiliary functions from Debug Interface module
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ldo.c+12−10
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $2** $Id: ldo.c,v 2.38.1.2 2008/01/03 15:20:39 roberto Exp $
3** Stack and Call structure of Lua3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -83,7 +83,7 @@ static void resetstack (lua_State *L, int status) { · 77 unmodified lines
83 L->base = L->ci->base;83 L->base = L->ci->base;
84 luaF_close(L, L->base); /* close eventual pending closures */84 luaF_close(L, L->base); /* close eventual pending closures */
85 luaD_seterrorobj(L, status, L->base);85 luaD_seterrorobj(L, status, L->base);
86 L->nCcalls = 0;86 L->nCcalls = L->baseCcalls;
87 L->allowhook = 1;87 L->allowhook = 1;
88 restore_stack_limit(L);88 restore_stack_limit(L);
89 L->errfunc = 0;89 L->errfunc = 0;
@@ -417,22 +417,24 @@ static int resume_error (lua_State *L, const char *msg) { · 327 unmodified lines
417LUA_API int lua_resume (lua_State *L, int nargs) {417LUA_API int lua_resume (lua_State *L, int nargs) {
418 int status;418 int status;
419 lua_lock(L);419 lua_lock(L);
420 if (L->status != LUA_YIELD) {420 if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
421 if (L->status != 0)
422 return resume_error(L, "cannot resume dead coroutine");
423 else if (L->ci != L->base_ci)
424 return resume_error(L, "cannot resume non-suspended coroutine");421 return resume_error(L, "cannot resume non-suspended coroutine");
425 }422 if (L->nCcalls >= LUAI_MAXCCALLS)
423 return resume_error(L, "C stack overflow");
426 luai_userstateresume(L, nargs);424 luai_userstateresume(L, nargs);
427 lua_assert(L->errfunc == 0 && L->nCcalls == 0);425 lua_assert(L->errfunc == 0);
426 L->baseCcalls = ++L->nCcalls;
428 status = luaD_rawrunprotected(L, resume, L->top - nargs);427 status = luaD_rawrunprotected(L, resume, L->top - nargs);
429 if (status != 0) { /* error? */428 if (status != 0) { /* error? */
430 L->status = cast_byte(status); /* mark thread as `dead' */429 L->status = cast_byte(status); /* mark thread as `dead' */
431 luaD_seterrorobj(L, status, L->top);430 luaD_seterrorobj(L, status, L->top);
432 L->ci->top = L->top;431 L->ci->top = L->top;
433 }432 }
434 else433 else {
434 lua_assert(L->nCcalls == L->baseCcalls);
435 status = L->status;435 status = L->status;
436 }
437 --L->nCcalls;
436 lua_unlock(L);438 lua_unlock(L);
437 return status;439 return status;
438}440}
@@ -441,7 +443,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) { · 2 unmodified lines
441LUA_API int lua_yield (lua_State *L, int nresults) {443LUA_API int lua_yield (lua_State *L, int nresults) {
442 luai_userstateyield(L, nresults);444 luai_userstateyield(L, nresults);
443 lua_lock(L);445 lua_lock(L);
444 if (L->nCcalls > 0)446 if (L->nCcalls > L->baseCcalls)
445 luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");447 luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
446 L->base = L->top - nresults; /* protect stack slots below */448 L->base = L->top - nresults; /* protect stack slots below */
447 L->status = LUA_YIELD;449 L->status = LUA_YIELD;
src/ldo.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Stack and Call structure of Lua3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ldump.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** save precompiled Lua chunks3** save precompiled Lua chunks
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lfunc.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Auxiliary functions to manipulate prototypes and closures3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lfunc.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Auxiliary functions to manipulate prototypes and closures3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lgc.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Garbage Collector3** Garbage Collector
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lgc.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Garbage Collector3** Garbage Collector
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/linit.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Initialization of libraries for lua.c3** Initialization of libraries for lua.c
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/liolib.c+7−5
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $2** $Id: liolib.c,v 2.73.1.2 2008/01/02 13:56:00 roberto Exp $
3** Standard I/O (and system) library3** Standard I/O (and system) library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -106,8 +106,11 @@ static int io_pclose (lua_State *L) { · 100 unmodified lines
106 106
107static int io_fclose (lua_State *L) {107static int io_fclose (lua_State *L) {
108 FILE **p = topfile(L);108 FILE **p = topfile(L);
109 int ok = (fclose(*p) == 0);109 int ok = 0;
110 *p = NULL;110 if (*p != stdin && *p != stdout && *p != stderr) {
111 ok = (fclose(*p) == 0);
112 *p = NULL;
113 }
111 return pushresult(L, ok, NULL);114 return pushresult(L, ok, NULL);
112}115}
113 116
@@ -129,8 +132,7 @@ static int io_close (lua_State *L) { · 15 unmodified lines
129 132
130static int io_gc (lua_State *L) {133static int io_gc (lua_State *L) {
131 FILE *f = *topfile(L);134 FILE *f = *topfile(L);
132 /* ignore closed files and standard files */135 if (f != NULL) /* ignore closed files */
133 if (f != NULL && f != stdin && f != stdout && f != stderr)
134 aux_close(L);136 aux_close(L);
135 return 0;137 return 0;
136}138}
src/llex.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/llex.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/llimits.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Limits, basic types, and some other `installation-dependent' definitions3** Limits, basic types, and some other `installation-dependent' definitions
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lmathlib.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Standard mathematical library3** Standard mathematical library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lmem.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Interface to Memory Manager3** Interface to Memory Manager
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lmem.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Interface to Memory Manager3** Interface to Memory Manager
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/loadlib.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Dynamic library loader for Lua3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5**5**
src/lobject.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Some generic functions over Lua objects3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lobject.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Type definitions for Lua objects3** Type definitions for Lua objects
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lopcodes.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** See Copyright Notice in lua.h3** See Copyright Notice in lua.h
4*/4*/
5 5
src/lopcodes.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Opcodes for Lua virtual machine3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/loslib.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $2** $Id: loslib.c,v 1.19.1.2 2007/12/28 14:58:43 roberto Exp $
3** Standard Operating System library3** Standard Operating System library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lparser.c+3−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua Parser3** Lua Parser
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -938,6 +938,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { · 932 unmodified lines
938 primaryexp(ls, &nv.v);938 primaryexp(ls, &nv.v);
939 if (nv.v.k == VLOCAL)939 if (nv.v.k == VLOCAL)
940 check_conflict(ls, lh, &nv.v);940 check_conflict(ls, lh, &nv.v);
941 luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
942 "variables in assignment");
941 assignment(ls, &nv, nvars+1);943 assignment(ls, &nv, nvars+1);
942 }944 }
943 else { /* assignment -> `=' explist1 */945 else { /* assignment -> `=' explist1 */
src/lparser.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua Parser3** Lua Parser
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lstate.c+3−3
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Global State3** Global State
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -93,7 +93,7 @@ static void preinit_state (lua_State *L, global_State *g) { · 87 unmodified lines
93 resethookcount(L);93 resethookcount(L);
94 L->openupval = NULL;94 L->openupval = NULL;
95 L->size_ci = 0;95 L->size_ci = 0;
96 L->nCcalls = 0;96 L->nCcalls = L->baseCcalls = 0;
97 L->status = 0;97 L->status = 0;
98 L->base_ci = L->ci = NULL;98 L->base_ci = L->ci = NULL;
99 L->savedpc = NULL;99 L->savedpc = NULL;
@@ -205,7 +205,7 @@ LUA_API void lua_close (lua_State *L) { · 105 unmodified lines
205 do { /* repeat until no more errors */205 do { /* repeat until no more errors */
206 L->ci = L->base_ci;206 L->ci = L->base_ci;
207 L->base = L->top = L->ci->base;207 L->base = L->top = L->ci->base;
208 L->nCcalls = 0;208 L->nCcalls = L->baseCcalls = 0;
209 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);209 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
210 lua_assert(G(L)->tmudata == NULL);210 lua_assert(G(L)->tmudata == NULL);
211 luai_userstateclose(L);211 luai_userstateclose(L);
src/lstate.h+2−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Global State3** Global State
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -112,6 +112,7 @@ struct lua_State { · 106 unmodified lines
112 int stacksize;112 int stacksize;
113 int size_ci; /* size of array `base_ci' */113 int size_ci; /* size of array `base_ci' */
114 unsigned short nCcalls; /* number of nested C calls */114 unsigned short nCcalls; /* number of nested C calls */
115 unsigned short baseCcalls; /* nested C calls when resuming coroutine */
115 lu_byte hookmask;116 lu_byte hookmask;
116 lu_byte allowhook;117 lu_byte allowhook;
117 int basehookcount;118 int basehookcount;
src/lstring.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** String table (keeps all strings handled by Lua)3** String table (keeps all strings handled by Lua)
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lstring.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** String table (keep all strings handled by Lua)3** String table (keep all strings handled by Lua)
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lstrlib.c+5−5
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Standard library for string operations and pattern-matching3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -629,10 +629,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, · 623 unmodified lines
629 lua_gettable(L, 3);629 lua_gettable(L, 3);
630 break;630 break;
631 }631 }
632 default: {
633 luaL_argerror(L, 3, "string/function/table expected");
634 return;
635 }
636 }632 }
637 if (!lua_toboolean(L, -1)) { /* nil or false? */633 if (!lua_toboolean(L, -1)) { /* nil or false? */
638 lua_pop(L, 1);634 lua_pop(L, 1);
@@ -648,11 +644,15 @@ static int str_gsub (lua_State *L) { · 9 unmodified lines
648 size_t srcl;644 size_t srcl;
649 const char *src = luaL_checklstring(L, 1, &srcl);645 const char *src = luaL_checklstring(L, 1, &srcl);
650 const char *p = luaL_checkstring(L, 2);646 const char *p = luaL_checkstring(L, 2);
647 int tr = lua_type(L, 3);
651 int max_s = luaL_optint(L, 4, srcl+1);648 int max_s = luaL_optint(L, 4, srcl+1);
652 int anchor = (*p == '^') ? (p++, 1) : 0;649 int anchor = (*p == '^') ? (p++, 1) : 0;
653 int n = 0;650 int n = 0;
654 MatchState ms;651 MatchState ms;
655 luaL_Buffer b;652 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");
656 luaL_buffinit(L, &b);656 luaL_buffinit(L, &b);
657 ms.L = L;657 ms.L = L;
658 ms.src_init = src;658 ms.src_init = src;
src/ltable.c+3−3
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua tables (hash)3** Lua tables (hash)
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -84,8 +84,8 @@ static const Node dummynode_ = { · 78 unmodified lines
84static Node *hashnum (const Table *t, lua_Number n) {84static Node *hashnum (const Table *t, lua_Number n) {
85 unsigned int a[numints];85 unsigned int a[numints];
86 int i;86 int i;
87 n += 1; /* normalize number (avoid -0) */87 if (luai_numeq(n, 0)) /* avoid problems with -0 */
88 lua_assert(sizeof(a) <= sizeof(n));88 return gnode(t, 0);
89 memcpy(a, &n, sizeof(a));89 memcpy(a, &n, sizeof(a));
90 for (i = 1; i < numints; i++) a[0] += a[i];90 for (i = 1; i < numints; i++) a[0] += a[i];
91 return hashmod(t, a[0]);91 return hashmod(t, a[0]);
src/ltable.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua tables (hash)3** Lua tables (hash)
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ltablib.c+3−2
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Library for Table Manipulation3** Library for Table Manipulation
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -118,7 +118,8 @@ static int tinsert (lua_State *L) { · 112 unmodified lines
118static int tremove (lua_State *L) {118static int tremove (lua_State *L) {
119 int e = aux_getn(L, 1);119 int e = aux_getn(L, 1);
120 int pos = luaL_optint(L, 2, e);120 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 */
122 luaL_setn(L, 1, e - 1); /* t.n = n-1 */123 luaL_setn(L, 1, e - 1); /* t.n = n-1 */
123 lua_rawgeti(L, 1, pos); /* result = t[pos] */124 lua_rawgeti(L, 1, pos); /* result = t[pos] */
124 for ( ;pos<e; pos++) {125 for ( ;pos<e; pos++) {
src/ltm.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Tag methods3** Tag methods
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/ltm.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Tag methods3** Tag methods
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lua.c+4−2
@@ -1,5 +1,5 @@
1/*1/*
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 $
3** Lua stand-alone interpreter3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -74,6 +74,8 @@ static int report (lua_State *L, int status) { · 68 unmodified lines
74 74
75 75
76static int traceback (lua_State *L) {76static int traceback (lua_State *L) {
77 if (!lua_isstring(L, 1)) /* 'message' not a string? */
78 return 1; /* keep it intact */
77 lua_getfield(L, LUA_GLOBALSINDEX, "debug");79 lua_getfield(L, LUA_GLOBALSINDEX, "debug");
78 if (!lua_istable(L, -1)) {80 if (!lua_istable(L, -1)) {
79 lua_pop(L, 1);81 lua_pop(L, 1);
@@ -144,7 +146,7 @@ static int dostring (lua_State *L, const char *s, const char *name) { · 64 unmodified lines
144static int dolibrary (lua_State *L, const char *name) {146static int dolibrary (lua_State *L, const char *name) {
145 lua_getglobal(L, "require");147 lua_getglobal(L, "require");
146 lua_pushstring(L, name);148 lua_pushstring(L, name);
147 return report(L, lua_pcall(L, 1, 0, 0));149 return report(L, docall(L, 1, 1));
148}150}
149 151
150 152
src/lua.h+7−4
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $2** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
3** Lua - An Extensible Extension Language3** Lua - An Extensible Extension Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file5** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@ · 11 unmodified lines
17 17
18 18
19#define LUA_VERSION "Lua 5.1"19#define LUA_VERSION "Lua 5.1"
20#define LUA_RELEASE "Lua 5.1.2"20#define LUA_RELEASE "Lua 5.1.3"
21#define LUA_VERSION_NUM 50121#define LUA_VERSION_NUM 501
22#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio"22#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
23#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"23#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
24 24
25 25
@@ -294,6 +294,9 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); · 268 unmodified lines
294#define lua_Chunkwriter lua_Writer294#define lua_Chunkwriter lua_Writer
295 295
296 296
297/* hack */
298LUA_API void lua_setlevel (lua_State *from, lua_State *to);
299
297 300
298/*301/*
299** {======================================================================302** {======================================================================
@@ -359,7 +362,7 @@ struct lua_Debug { · 59 unmodified lines
359 362
360 363
361/******************************************************************************364/******************************************************************************
362* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved.365* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
363*366*
364* Permission is hereby granted, free of charge, to any person obtaining367* Permission is hereby granted, free of charge, to any person obtaining
365* a copy of this software and associated documentation files (the368* a copy of this software and associated documentation files (the
src/luaconf.h+3−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $2** $Id: luaconf.h,v 1.82.1.5 2008/01/17 14:04:20 roberto Exp $
3** Configuration file for Lua3** Configuration file for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -442,7 +442,8 @@ · 436 unmodified lines
442** functions. This limit is arbitrary; its only purpose is to stop C442** functions. This limit is arbitrary; its only purpose is to stop C
443** functions to consume unlimited stack space.443** functions to consume unlimited stack space.
444*/444*/
445#define LUAI_MAXCSTACK 2048445#define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
446#define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
446 447
447 448
448 449
src/lualib.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $2** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
3** Lua standard libraries3** Lua standard libraries
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lundump.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $2** $Id: lundump.c,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
3** load precompiled Lua chunks3** load precompiled Lua chunks
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lundump.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $2** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
3** load precompiled Lua chunks3** load precompiled Lua chunks
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lvm.c+4−6
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $2** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
3** Lua virtual machine3** Lua virtual machine
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -61,11 +61,9 @@ static void traceexec (lua_State *L, const Instruction *pc) { · 55 unmodified lines
61 lu_byte mask = L->hookmask;61 lu_byte mask = L->hookmask;
62 const Instruction *oldpc = L->savedpc;62 const Instruction *oldpc = L->savedpc;
63 L->savedpc = pc;63 L->savedpc = pc;
64 if (mask > LUA_MASKLINE) { /* instruction-hook set? */64 if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
65 if (L->hookcount == 0) {65 resethookcount(L);
66 resethookcount(L);66 luaD_callhook(L, LUA_HOOKCOUNT, -1);
67 luaD_callhook(L, LUA_HOOKCOUNT, -1);
68 }
69 }67 }
70 if (mask & LUA_MASKLINE) {68 if (mask & LUA_MASKLINE) {
71 Proto *p = ci_func(L->ci)->l.p;69 Proto *p = ci_func(L->ci)->l.p;
src/lvm.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $2** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
3** Lua virtual machine3** Lua virtual machine
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lzio.c+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $2** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
3** a generic input stream interface3** a generic input stream interface
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
src/lzio.h+1−1
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $2** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
3** Buffered streams3** Buffered streams
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/