Changeset 266
- Timestamp:
- 07/09/06 16:58:32 (2 years ago)
- Files:
-
- trunk/lib/lua51/Makefile.orig (modified) (4 diffs)
- trunk/lib/lua51/lapi.c (modified) (2 diffs)
- trunk/lib/lua51/lauxlib.c (modified) (1 diff)
- trunk/lib/lua51/lauxlib.h (modified) (1 diff)
- trunk/lib/lua51/lcode.c (modified) (3 diffs)
- trunk/lib/lua51/lcode.h (modified) (1 diff)
- trunk/lib/lua51/ldo.c (modified) (3 diffs)
- trunk/lib/lua51/lgc.c (modified) (3 diffs)
- trunk/lib/lua51/liolib.c (modified) (2 diffs)
- trunk/lib/lua51/llex.c (modified) (1 diff)
- trunk/lib/lua51/llex.h (modified) (1 diff)
- trunk/lib/lua51/loadlib.c (modified) (1 diff)
- trunk/lib/lua51/lopcodes.h (modified) (1 diff)
- trunk/lib/lua51/loslib.c (modified) (3 diffs)
- trunk/lib/lua51/lparser.c (modified) (4 diffs)
- trunk/lib/lua51/lparser.h (modified) (1 diff)
- trunk/lib/lua51/lpow.c (deleted)
- trunk/lib/lua51/lpow.h (deleted)
- trunk/lib/lua51/lstate.c (modified) (2 diffs)
- trunk/lib/lua51/lstrlib.c (modified) (2 diffs)
- trunk/lib/lua51/lua.c (modified) (4 diffs)
- trunk/lib/lua51/lua.h (modified) (1 diff)
- trunk/lib/lua51/luac.c (modified) (6 diffs)
- trunk/lib/lua51/luaconf.h (modified) (12 diffs)
- trunk/lib/lua51/lvm.c (modified) (1 diff)
- trunk/lib/lua51/print.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/lua51/Makefile.orig
r141 r266 81 81 82 82 aix: 83 $(MAKE) all CC="xlc" CFLAGS="-O2 " MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"83 $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" 84 84 85 85 ansi: … … 122 122 lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h 123 123 lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ 124 lzio.h lmem.h lopcodes.h lparser.h l table.h ldebug.h lstate.h ltm.h \125 l do.h lgc.h124 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ 125 ltable.h 126 126 ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h 127 127 ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \ 128 llex.h lzio.h lmem.h lopcodes.h lparser.h l table.h ldebug.h lstate.h \129 l tm.h ldo.h lfunc.h lstring.h lgc.h lvm.h128 llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ 129 lfunc.h lstring.h lgc.h ltable.h lvm.h 130 130 ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ 131 lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h l table.h \132 l string.h lundump.h lvm.h131 lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \ 132 ltable.h lundump.h lvm.h 133 133 ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \ 134 134 lzio.h lmem.h lundump.h … … 140 140 liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h 141 141 llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \ 142 lzio.h lmem.h llex.h lparser.h l table.h lstring.h lgc.h142 lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h 143 143 lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h 144 144 lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ … … 151 151 loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h 152 152 lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ 153 lzio.h lmem.h lopcodes.h lparser.h l table.h ldebug.h lstate.h ltm.h \154 l do.h lfunc.h lstring.h lgc.h153 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \ 154 lfunc.h lstring.h lgc.h ltable.h 155 155 lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ 156 156 ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h trunk/lib/lua51/lapi.c
r198 r266 33 33 34 34 const char lua_ident[] = 35 "$Lua: " LUA_ VERSION" " LUA_COPYRIGHT " $\n"35 "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" 36 36 "$Authors: " LUA_AUTHORS " $\n" 37 37 "$URL: www.lua.org $\n"; … … 200 200 StkId o; 201 201 lua_lock(L); 202 /* explicit test for incompatible code */ 203 if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) 204 luaG_runerror(L, "no calling environment"); 202 205 api_checknelems(L, 1); 203 206 o = index2adr(L, idx); trunk/lib/lua51/lauxlib.c
r198 r266 124 124 LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { 125 125 void *p = lua_touserdata(L, ud); 126 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ 127 if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2)) 128 luaL_typerror(L, ud, tname); 129 lua_pop(L, 2); /* remove both metatables */ 130 return p; 126 if (p != NULL) { /* value is a userdata? */ 127 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ 128 lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ 129 if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ 130 lua_pop(L, 2); /* remove both metatables */ 131 return p; 132 } 133 } 134 } 135 luaL_typerror(L, ud, tname); /* else error */ 136 return NULL; /* to avoid warnings */ 131 137 } 132 138 trunk/lib/lua51/lauxlib.h
r199 r266 109 109 #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 110 110 111 #define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, 0, 0)) 111 #define luaL_dofile(L, fn) \ 112 (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 112 113 113 #define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0)) 114 #define luaL_dostring(L, s) \ 115 (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 114 116 115 117 #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) trunk/lib/lua51/lcode.c
r198 r266 732 732 lua_assert(e1->t == NO_JUMP); /* list must be closed */ 733 733 luaK_dischargevars(fs, e2); 734 luaK_concat(fs, &e1->f, e2->f); 735 e1->k = e2->k; e1->u.s.info = e2->u.s.info; 736 e1->u.s.aux = e2->u.s.aux; e1->t = e2->t; 734 luaK_concat(fs, &e2->f, e1->f); 735 *e1 = *e2; 737 736 break; 738 737 } … … 740 739 lua_assert(e1->f == NO_JUMP); /* list must be closed */ 741 740 luaK_dischargevars(fs, e2); 742 luaK_concat(fs, &e1->t, e2->t); 743 e1->k = e2->k; e1->u.s.info = e2->u.s.info; 744 e1->u.s.aux = e2->u.s.aux; e1->f = e2->f; 741 luaK_concat(fs, &e2->t, e1->t); 742 *e1 = *e2; 745 743 break; 746 744 } … … 751 749 freeexp(fs, e1); 752 750 SETARG_B(getcode(fs, e2), e1->u.s.info); 753 e1->k = e2->k; e1->u.s.info = e2->u.s.info;751 e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; 754 752 } 755 753 else { trunk/lib/lua51/lcode.h
r199 r266 33 33 } BinOpr; 34 34 35 #define binopistest(op) ((op) >= OPR_NE)36 35 37 36 typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; trunk/lib/lua51/ldo.c
r198 r266 384 384 StkId firstArg = cast(StkId, ud); 385 385 CallInfo *ci = L->ci; 386 if (L->status != LUA_YIELD) { /* start coroutine*/386 if (L->status == 0) { /* start coroutine? */ 387 387 lua_assert(ci == L->base_ci && firstArg > L->base); 388 388 if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) … … 390 390 } 391 391 else { /* resuming from previous yield */ 392 lua_assert(L->status == LUA_YIELD); 393 L->status = 0; 392 394 if (!f_isLua(ci)) { /* `common' yield? */ 393 395 /* finish interrupted execution of `OP_CALL' */ … … 400 402 L->base = L->ci->base; 401 403 } 402 L->status = 0;403 404 luaV_execute(L, cast_int(L->ci - L->base_ci)); 404 405 } trunk/lib/lua51/lgc.c
r198 r266 321 321 322 322 323 static void propagateall (global_State *g) { 324 while (g->gray) propagatemark(g); 323 static size_t propagateall (global_State *g) { 324 size_t m = 0; 325 while (g->gray) m += propagatemark(g); 326 return m; 325 327 } 326 328 … … 541 543 udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ 542 544 marktmu(g); /* mark `preserved' userdata */ 543 propagateall(g); /* remark, to propagate `preserveness' */545 udsize += propagateall(g); /* remark, to propagate `preserveness' */ 544 546 cleartable(g->weak); /* remove collected objects from weak tables */ 545 547 /* flip current white */ … … 591 593 if (g->tmudata) { 592 594 GCTM(L); 595 if (g->estimate > GCFINALIZECOST) 596 g->estimate -= GCFINALIZECOST; 593 597 return GCFINALIZECOST; 594 598 } trunk/lib/lua51/liolib.c
r198 r266 100 100 FILE **p = topfile(L); 101 101 int ok = lua_pclose(L, *p); 102 if (ok)*p = NULL;102 *p = NULL; 103 103 return pushresult(L, ok, NULL); 104 104 } … … 108 108 FILE **p = topfile(L); 109 109 int ok = (fclose(*p) == 0); 110 if (ok)*p = NULL;110 *p = NULL; 111 111 return pushresult(L, ok, NULL); 112 112 } trunk/lib/lua51/llex.c
r198 r266 21 21 #include "lstate.h" 22 22 #include "lstring.h" 23 #include "ltable.h" 23 24 #include "lzio.h" 24 25 trunk/lib/lua51/llex.h
r199 r266 69 69 70 70 LUAI_FUNC void luaX_init (lua_State *L); 71 LUAI_FUNC void luaX_setinput (lua_State *L, LexState * LS, ZIO *z,71 LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 72 72 TString *source); 73 LUAI_FUNC TString *luaX_newstring (LexState * LS, const char *str, size_t l);73 LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 74 74 LUAI_FUNC void luaX_next (LexState *ls); 75 75 LUAI_FUNC void luaX_lookahead (LexState *ls); trunk/lib/lua51/loadlib.c
r198 r266 22 22 #include "lualib.h" 23 23 24 25 /* environment variables that hold the search path for packages */26 #define LUA_PATH "LUA_PATH"27 #define LUA_CPATH "LUA_CPATH"28 24 29 25 /* prefix for open functions in C libraries */ trunk/lib/lua51/lopcodes.h
r199 r266 198 198 OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ 199 199 200 OP_TFORLOOP,/* A C R(A+3), ... ,R(A+ 3+C) := R(A)(R(A+1), R(A+2));201 if R(A+3) ~= nil then { pc++; R(A+2)=R(A+3); }*/200 OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); 201 if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */ 202 202 OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ 203 203 trunk/lib/lua51/loslib.c
r198 r266 29 29 else { 30 30 lua_pushnil(L); 31 if (filename) 32 lua_pushfstring(L, "%s: %s", filename, strerror(en)); 33 else 34 lua_pushfstring(L, "%s", strerror(en)); 31 lua_pushfstring(L, "%s: %s", filename, strerror(en)); 35 32 lua_pushinteger(L, en); 36 33 return 3; … … 127 124 static int os_date (lua_State *L) { 128 125 const char *s = luaL_optstring(L, 1, "%c"); 129 time_t t = lua_isnoneornil(L, 2) ? time(NULL) : 130 (time_t)luaL_checknumber(L, 2); 126 time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); 131 127 struct tm *stm; 132 128 if (*s == '!') { /* UTC? */ … … 200 196 static const char *const catnames[] = {"all", "collate", "ctype", "monetary", 201 197 "numeric", "time", NULL}; 202 const char *l = lua _tostring(L, 1);198 const char *l = luaL_optstring(L, 1, NULL); 203 199 int op = luaL_checkoption(L, 2, "all", catnames); 204 luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected");205 200 lua_pushstring(L, setlocale(cat[op], l)); 206 201 return 1; trunk/lib/lua51/lparser.c
r198 r266 24 24 #include "lstate.h" 25 25 #include "lstring.h" 26 26 #include "ltable.h" 27 27 28 28 … … 300 300 if (bl->upval) 301 301 luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); 302 lua_assert(!bl->isbreakable || !bl->upval); /* loops have no body */ 302 /* a block either controls scope or breaks (never both) */ 303 lua_assert(!bl->isbreakable || !bl->upval); 303 304 lua_assert(bl->nactvar == fs->nactvar); 304 305 fs->freereg = fs->nactvar; /* free registers */ … … 445 446 int reg = ls->fs->freereg; 446 447 expdesc key, val; 448 int rkkey; 447 449 if (ls->t.token == TK_NAME) { 448 450 luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); … … 453 455 cc->nh++; 454 456 checknext(ls, '='); 455 luaK_exp2RK(fs, &key);457 rkkey = luaK_exp2RK(fs, &key); 456 458 expr(ls, &val); 457 luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, luaK_exp2RK(fs, &key), 458 luaK_exp2RK(fs, &val)); 459 luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); 459 460 fs->freereg = reg; /* free registers */ 460 461 } trunk/lib/lua51/lparser.h
r199 r266 10 10 #include "llimits.h" 11 11 #include "lobject.h" 12 #include "ltable.h"13 12 #include "lzio.h" 14 13 trunk/lib/lua51/lstate.c
r198 r266 199 199 LUA_API void lua_close (lua_State *L) { 200 200 L = G(L)->mainthread; /* only the main thread can be closed */ 201 luai_userstateclose(L);202 201 lua_lock(L); 203 202 luaF_close(L, L->stack); /* close all upvalues for this thread */ … … 210 209 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); 211 210 lua_assert(G(L)->tmudata == NULL); 211 luai_userstateclose(L); 212 212 close_state(L); 213 213 } trunk/lib/lua51/lstrlib.c
r198 r266 702 702 luaL_addchar(b, '\\'); 703 703 luaL_addchar(b, *s); 704 break; 705 } 706 case '\r': { 707 luaL_addlstring(b, "\\r", 2); 704 708 break; 705 709 } … … 806 810 } 807 811 default: { /* also treat cases `pnLlh' */ 808 return luaL_error(L, "invalid option to " LUA_QL("format")); 812 return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " 813 LUA_QL("format"), *(strfrmt - 1)); 809 814 } 810 815 } trunk/lib/lua51/lua.c
r198 r266 108 108 109 109 static void print_version (void) { 110 l_message(NULL, LUA_ VERSION" " LUA_COPYRIGHT);110 l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); 111 111 } 112 112 … … 253 253 254 254 255 /* check that argument has no extra characters at the end */ 256 #define notail(x) {if ((x)[2] != '\0') return -1;} 257 258 255 259 static int collectargs (char **argv, int *pi, int *pv, int *pe) { 256 260 int i; … … 259 263 return i; 260 264 switch (argv[i][1]) { /* option */ 261 case '-': return (argv[i+1] != NULL ? i+1 : 0); 262 case '\0': return i; 263 case 'i': *pi = 1; /* go through */ 264 case 'v': *pv = 1; break; 265 case 'e': *pe = 1; /* go through */ 265 case '-': 266 notail(argv[i]); 267 return (argv[i+1] != NULL ? i+1 : 0); 268 case '\0': 269 return i; 270 case 'i': 271 notail(argv[i]); 272 *pi = 1; /* go through */ 273 case 'v': 274 notail(argv[i]); 275 *pv = 1; 276 break; 277 case 'e': 278 *pe = 1; /* go through */ 266 279 case 'l': 267 280 if (argv[i][2] == '\0') { … … 307 320 308 321 static int handle_luainit (lua_State *L) { 309 const char *init = getenv( "LUA_INIT");322 const char *init = getenv(LUA_INIT); 310 323 if (init == NULL) return 0; /* status OK */ 311 324 else if (init[0] == '@') 312 325 return dofile(L, init+1); 313 326 else 314 return dostring(L, init, "= LUA_INIT");327 return dostring(L, init, "=" LUA_INIT); 315 328 } 316 329 trunk/lib/lua51/lua.h
r199 r266 18 18 19 19 #define LUA_VERSION "Lua 5.1" 20 #define LUA_RELEASE "Lua 5.1.1" 20 21 #define LUA_VERSION_NUM 501 21 22 #define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" trunk/lib/lua51/luac.c
r198 r266 71 71 { 72 72 int i; 73 int version=0; 73 74 if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; 74 75 for (i=1; i<argc; i++) … … 79 80 { 80 81 ++i; 82 if (version) ++version; 81 83 break; 82 84 } … … 96 98 stripping=1; 97 99 else if (IS("-v")) /* show version */ 98 { 99 printf("%s %s\n",LUA_VERSION,LUA_COPYRIGHT); 100 if (argc==2) exit(EXIT_SUCCESS); 101 } 100 ++version; 102 101 else /* unknown option */ 103 102 usage(argv[i]); … … 108 107 argv[--i]=Output; 109 108 } 109 if (version) 110 { 111 printf("%s %s\n",LUA_RELEASE,LUA_COPYRIGHT); 112 if (version==argc-1) exit(EXIT_SUCCESS); 113 } 110 114 return i; 111 115 } … … 113 117 #define toproto(L,i) (clvalue(L->top+(i))->l.p) 114 118 115 static Proto* combine(lua_State* L, int n)119 static const Proto* combine(lua_State* L, int n) 116 120 { 117 121 if (n==1) … … 157 161 int argc=s->argc; 158 162 char** argv=s->argv; 159 Proto* f;163 const Proto* f; 160 164 int i; 161 165 if (!lua_checkstack(L,argc)) fatal("too many input files"); trunk/lib/lua51/luaconf.h
r199 r266 58 58 #define LUA_USE_ULONGJMP 59 59 #endif 60 61 62 /* 63 @@ LUA_PATH and LUA_CPATH are the names of the environment variables that 64 @* Lua check to set its paths. 65 @@ LUA_INIT is the name of the environment variable that Lua 66 @* checks for initialization code. 67 ** CHANGE them if you want different names. 68 */ 69 #define LUA_PATH "LUA_PATH" 70 #define LUA_CPATH "LUA_CPATH" 71 #define LUA_INIT "LUA_INIT" 60 72 61 73 … … 231 243 ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) 232 244 */ 233 #define LUA_PROMPT "> :"234 #define LUA_PROMPT2 ">> :"245 #define LUA_PROMPT "> " 246 #define LUA_PROMPT2 ">> " 235 247 236 248 … … 322 334 ** access vararg parameters (instead of the old 'arg' table). 323 335 */ 324 # undefLUA_COMPAT_VARARG336 #define LUA_COMPAT_VARARG 325 337 326 338 /* … … 329 341 ** the new '%' operator instead of 'math.mod'. 330 342 */ 331 # undefLUA_COMPAT_MOD343 #define LUA_COMPAT_MOD 332 344 333 345 /* … … 337 349 ** off the advisory error when nesting [[...]]. 338 350 */ 339 # undef LUA_COMPAT_LSTR351 #define LUA_COMPAT_LSTR 1 340 352 341 353 /* … … 344 356 ** 'string.gmatch'. 345 357 */ 346 # undefLUA_COMPAT_GFIND358 #define LUA_COMPAT_GFIND 347 359 348 360 /* … … 352 364 ** your uses of 'luaL_openlib' 353 365 */ 354 # undefLUA_COMPAT_OPENLIB366 #define LUA_COMPAT_OPENLIB 355 367 356 368 … … 489 501 */ 490 502 491 /*#define LUA_NUMBER_DOUBLE */ 492 #define LUA_NUMBER long503 #define LUA_NUMBER_DOUBLE 504 #define LUA_NUMBER double 493 505 494 506 /* … … 496 508 @* over a number. 497 509 */ 498 #define LUAI_UACNUMBER long510 #define LUAI_UACNUMBER double 499 511 500 512 … … 506 518 @@ lua_str2number converts a string to a number. 507 519 */ 508 #define LUA_NUMBER_SCAN "%l d"509 #define LUA_NUMBER_FMT "% ld"520 #define LUA_NUMBER_SCAN "%lf" 521 #define LUA_NUMBER_FMT "%.14g" 510 522 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 511 523 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ 512 #define lua_str2number(s,p) strto l((s), (p), 10)524 #define lua_str2number(s,p) strtod((s), (p)) 513 525 514 526 … … 518 530 #if defined(LUA_CORE) 519 531 #include <math.h> 520 #include "lpow.h"521 532 #define luai_numadd(a,b) ((a)+(b)) 522 533 #define luai_numsub(a,b) ((a)-(b)) 523 534 #define luai_nummul(a,b) ((a)*(b)) 524 535 #define luai_numdiv(a,b) ((a)/(b)) 525 #define luai_nummod(a,b) ((a) %(b))526 #define luai_numpow(a,b) ( lpow(a,b))536 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) 537 #define luai_numpow(a,b) (pow(a,b)) 527 538 #define luai_numunm(a) (-(a)) 528 539 #define luai_numeq(a,b) ((a)==(b)) 529 540 #define luai_numlt(a,b) ((a)<(b)) 530 541 #define luai_numle(a,b) ((a)<=(b)) 531 #define luai_numisnan(a) ( 0)542 #define luai_numisnan(a) (!luai_numeq((a), (a))) 532 543 #endif 533 544 … … 545 556 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ 546 557 (defined(__i386) || defined (_M_IX86) || defined(__i386__)) 558 559 /* On a Microsoft compiler, use assembler */ 560 #if defined(_MSC_VER) 561 562 #define lua_number2int(i,d) __asm fld d __asm fistp i 563 #define lua_number2integer(i,n) lua_number2int(i, n) 564 565 /* the next trick should work on any Pentium, but sometimes clashes 566 with a DirectX idiosyncrasy */ 567 #else 568 547 569 union luai_Cast { double l_d; long l_l; }; 548 570 #define lua_number2int(i,d) \ 549 571 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } 550 572 #define lua_number2integer(i,n) lua_number2int(i, n) 573 574 #endif 575 551 576 552 577 /* this option always works, but may be slow */ trunk/lib/lua51/lvm.c
r198 r266 377 377 const Instruction *pc; 378 378 reentry: /* entry point */ 379 lua_assert(isLua(L->ci)); 379 380 pc = L->savedpc; 380 381 cl = &clvalue(L->ci->func)->l; trunk/lib/lua51/print.c
r198 r266 21 21 #define VOID(p) ((const void*)(p)) 22 22 23 static void PrintString(const Proto* f, int n) 24 { 25 const char* s=svalue(&f->k[n]); 23 static void PrintString(const TString* ts) 24 { 25 const char* s=getstr(ts); 26 int n=ts->tsv.len; 27 int i; 26 28 putchar('"'); 27 for (; *s; s++) 28 { 29 switch (*s) 29 for (i=0; i<n; i++) 30 { 31 int c=s[i]; 32 switch (c) 30 33 { 31 34 case '"': printf("\\\""); break; … … 37 40 case '\t': printf("\\t"); break; 38 41 case '\v': printf("\\v"); break; 39 default: if (isprint((unsigned char) *s))40 p rintf("%c",*s);42 default: if (isprint((unsigned char)c)) 43 putchar(c); 41 44 else 42 printf("\\%03u",(unsigned char) *s);45 printf("\\%03u",(unsigned char)c); 43 46 } 44 47 } … … 61 64 break; 62 65 case LUA_TSTRING: 63 PrintString( f,i);66 PrintString(rawtsvalue(o)); 64 67 break; 65 68 default: /* cannot happen */
