diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-10 16:41:19 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-11-10 16:41:19 -0200 |
commit | d1d1ddec1e4ffb53e646dde684d4a1262b3d43de (patch) | |
tree | 9172a203f8c1752618586f01b6b60dbbd3345d33 | |
parent | bfa0898312e1a36087fa10fa8020a706a2e8e885 (diff) | |
download | lua-d1d1ddec1e4ffb53e646dde684d4a1262b3d43de.tar.gz lua-d1d1ddec1e4ffb53e646dde684d4a1262b3d43de.tar.bz2 lua-d1d1ddec1e4ffb53e646dde684d4a1262b3d43de.zip |
details
-rw-r--r-- | ldebug.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.104 2014/11/02 19:33:33 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.105 2014/11/10 14:46:46 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -483,17 +483,21 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { | |||
483 | 483 | ||
484 | 484 | ||
485 | /* | 485 | /* |
486 | ** only portable way to check whether a pointer points to an array | 486 | ** The subtraction of two potentially unrelated pointers is |
487 | ** (used only for error messages, so efficiency is not a big concern) | 487 | ** not ISO C, but it should not crash a program; the subsequent |
488 | ** checks are ISO C and ensure a correct result. | ||
488 | */ | 489 | */ |
489 | static int isinstack (CallInfo *ci, const TValue *o) { | 490 | static int isinstack (CallInfo *ci, const TValue *o) { |
490 | StkId p; | 491 | ptrdiff_t i = o - ci->u.l.base; |
491 | for (p = ci->u.l.base; p < ci->top; p++) | 492 | return (0 <= i && i < (ci->top - ci->u.l.base) && ci->u.l.base + i == o); |
492 | if (o == p) return 1; | ||
493 | return 0; | ||
494 | } | 493 | } |
495 | 494 | ||
496 | 495 | ||
496 | /* | ||
497 | ** Checks whether value 'o' came from an upvalue. (That can only happen | ||
498 | ** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on | ||
499 | ** upvalues.) | ||
500 | */ | ||
497 | static const char *getupvalname (CallInfo *ci, const TValue *o, | 501 | static const char *getupvalname (CallInfo *ci, const TValue *o, |
498 | const char **name) { | 502 | const char **name) { |
499 | LClosure *c = ci_func(ci); | 503 | LClosure *c = ci_func(ci); |