Changeset 531
- Timestamp:
- 08/09/07 00:28:51 (1 year ago)
- Files:
-
- trunk/lib/lua51/Makefile.orig (modified) (4 diffs)
- trunk/lib/lua51/README.txt (modified) (1 diff)
- trunk/lib/lua51/lbaselib.c (modified) (4 diffs)
- trunk/lib/lua51/lcode.c (modified) (4 diffs)
- trunk/lib/lua51/ldebug.c (modified) (2 diffs)
- trunk/lib/lua51/lfunc.c (modified) (3 diffs)
- trunk/lib/lua51/linit.c (modified) (1 diff)
- trunk/lib/lua51/lmathlib.c (modified) (1 diff)
- trunk/lib/lua51/loadlib.c (modified) (10 diffs)
- trunk/lib/lua51/loslib.c (modified) (5 diffs)
- trunk/lib/lua51/lparser.c (modified) (2 diffs)
- trunk/lib/lua51/lstrlib.c (modified) (4 diffs)
- trunk/lib/lua51/lua.h (modified) (3 diffs)
- trunk/lib/lua51/luaconf.h (modified) (7 diffs)
- trunk/lib/lua51/lvm.c (modified) (6 diffs)
- trunk/lib/lua51/print.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/lua51/Makefile.orig
r269 r531 21 21 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= 22 22 23 PLATS= aix ansi bsd generic linux macosx mingw posix solaris23 PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris 24 24 25 25 LUA_A= liblua.a … … 78 78 79 79 none: 80 @echo "Please choose a platform: $(PLATS)" 80 @echo "Please choose a platform:" 81 @echo " $(PLATS)" 81 82 82 83 aix: … … 88 89 bsd: 89 90 $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" 91 92 freebsd: 93 $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" 90 94 91 95 generic: … … 104 108 "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ 105 109 "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe 110 $(MAKE) "LUAC_T=luac.exe" luac.exe 106 111 107 112 posix: trunk/lib/lua51/README.txt
r269 r531 1 This is based on Lua 5.1. 1.1 This is based on Lua 5.1.2. 2 2 3 3 Please see the copyright notice in lua.h. trunk/lib/lua51/lbaselib.c
r269 r531 1 1 /* 2 ** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $2 ** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ 3 3 ** Basic library 4 4 ** See Copyright Notice in lua.h … … 115 115 116 116 117 static void getfunc (lua_State *L ) {117 static void getfunc (lua_State *L, int opt) { 118 118 if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); 119 119 else { 120 120 lua_Debug ar; 121 int level = luaL_optint(L, 1, 1);121 int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); 122 122 luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); 123 123 if (lua_getstack(L, level, &ar) == 0) … … 132 132 133 133 static int luaB_getfenv (lua_State *L) { 134 getfunc(L );134 getfunc(L, 1); 135 135 if (lua_iscfunction(L, -1)) /* is a C function? */ 136 136 lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ … … 143 143 static int luaB_setfenv (lua_State *L) { 144 144 luaL_checktype(L, 2, LUA_TTABLE); 145 getfunc(L );145 getfunc(L, 0); 146 146 lua_pushvalue(L, 2); 147 147 if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { trunk/lib/lua51/lcode.c
r270 r531 1 1 /* 2 ** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp $2 ** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $ 3 3 ** Code generator for Lua 4 4 ** See Copyright Notice in lua.h … … 36 36 Instruction *previous; 37 37 if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ 38 if (fs->pc == 0) /* function start? */ 39 return; /* positions are already clean */ 40 if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { 41 int pfrom = GETARG_A(*previous); 42 int pto = GETARG_B(*previous); 43 if (pfrom <= from && from <= pto+1) { /* can connect both? */ 44 if (from+n-1 > pto) 45 SETARG_B(*previous, from+n-1); 46 return; 38 if (fs->pc == 0) { /* function start? */ 39 if (from >= fs->nactvar) 40 return; /* positions are already clean */ 41 } 42 else { 43 previous = &fs->f->code[fs->pc-1]; 44 if (GET_OPCODE(*previous) == OP_LOADNIL) { 45 int pfrom = GETARG_A(*previous); 46 int pto = GETARG_B(*previous); 47 if (pfrom <= from && from <= pto+1) { /* can connect both? */ 48 if (from+n-1 > pto) 49 SETARG_B(*previous, from+n-1); 50 return; 51 } 47 52 } 48 53 } … … 658 663 return; 659 664 else { 665 int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; 660 666 int o1 = luaK_exp2RK(fs, e1); 661 int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; 662 freeexp(fs, e2); 663 freeexp(fs, e1); 667 if (o1 > o2) { 668 freeexp(fs, e1); 669 freeexp(fs, e2); 670 } 671 else { 672 freeexp(fs, e2); 673 freeexp(fs, e1); 674 } 664 675 e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); 665 676 e1->k = VRELOCABLE; … … 719 730 break; 720 731 } 732 case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: 733 case OPR_MOD: case OPR_POW: { 734 if (!isnumeral(v)) luaK_exp2RK(fs, v); 735 break; 736 } 721 737 default: { 722 if (!isnumeral(v))luaK_exp2RK(fs, v);738 luaK_exp2RK(fs, v); 723 739 break; 724 740 } trunk/lib/lua51/ldebug.c
r269 r531 1 1 /* 2 ** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $2 ** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $ 3 3 ** Debug Interface 4 4 ** See Copyright Notice in lua.h … … 433 433 } 434 434 case OP_CLOSURE: { 435 int nup ;435 int nup, j; 436 436 check(b < pt->sizep); 437 437 nup = pt->p[b]->nups; 438 438 check(pc + nup < pt->sizecode); 439 for ( ; nup>0; nup--) {440 OpCode op1 = GET_OPCODE(pt->code[pc +nup]);439 for (j = 1; j <= nup; j++) { 440 OpCode op1 = GET_OPCODE(pt->code[pc + j]); 441 441 check(op1 == OP_GETUPVAL || op1 == OP_MOVE); 442 442 } 443 if (reg != NO_REG) /* tracing? */ 444 pc += nup; /* do not 'execute' these pseudo-instructions */ 443 445 break; 444 446 } trunk/lib/lua51/lfunc.c
r269 r531 1 1 /* 2 ** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $2 ** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $ 3 3 ** Auxiliary functions to manipulate prototypes and closures 4 4 ** See Copyright Notice in lua.h … … 56 56 UpVal *p; 57 57 UpVal *uv; 58 while ( (p = ngcotouv(*pp)) != NULL && p->v >= level) {58 while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { 59 59 lua_assert(p->v != &p->u.value); 60 60 if (p->v == level) { /* found a corresponding upvalue? */ … … 97 97 UpVal *uv; 98 98 global_State *g = G(L); 99 while ( (uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {99 while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { 100 100 GCObject *o = obj2gco(uv); 101 101 lua_assert(!isblack(o) && uv->v != &uv->u.value); trunk/lib/lua51/linit.c
r270 r531 22 22 {LUA_OSLIBNAME, luaopen_os}, 23 23 {LUA_STRLIBNAME, luaopen_string}, 24 #if !defined LUA_NUMBER_INTEGRAL25 24 {LUA_MATHLIBNAME, luaopen_math}, 26 #endif27 25 {LUA_DBLIBNAME, luaopen_debug}, 28 26 {NULL, NULL} trunk/lib/lua51/lmathlib.c
r270 r531 253 253 lua_pushnumber(L, PI); 254 254 lua_setfield(L, -2, "pi"); 255 #if !defined LUA_NUMBER_INTEGRAL256 255 lua_pushnumber(L, HUGE_VAL); 257 256 lua_setfield(L, -2, "huge"); 258 #endif259 257 #if defined(LUA_COMPAT_MOD) 260 258 lua_getfield(L, -1, "fmod"); trunk/lib/lua51/loadlib.c
r270 r531 1 1 /* 2 ** $Id: loadlib.c,v 1.5 2 2006/04/10 18:27:23roberto Exp $2 ** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ 3 3 ** Dynamic library loader for Lua 4 4 ** See Copyright Notice in lua.h … … 17 17 #define LUA_LIB 18 18 19 #include "lua.h" 20 19 21 #include "lauxlib.h" 20 #include "lobject.h"21 #include "lua.h"22 22 #include "lualib.h" 23 23 … … 99 99 char *lb; 100 100 DWORD nsize = sizeof(buff)/sizeof(char); 101 DWORD n = GetModuleFileName (NULL, buff, nsize);101 DWORD n = GetModuleFileNameA(NULL, buff, nsize); 102 102 if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) 103 103 luaL_error(L, "unable to get ModuleFileName"); … … 113 113 int error = GetLastError(); 114 114 char buffer[128]; 115 if (FormatMessage (FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,115 if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, 116 116 NULL, error, 0, buffer, sizeof(buffer), NULL)) 117 117 lua_pushstring(L, buffer); … … 126 126 127 127 static void *ll_load (lua_State *L, const char *path) { 128 HINSTANCE lib = LoadLibrary (path);128 HINSTANCE lib = LoadLibraryA(path); 129 129 if (lib == NULL) pusherror(L); 130 130 return lib; … … 357 357 if (path == NULL) 358 358 luaL_error(L, LUA_QL("package.%s") " must be a string", pname); 359 lua_push string(L, ""); /* error accumulator */359 lua_pushliteral(L, ""); /* error accumulator */ 360 360 while ((path = pushnexttemplate(L, path)) != NULL) { 361 361 const char *filename; 362 362 filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); 363 lua_remove(L, -2); /* remove path template */ 363 364 if (readable(filename)) /* does file exist and is readable? */ 364 365 return filename; /* return that file name */ 365 lua_p op(L, 2); /* remove path template and file name */366 lua O_pushfstring(L, "\n\tno file " LUA_QS, filename);367 lua_concat(L, 2); 366 lua_pushfstring(L, "\n\tno file " LUA_QS, filename); 367 lua_remove(L, -2); /* remove file name */ 368 lua_concat(L, 2); /* add entry to possible error message */ 368 369 } 369 370 return NULL; /* not found */ … … 424 425 if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { 425 426 if (stat != ERRFUNC) loaderror(L, filename); /* real error */ 426 lua O_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,427 name, filename);427 lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, 428 name, filename); 428 429 return 1; /* function not found */ 429 430 } … … 439 440 lua_getfield(L, -1, name); 440 441 if (lua_isnil(L, -1)) /* not found? */ 441 lua O_pushfstring(L, "\n\tno field package.preload['%s']", name);442 lua_pushfstring(L, "\n\tno field package.preload['%s']", name); 442 443 return 1; 443 444 } … … 463 464 if (!lua_istable(L, -1)) 464 465 luaL_error(L, LUA_QL("package.loaders") " must be a table"); 465 lua_push string(L, ""); /* error message accumulator */466 lua_pushliteral(L, ""); /* error message accumulator */ 466 467 for (i=1; ; i++) { 467 468 lua_rawgeti(L, -2, i); /* get a loader */ … … 647 648 setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ 648 649 /* store config information */ 649 lua_push string(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"650 LUA_EXECDIR "\n" LUA_IGMARK);650 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" 651 LUA_EXECDIR "\n" LUA_IGMARK); 651 652 lua_setfield(L, -2, "config"); 652 653 /* set field `loaded' */ trunk/lib/lua51/loslib.c
r270 r531 1 1 /* 2 ** $Id: loslib.c,v 1. 19 2006/04/26 18:19:49roberto Exp $2 ** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $ 3 3 ** Standard Operating System library 4 4 ** See Copyright Notice in lua.h … … 147 147 } 148 148 else { 149 char b[256]; 150 if (strftime(b, sizeof(b), s, stm)) 151 lua_pushstring(L, b); 152 else 153 return luaL_error(L, LUA_QL("date") " format too long"); 149 char cc[3]; 150 luaL_Buffer b; 151 cc[0] = '%'; cc[2] = '\0'; 152 luaL_buffinit(L, &b); 153 for (; *s; s++) { 154 if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ 155 luaL_addchar(&b, *s); 156 else { 157 size_t reslen; 158 char buff[200]; /* should be big enough for any conversion result */ 159 cc[1] = *(++s); 160 reslen = strftime(buff, sizeof(buff), cc, stm); 161 luaL_addlstring(&b, buff, reslen); 162 } 163 } 164 luaL_pushresult(&b); 154 165 } 155 166 return 1; … … 182 193 183 194 184 #if !defined LUA_NUMBER_INTEGRAL185 195 static int os_difftime (lua_State *L) { 186 196 lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), … … 188 198 return 1; 189 199 } 190 #endif191 200 192 201 /* }====================================================== */ … … 213 222 {"clock", os_clock}, 214 223 {"date", os_date}, 215 #if !defined LUA_NUMBER_INTEGRAL216 224 {"difftime", os_difftime}, 217 #endif218 225 {"execute", os_execute}, 219 226 {"exit", os_exit}, trunk/lib/lua51/lparser.c
r270 r531 1 1 /* 2 ** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp $2 ** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $ 3 3 ** Lua Parser 4 4 ** See Copyright Notice in lua.h … … 490 490 static void listfield (LexState *ls, struct ConsControl *cc) { 491 491 expr(ls, &cc->v); 492 luaY_checklimit(ls->fs, cc->na, MAX ARG_Bx, "items in a constructor");492 luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); 493 493 cc->na++; 494 494 cc->tostore++; trunk/lib/lua51/lstrlib.c
r270 r531 1 1 /* 2 ** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $2 ** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ 3 3 ** Standard library for string operations and pattern-matching 4 4 ** See Copyright Notice in lua.h … … 724 724 static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { 725 725 const char *p = strfrmt; 726 while ( strchr(FLAGS, *p)) p++; /* skip flags */726 while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ 727 727 if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) 728 728 luaL_error(L, "invalid format (repeated flags)"); … … 785 785 break; 786 786 } 787 #if !defined LUA_NUMBER_INTEGRAL788 787 case 'e': case 'E': case 'f': 789 788 case 'g': case 'G': { … … 791 790 break; 792 791 } 793 #endif794 792 case 'q': { 795 793 addquoted(L, &b, arg); trunk/lib/lua51/lua.h
r270 r531 1 1 /* 2 ** $Id: lua.h,v 1.218 2006/06/02 15:34:00 roberto Exp $2 ** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $ 3 3 ** Lua - An Extensible Extension Language 4 4 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) … … 18 18 19 19 #define LUA_VERSION "Lua 5.1" 20 #define LUA_RELEASE "Lua 5.1. 1"20 #define LUA_RELEASE "Lua 5.1.2" 21 21 #define LUA_VERSION_NUM 501 22 #define LUA_COPYRIGHT "Copyright (C) 1994-200 6Lua.org, PUC-Rio"22 #define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" 23 23 #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" 24 24 … … 360 360 361 361 /****************************************************************************** 362 * Copyright (C) 1994-200 6Lua.org, PUC-Rio. All rights reserved.362 * Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. 363 363 * 364 364 * Permission is hereby granted, free of charge, to any person obtaining trunk/lib/lua51/luaconf.h
r327 r531 1 1 /* 2 ** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $2 ** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $ 3 3 ** Configuration file for Lua 4 4 ** See Copyright Notice in lua.h … … 141 141 ** machines, ptrdiff_t gives a good choice between int or long.) 142 142 */ 143 144 /* Changed to long for use with integral Lua numbers. */ 145 #define LUA_INTEGER long 143 #define LUA_INTEGER ptrdiff_t 144 146 145 147 146 /* … … 362 361 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' 363 362 @* behavior. 364 ** CHANGE it to undefined as soon as you replace to 'luaL_regist ry'363 ** CHANGE it to undefined as soon as you replace to 'luaL_register' 365 364 ** your uses of 'luaL_openlib' 366 365 */ … … 502 501 */ 503 502 504 /* Define LUA_NUMBER_INTEGRAL to produce a system that uses no505 floating point operations by changing the type of Lua numbers from506 double to long. It implements division and modulus so that507 508 x == (x / y) * y + x % y.509 510 The exponentiation function returns zero for negative exponents.511 Defining LUA_NUMBER_INTEGRAL also removes the difftime function,512 and the math module should not be used. The string.format function513 no longer handles the floating point directives %e, %E, %f, %g, and514 %G. */515 516 #define LUA_NUMBER_INTEGRAL517 #if defined LUA_NUMBER_INTEGRAL518 #define LUA_NUMBER long519 #else520 503 #define LUA_NUMBER_DOUBLE 521 504 #define LUA_NUMBER double 522 #endif523 505 524 506 /* … … 526 508 @* over a number. 527 509 */ 528 #define LUAI_UACNUMBER LUA_NUMBER510 #define LUAI_UACNUMBER double 529 511 530 512 … … 536 518 @@ lua_str2number converts a string to a number. 537 519 */ 538 #if defined LUA_NUMBER_INTEGRAL539 #define LUA_NUMBER_SCAN "%ld"540 #define LUA_NUMBER_FMT "%ld"541 #else542 520 #define LUA_NUMBER_SCAN "%lf" 543 521 #define LUA_NUMBER_FMT "%.14g" 544 #endif545 522 #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 546 523 #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ 547 #if defined LUA_NUMBER_INTEGRAL548 #define lua_str2number(s,p) strtol((s), (p), 10)549 #else550 524 #define lua_str2number(s,p) strtod((s), (p)) 551 #endif552 525 553 526 … … 560 533 #define luai_numsub(a,b) ((a)-(b)) 561 534 #define luai_nummul(a,b) ((a)*(b)) 562 #if defined LUA_NUMBER_INTEGRAL563 #define luai_numdiv(a,b) \564 (-1/2? \565 (a)/(b): \566 ((a)<0==(b)<0||(a)%(b)==0? \567 (a)/(b): \568 (a)/(b)-1))569 #define luai_nummod(a,b) \570 (-1/2? \571 (a)%(b): \572 ((a)<0==(b)<0||(a)%(b)==0? \573 (a)%(b): \574 (a)%(b)+(b)))575 #define luai_lnumdiv(a,b) \576 ((b)==0? \577 (luaG_runerror(L,"divide by zero"),0): \578 luai_numdiv(a,b))579 #define luai_lnummod(a,b) \580 ((b)==0? \581 (luaG_runerror(L,"modulo by zero"),0): \582 luai_nummod(a,b))583 LUA_NUMBER luai_ipow(LUA_NUMBER, LUA_NUMBER);584 #define luai_numpow(a,b) (luai_ipow(a,b))585 #else586 535 #define luai_numdiv(a,b) ((a)/(b)) 587 536 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) 588 #define luai_lnumdiv(a,b) (luai_numdiv(a,b))589 #define luai_lnummod(a,b) (luai_nummod(a,b))590 537 #define luai_numpow(a,b) (pow(a,b)) 591 #endif592 538 #define luai_numunm(a) (-(a)) 593 539 #define luai_numeq(a,b) ((a)==(b)) trunk/lib/lua51/lvm.c
r270 r531 1 1 /* 2 ** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 roberto Exp $2 ** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $ 3 3 ** Lua virtual machine 4 4 ** See Copyright Notice in lua.h … … 28 28 29 29 30 #if defined LUA_NUMBER_INTEGRAL31 LUA_NUMBER luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {32 if (b < 0)33 return 0;34 else if (b == 0)35 return 1;36 else {37 LUA_NUMBER c = 1;38 for (;;) {39 if (b & 1)40 c *= a;41 b = b >> 1;42 if (b == 0)43 return c;44 a *= a;45 }46 }47 }48 #endif49 30 50 31 /* limit for table tag-method chains (to avoid loops) */ … … 185 166 if (ttisnil(tm)) 186 167 tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ 187 if ( !ttisfunction(tm)) return 0;168 if (ttisnil(tm)) return 0; 188 169 callTMres(L, res, tm, p1, p2); 189 170 return 1; … … 301 282 StkId top = L->base + last + 1; 302 283 int n = 2; /* number of elements handled in this pass (at least 2) */ 303 if (! tostring(L, top-2) || !tostring(L, top-1)) {284 if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { 304 285 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) 305 286 luaG_concaterror(L, top-2, top-1); 306 } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ 287 } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ 288 (void)tostring(L, top - 2); /* result is first op (as string) */ 289 else { 307 290 /* at least two string values; get as many as possible */ 308 291 size_t tl = tsvalue(top-1)->len; … … 341 324 case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; 342 325 case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; 343 case TM_DIV: setnvalue(ra, luai_ lnumdiv(nb, nc)); break;344 case TM_MOD: setnvalue(ra, luai_ lnummod(nb, nc)); break;326 case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; 327 case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; 345 328 case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; 346 329 case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; … … 500 483 } 501 484 case OP_DIV: { 502 arith_op(luai_ lnumdiv, TM_DIV);485 arith_op(luai_numdiv, TM_DIV); 503 486 continue; 504 487 } 505 488 case OP_MOD: { 506 arith_op(luai_ lnummod, TM_MOD);489 arith_op(luai_nummod, TM_MOD); 507 490 continue; 508 491 } trunk/lib/lua51/print.c
r270 r531 1 1 /* 2 ** $Id: print.c,v 1.55 2006/05/31 13:30:05 lhf Exp $2 ** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ 3 3 ** print bytecodes 4 4 ** See Copyright Notice in lua.h … … 24 24 { 25 25 const char* s=getstr(ts); 26 int n=ts->tsv.len; 27 int i; 26 size_t i,n=ts->tsv.len; 28 27 putchar('"'); 29 28 for (i=0; i<n; i++) … … 33 32 { 34 33 case '"': printf("\\\""); break; 34 case '\\': printf("\\\\"); break; 35 35 case '\a': printf("\\a"); break; 36 36 case '\b': printf("\\b"); break;
