From 19a6c3874551719f0fab72465339e6d46148396f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 26 Nov 2009 13:34:15 -0200 Subject: [PATCH] detail in 'currentpc' (only needs to work for Lua functions) --- ldebug.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ldebug.c b/ldebug.c index 209986c5..b9010bea 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.57 2009/10/13 19:07:40 roberto Exp roberto $ +** $Id: ldebug.c,v 2.58 2009/11/25 15:27:51 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -34,17 +34,13 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); static int currentpc (CallInfo *ci) { - if (!isLua(ci)) return -1; /* function is not a Lua function? */ + lua_assert(isLua(ci)); return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); } static int currentline (CallInfo *ci) { - int pc = currentpc(ci); - if (pc < 0) - return -1; /* only active lua functions have current-line information */ - else - return getfuncline(ci_func(ci)->l.p, pc); + return getfuncline(ci_func(ci)->l.p, currentpc(ci)); } @@ -187,7 +183,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, break; } case 'l': { - ar->currentline = (ci) ? currentline(ci) : -1; + ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; break; } case 'u': {