diff options
-rw-r--r-- | src/3rdParty/lua/ldebug.c | 153 | ||||
-rw-r--r-- | src/3rdParty/lua/lmathlib.c | 31 | ||||
-rw-r--r-- | src/3rdParty/lua/lparser.c | 12 | ||||
-rw-r--r-- | src/3rdParty/lua/lstring.c | 2 | ||||
-rw-r--r-- | src/3rdParty/lua/ltable.c | 36 | ||||
-rw-r--r-- | src/3rdParty/lua/lundump.c | 2 |
6 files changed, 141 insertions, 95 deletions
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c index 690ac38..b1f16ac 100644 --- a/src/3rdParty/lua/ldebug.c +++ b/src/3rdParty/lua/ldebug.c | |||
@@ -417,40 +417,6 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
417 | ** ======================================================= | 417 | ** ======================================================= |
418 | */ | 418 | */ |
419 | 419 | ||
420 | static const char *getobjname (const Proto *p, int lastpc, int reg, | ||
421 | const char **name); | ||
422 | |||
423 | |||
424 | /* | ||
425 | ** Find a "name" for the constant 'c'. | ||
426 | */ | ||
427 | static void kname (const Proto *p, int c, const char **name) { | ||
428 | TValue *kvalue = &p->k[c]; | ||
429 | *name = (ttisstring(kvalue)) ? getstr(tsvalue(kvalue)) : "?"; | ||
430 | } | ||
431 | |||
432 | |||
433 | /* | ||
434 | ** Find a "name" for the register 'c'. | ||
435 | */ | ||
436 | static void rname (const Proto *p, int pc, int c, const char **name) { | ||
437 | const char *what = getobjname(p, pc, c, name); /* search for 'c' */ | ||
438 | if (!(what && *what == 'c')) /* did not find a constant name? */ | ||
439 | *name = "?"; | ||
440 | } | ||
441 | |||
442 | |||
443 | /* | ||
444 | ** Find a "name" for a 'C' value in an RK instruction. | ||
445 | */ | ||
446 | static void rkname (const Proto *p, int pc, Instruction i, const char **name) { | ||
447 | int c = GETARG_C(i); /* key index */ | ||
448 | if (GETARG_k(i)) /* is 'c' a constant? */ | ||
449 | kname(p, c, name); | ||
450 | else /* 'c' is a register */ | ||
451 | rname(p, pc, c, name); | ||
452 | } | ||
453 | |||
454 | 420 | ||
455 | static int filterpc (int pc, int jmptarget) { | 421 | static int filterpc (int pc, int jmptarget) { |
456 | if (pc < jmptarget) /* is code conditional (inside a jump)? */ | 422 | if (pc < jmptarget) /* is code conditional (inside a jump)? */ |
@@ -509,28 +475,29 @@ static int findsetreg (const Proto *p, int lastpc, int reg) { | |||
509 | 475 | ||
510 | 476 | ||
511 | /* | 477 | /* |
512 | ** Check whether table being indexed by instruction 'i' is the | 478 | ** Find a "name" for the constant 'c'. |
513 | ** environment '_ENV' | ||
514 | */ | 479 | */ |
515 | static const char *gxf (const Proto *p, int pc, Instruction i, int isup) { | 480 | static const char *kname (const Proto *p, int index, const char **name) { |
516 | int t = GETARG_B(i); /* table index */ | 481 | TValue *kvalue = &p->k[index]; |
517 | const char *name; /* name of indexed variable */ | 482 | if (ttisstring(kvalue)) { |
518 | if (isup) /* is an upvalue? */ | 483 | *name = getstr(tsvalue(kvalue)); |
519 | name = upvalname(p, t); | 484 | return "constant"; |
520 | else | 485 | } |
521 | getobjname(p, pc, t, &name); | 486 | else { |
522 | return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field"; | 487 | *name = "?"; |
488 | return NULL; | ||
489 | } | ||
523 | } | 490 | } |
524 | 491 | ||
525 | 492 | ||
526 | static const char *getobjname (const Proto *p, int lastpc, int reg, | 493 | static const char *basicgetobjname (const Proto *p, int *ppc, int reg, |
527 | const char **name) { | 494 | const char **name) { |
528 | int pc; | 495 | int pc = *ppc; |
529 | *name = luaF_getlocalname(p, reg + 1, lastpc); | 496 | *name = luaF_getlocalname(p, reg + 1, pc); |
530 | if (*name) /* is a local? */ | 497 | if (*name) /* is a local? */ |
531 | return "local"; | 498 | return "local"; |
532 | /* else try symbolic execution */ | 499 | /* else try symbolic execution */ |
533 | pc = findsetreg(p, lastpc, reg); | 500 | *ppc = pc = findsetreg(p, pc, reg); |
534 | if (pc != -1) { /* could find instruction? */ | 501 | if (pc != -1) { /* could find instruction? */ |
535 | Instruction i = p->code[pc]; | 502 | Instruction i = p->code[pc]; |
536 | OpCode op = GET_OPCODE(i); | 503 | OpCode op = GET_OPCODE(i); |
@@ -538,18 +505,80 @@ static const char *getobjname (const Proto *p, int lastpc, int reg, | |||
538 | case OP_MOVE: { | 505 | case OP_MOVE: { |
539 | int b = GETARG_B(i); /* move from 'b' to 'a' */ | 506 | int b = GETARG_B(i); /* move from 'b' to 'a' */ |
540 | if (b < GETARG_A(i)) | 507 | if (b < GETARG_A(i)) |
541 | return getobjname(p, pc, b, name); /* get name for 'b' */ | 508 | return basicgetobjname(p, ppc, b, name); /* get name for 'b' */ |
542 | break; | 509 | break; |
543 | } | 510 | } |
511 | case OP_GETUPVAL: { | ||
512 | *name = upvalname(p, GETARG_B(i)); | ||
513 | return "upvalue"; | ||
514 | } | ||
515 | case OP_LOADK: return kname(p, GETARG_Bx(i), name); | ||
516 | case OP_LOADKX: return kname(p, GETARG_Ax(p->code[pc + 1]), name); | ||
517 | default: break; | ||
518 | } | ||
519 | } | ||
520 | return NULL; /* could not find reasonable name */ | ||
521 | } | ||
522 | |||
523 | |||
524 | /* | ||
525 | ** Find a "name" for the register 'c'. | ||
526 | */ | ||
527 | static void rname (const Proto *p, int pc, int c, const char **name) { | ||
528 | const char *what = basicgetobjname(p, &pc, c, name); /* search for 'c' */ | ||
529 | if (!(what && *what == 'c')) /* did not find a constant name? */ | ||
530 | *name = "?"; | ||
531 | } | ||
532 | |||
533 | |||
534 | /* | ||
535 | ** Find a "name" for a 'C' value in an RK instruction. | ||
536 | */ | ||
537 | static void rkname (const Proto *p, int pc, Instruction i, const char **name) { | ||
538 | int c = GETARG_C(i); /* key index */ | ||
539 | if (GETARG_k(i)) /* is 'c' a constant? */ | ||
540 | kname(p, c, name); | ||
541 | else /* 'c' is a register */ | ||
542 | rname(p, pc, c, name); | ||
543 | } | ||
544 | |||
545 | |||
546 | /* | ||
547 | ** Check whether table being indexed by instruction 'i' is the | ||
548 | ** environment '_ENV' | ||
549 | */ | ||
550 | static const char *isEnv (const Proto *p, int pc, Instruction i, int isup) { | ||
551 | int t = GETARG_B(i); /* table index */ | ||
552 | const char *name; /* name of indexed variable */ | ||
553 | if (isup) /* is 't' an upvalue? */ | ||
554 | name = upvalname(p, t); | ||
555 | else /* 't' is a register */ | ||
556 | basicgetobjname(p, &pc, t, &name); | ||
557 | return (name && strcmp(name, LUA_ENV) == 0) ? "global" : "field"; | ||
558 | } | ||
559 | |||
560 | |||
561 | /* | ||
562 | ** Extend 'basicgetobjname' to handle table accesses | ||
563 | */ | ||
564 | static const char *getobjname (const Proto *p, int lastpc, int reg, | ||
565 | const char **name) { | ||
566 | const char *kind = basicgetobjname(p, &lastpc, reg, name); | ||
567 | if (kind != NULL) | ||
568 | return kind; | ||
569 | else if (lastpc != -1) { /* could find instruction? */ | ||
570 | Instruction i = p->code[lastpc]; | ||
571 | OpCode op = GET_OPCODE(i); | ||
572 | switch (op) { | ||
544 | case OP_GETTABUP: { | 573 | case OP_GETTABUP: { |
545 | int k = GETARG_C(i); /* key index */ | 574 | int k = GETARG_C(i); /* key index */ |
546 | kname(p, k, name); | 575 | kname(p, k, name); |
547 | return gxf(p, pc, i, 1); | 576 | return isEnv(p, lastpc, i, 1); |
548 | } | 577 | } |
549 | case OP_GETTABLE: { | 578 | case OP_GETTABLE: { |
550 | int k = GETARG_C(i); /* key index */ | 579 | int k = GETARG_C(i); /* key index */ |
551 | rname(p, pc, k, name); | 580 | rname(p, lastpc, k, name); |
552 | return gxf(p, pc, i, 0); | 581 | return isEnv(p, lastpc, i, 0); |
553 | } | 582 | } |
554 | case OP_GETI: { | 583 | case OP_GETI: { |
555 | *name = "integer index"; | 584 | *name = "integer index"; |
@@ -558,24 +587,10 @@ static const char *getobjname (const Proto *p, int lastpc, int reg, | |||
558 | case OP_GETFIELD: { | 587 | case OP_GETFIELD: { |
559 | int k = GETARG_C(i); /* key index */ | 588 | int k = GETARG_C(i); /* key index */ |
560 | kname(p, k, name); | 589 | kname(p, k, name); |
561 | return gxf(p, pc, i, 0); | 590 | return isEnv(p, lastpc, i, 0); |
562 | } | ||
563 | case OP_GETUPVAL: { | ||
564 | *name = upvalname(p, GETARG_B(i)); | ||
565 | return "upvalue"; | ||
566 | } | ||
567 | case OP_LOADK: | ||
568 | case OP_LOADKX: { | ||
569 | int b = (op == OP_LOADK) ? GETARG_Bx(i) | ||
570 | : GETARG_Ax(p->code[pc + 1]); | ||
571 | if (ttisstring(&p->k[b])) { | ||
572 | *name = getstr(tsvalue(&p->k[b])); | ||
573 | return "constant"; | ||
574 | } | ||
575 | break; | ||
576 | } | 591 | } |
577 | case OP_SELF: { | 592 | case OP_SELF: { |
578 | rkname(p, pc, i, name); | 593 | rkname(p, lastpc, i, name); |
579 | return "method"; | 594 | return "method"; |
580 | } | 595 | } |
581 | default: break; /* go through to return NULL */ | 596 | default: break; /* go through to return NULL */ |
diff --git a/src/3rdParty/lua/lmathlib.c b/src/3rdParty/lua/lmathlib.c index d0b1e1e..f140d62 100644 --- a/src/3rdParty/lua/lmathlib.c +++ b/src/3rdParty/lua/lmathlib.c | |||
@@ -249,6 +249,15 @@ static int math_type (lua_State *L) { | |||
249 | ** =================================================================== | 249 | ** =================================================================== |
250 | */ | 250 | */ |
251 | 251 | ||
252 | /* | ||
253 | ** This code uses lots of shifts. ANSI C does not allow shifts greater | ||
254 | ** than or equal to the width of the type being shifted, so some shifts | ||
255 | ** are written in convoluted ways to match that restriction. For | ||
256 | ** preprocessor tests, it assumes a width of 32 bits, so the maximum | ||
257 | ** shift there is 31 bits. | ||
258 | */ | ||
259 | |||
260 | |||
252 | /* number of binary digits in the mantissa of a float */ | 261 | /* number of binary digits in the mantissa of a float */ |
253 | #define FIGS l_floatatt(MANT_DIG) | 262 | #define FIGS l_floatatt(MANT_DIG) |
254 | 263 | ||
@@ -271,16 +280,19 @@ static int math_type (lua_State *L) { | |||
271 | 280 | ||
272 | /* 'long' has at least 64 bits */ | 281 | /* 'long' has at least 64 bits */ |
273 | #define Rand64 unsigned long | 282 | #define Rand64 unsigned long |
283 | #define SRand64 long | ||
274 | 284 | ||
275 | #elif !defined(LUA_USE_C89) && defined(LLONG_MAX) | 285 | #elif !defined(LUA_USE_C89) && defined(LLONG_MAX) |
276 | 286 | ||
277 | /* there is a 'long long' type (which must have at least 64 bits) */ | 287 | /* there is a 'long long' type (which must have at least 64 bits) */ |
278 | #define Rand64 unsigned long long | 288 | #define Rand64 unsigned long long |
289 | #define SRand64 long long | ||
279 | 290 | ||
280 | #elif ((LUA_MAXUNSIGNED >> 31) >> 31) >= 3 | 291 | #elif ((LUA_MAXUNSIGNED >> 31) >> 31) >= 3 |
281 | 292 | ||
282 | /* 'lua_Unsigned' has at least 64 bits */ | 293 | /* 'lua_Unsigned' has at least 64 bits */ |
283 | #define Rand64 lua_Unsigned | 294 | #define Rand64 lua_Unsigned |
295 | #define SRand64 lua_Integer | ||
284 | 296 | ||
285 | #endif | 297 | #endif |
286 | 298 | ||
@@ -319,23 +331,30 @@ static Rand64 nextrand (Rand64 *state) { | |||
319 | } | 331 | } |
320 | 332 | ||
321 | 333 | ||
322 | /* must take care to not shift stuff by more than 63 slots */ | ||
323 | |||
324 | |||
325 | /* | 334 | /* |
326 | ** Convert bits from a random integer into a float in the | 335 | ** Convert bits from a random integer into a float in the |
327 | ** interval [0,1), getting the higher FIG bits from the | 336 | ** interval [0,1), getting the higher FIG bits from the |
328 | ** random unsigned integer and converting that to a float. | 337 | ** random unsigned integer and converting that to a float. |
338 | ** Some old Microsoft compilers cannot cast an unsigned long | ||
339 | ** to a floating-point number, so we use a signed long as an | ||
340 | ** intermediary. When lua_Number is float or double, the shift ensures | ||
341 | ** that 'sx' is non negative; in that case, a good compiler will remove | ||
342 | ** the correction. | ||
329 | */ | 343 | */ |
330 | 344 | ||
331 | /* must throw out the extra (64 - FIGS) bits */ | 345 | /* must throw out the extra (64 - FIGS) bits */ |
332 | #define shift64_FIG (64 - FIGS) | 346 | #define shift64_FIG (64 - FIGS) |
333 | 347 | ||
334 | /* to scale to [0, 1), multiply by scaleFIG = 2^(-FIGS) */ | 348 | /* 2^(-FIGS) == 2^-1 / 2^(FIGS-1) */ |
335 | #define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1))) | 349 | #define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1))) |
336 | 350 | ||
337 | static lua_Number I2d (Rand64 x) { | 351 | static lua_Number I2d (Rand64 x) { |
338 | return (lua_Number)(trim64(x) >> shift64_FIG) * scaleFIG; | 352 | SRand64 sx = (SRand64)(trim64(x) >> shift64_FIG); |
353 | lua_Number res = (lua_Number)(sx) * scaleFIG; | ||
354 | if (sx < 0) | ||
355 | res += 1.0; /* correct the two's complement if negative */ | ||
356 | lua_assert(0 <= res && res < 1); | ||
357 | return res; | ||
339 | } | 358 | } |
340 | 359 | ||
341 | /* convert a 'Rand64' to a 'lua_Unsigned' */ | 360 | /* convert a 'Rand64' to a 'lua_Unsigned' */ |
@@ -471,8 +490,6 @@ static lua_Number I2d (Rand64 x) { | |||
471 | 490 | ||
472 | #else /* 32 < FIGS <= 64 */ | 491 | #else /* 32 < FIGS <= 64 */ |
473 | 492 | ||
474 | /* must take care to not shift stuff by more than 31 slots */ | ||
475 | |||
476 | /* 2^(-FIGS) = 1.0 / 2^30 / 2^3 / 2^(FIGS-33) */ | 493 | /* 2^(-FIGS) = 1.0 / 2^30 / 2^3 / 2^(FIGS-33) */ |
477 | #define scaleFIG \ | 494 | #define scaleFIG \ |
478 | (l_mathop(1.0) / (UONE << 30) / l_mathop(8.0) / (UONE << (FIGS - 33))) | 495 | (l_mathop(1.0) / (UONE << 30) / l_mathop(8.0) / (UONE << (FIGS - 33))) |
diff --git a/src/3rdParty/lua/lparser.c b/src/3rdParty/lua/lparser.c index b745f23..2b888c7 100644 --- a/src/3rdParty/lua/lparser.c +++ b/src/3rdParty/lua/lparser.c | |||
@@ -1022,10 +1022,11 @@ static int explist (LexState *ls, expdesc *v) { | |||
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | 1024 | ||
1025 | static void funcargs (LexState *ls, expdesc *f, int line) { | 1025 | static void funcargs (LexState *ls, expdesc *f) { |
1026 | FuncState *fs = ls->fs; | 1026 | FuncState *fs = ls->fs; |
1027 | expdesc args; | 1027 | expdesc args; |
1028 | int base, nparams; | 1028 | int base, nparams; |
1029 | int line = ls->linenumber; | ||
1029 | switch (ls->t.token) { | 1030 | switch (ls->t.token) { |
1030 | case '(': { /* funcargs -> '(' [ explist ] ')' */ | 1031 | case '(': { /* funcargs -> '(' [ explist ] ')' */ |
1031 | luaX_next(ls); | 1032 | luaX_next(ls); |
@@ -1063,8 +1064,8 @@ static void funcargs (LexState *ls, expdesc *f, int line) { | |||
1063 | } | 1064 | } |
1064 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); | 1065 | init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); |
1065 | luaK_fixline(fs, line); | 1066 | luaK_fixline(fs, line); |
1066 | fs->freereg = base+1; /* call remove function and arguments and leaves | 1067 | fs->freereg = base+1; /* call removes function and arguments and leaves |
1067 | (unless changed) one result */ | 1068 | one result (unless changed later) */ |
1068 | } | 1069 | } |
1069 | 1070 | ||
1070 | 1071 | ||
@@ -1103,7 +1104,6 @@ static void suffixedexp (LexState *ls, expdesc *v) { | |||
1103 | /* suffixedexp -> | 1104 | /* suffixedexp -> |
1104 | primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ | 1105 | primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ |
1105 | FuncState *fs = ls->fs; | 1106 | FuncState *fs = ls->fs; |
1106 | int line = ls->linenumber; | ||
1107 | primaryexp(ls, v); | 1107 | primaryexp(ls, v); |
1108 | for (;;) { | 1108 | for (;;) { |
1109 | switch (ls->t.token) { | 1109 | switch (ls->t.token) { |
@@ -1123,12 +1123,12 @@ static void suffixedexp (LexState *ls, expdesc *v) { | |||
1123 | luaX_next(ls); | 1123 | luaX_next(ls); |
1124 | codename(ls, &key); | 1124 | codename(ls, &key); |
1125 | luaK_self(fs, v, &key); | 1125 | luaK_self(fs, v, &key); |
1126 | funcargs(ls, v, line); | 1126 | funcargs(ls, v); |
1127 | break; | 1127 | break; |
1128 | } | 1128 | } |
1129 | case '(': case TK_STRING: case '{': { /* funcargs */ | 1129 | case '(': case TK_STRING: case '{': { /* funcargs */ |
1130 | luaK_exp2nextreg(fs, v); | 1130 | luaK_exp2nextreg(fs, v); |
1131 | funcargs(ls, v, line); | 1131 | funcargs(ls, v); |
1132 | break; | 1132 | break; |
1133 | } | 1133 | } |
1134 | default: return; | 1134 | default: return; |
diff --git a/src/3rdParty/lua/lstring.c b/src/3rdParty/lua/lstring.c index 1032ad8..e921dd0 100644 --- a/src/3rdParty/lua/lstring.c +++ b/src/3rdParty/lua/lstring.c | |||
@@ -207,8 +207,8 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) { | |||
207 | list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */ | 207 | list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */ |
208 | } | 208 | } |
209 | ts = createstrobj(L, l, LUA_VSHRSTR, h); | 209 | ts = createstrobj(L, l, LUA_VSHRSTR, h); |
210 | memcpy(getshrstr(ts), str, l * sizeof(char)); | ||
211 | ts->shrlen = cast_byte(l); | 210 | ts->shrlen = cast_byte(l); |
211 | memcpy(getshrstr(ts), str, l * sizeof(char)); | ||
212 | ts->u.hnext = *list; | 212 | ts->u.hnext = *list; |
213 | *list = ts; | 213 | *list = ts; |
214 | tb->nuse++; | 214 | tb->nuse++; |
diff --git a/src/3rdParty/lua/ltable.c b/src/3rdParty/lua/ltable.c index 3fb575a..3353c04 100644 --- a/src/3rdParty/lua/ltable.c +++ b/src/3rdParty/lua/ltable.c | |||
@@ -252,7 +252,7 @@ LUAI_FUNC unsigned int luaH_realasize (const Table *t) { | |||
252 | return t->alimit; /* this is the size */ | 252 | return t->alimit; /* this is the size */ |
253 | else { | 253 | else { |
254 | unsigned int size = t->alimit; | 254 | unsigned int size = t->alimit; |
255 | /* compute the smallest power of 2 not smaller than 'n' */ | 255 | /* compute the smallest power of 2 not smaller than 'size' */ |
256 | size |= (size >> 1); | 256 | size |= (size >> 1); |
257 | size |= (size >> 2); | 257 | size |= (size >> 2); |
258 | size |= (size >> 4); | 258 | size |= (size >> 4); |
@@ -722,22 +722,36 @@ static void luaH_newkey (lua_State *L, Table *t, const TValue *key, | |||
722 | 722 | ||
723 | /* | 723 | /* |
724 | ** Search function for integers. If integer is inside 'alimit', get it | 724 | ** Search function for integers. If integer is inside 'alimit', get it |
725 | ** directly from the array part. Otherwise, if 'alimit' is not equal to | 725 | ** directly from the array part. Otherwise, if 'alimit' is not |
726 | ** the real size of the array, key still can be in the array part. In | 726 | ** the real size of the array, the key still can be in the array part. |
727 | ** this case, try to avoid a call to 'luaH_realasize' when key is just | 727 | ** In this case, do the "Xmilia trick" to check whether 'key-1' is |
728 | ** one more than the limit (so that it can be incremented without | 728 | ** smaller than the real size. |
729 | ** changing the real size of the array). | 729 | ** The trick works as follow: let 'p' be an integer such that |
730 | ** '2^(p+1) >= alimit > 2^p', or '2^(p+1) > alimit-1 >= 2^p'. | ||
731 | ** That is, 2^(p+1) is the real size of the array, and 'p' is the highest | ||
732 | ** bit on in 'alimit-1'. What we have to check becomes 'key-1 < 2^(p+1)'. | ||
733 | ** We compute '(key-1) & ~(alimit-1)', which we call 'res'; it will | ||
734 | ** have the 'p' bit cleared. If the key is outside the array, that is, | ||
735 | ** 'key-1 >= 2^(p+1)', then 'res' will have some bit on higher than 'p', | ||
736 | ** therefore it will be larger or equal to 'alimit', and the check | ||
737 | ** will fail. If 'key-1 < 2^(p+1)', then 'res' has no bit on higher than | ||
738 | ** 'p', and as the bit 'p' itself was cleared, 'res' will be smaller | ||
739 | ** than 2^p, therefore smaller than 'alimit', and the check succeeds. | ||
740 | ** As special cases, when 'alimit' is 0 the condition is trivially false, | ||
741 | ** and when 'alimit' is 1 the condition simplifies to 'key-1 < alimit'. | ||
742 | ** If key is 0 or negative, 'res' will have its higher bit on, so that | ||
743 | ** if cannot be smaller than alimit. | ||
730 | */ | 744 | */ |
731 | const TValue *luaH_getint (Table *t, lua_Integer key) { | 745 | const TValue *luaH_getint (Table *t, lua_Integer key) { |
732 | if (l_castS2U(key) - 1u < t->alimit) /* 'key' in [1, t->alimit]? */ | 746 | lua_Unsigned alimit = t->alimit; |
747 | if (l_castS2U(key) - 1u < alimit) /* 'key' in [1, t->alimit]? */ | ||
733 | return &t->array[key - 1]; | 748 | return &t->array[key - 1]; |
734 | else if (!limitequalsasize(t) && /* key still may be in the array part? */ | 749 | else if (!isrealasize(t) && /* key still may be in the array part? */ |
735 | (l_castS2U(key) == t->alimit + 1 || | 750 | (((l_castS2U(key) - 1u) & ~(alimit - 1u)) < alimit)) { |
736 | l_castS2U(key) - 1u < luaH_realasize(t))) { | ||
737 | t->alimit = cast_uint(key); /* probably '#t' is here now */ | 751 | t->alimit = cast_uint(key); /* probably '#t' is here now */ |
738 | return &t->array[key - 1]; | 752 | return &t->array[key - 1]; |
739 | } | 753 | } |
740 | else { | 754 | else { /* key is not in the array part; check the hash */ |
741 | Node *n = hashint(t, key); | 755 | Node *n = hashint(t, key); |
742 | for (;;) { /* check whether 'key' is somewhere in the chain */ | 756 | for (;;) { /* check whether 'key' is somewhere in the chain */ |
743 | if (keyisinteger(n) && keyival(n) == key) | 757 | if (keyisinteger(n) && keyival(n) == key) |
diff --git a/src/3rdParty/lua/lundump.c b/src/3rdParty/lua/lundump.c index f1852c3..e8d92a8 100644 --- a/src/3rdParty/lua/lundump.c +++ b/src/3rdParty/lua/lundump.c | |||
@@ -81,7 +81,7 @@ static size_t loadUnsigned (LoadState *S, size_t limit) { | |||
81 | 81 | ||
82 | 82 | ||
83 | static size_t loadSize (LoadState *S) { | 83 | static size_t loadSize (LoadState *S) { |
84 | return loadUnsigned(S, ~(size_t)0); | 84 | return loadUnsigned(S, MAX_SIZET); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||