summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-31 17:47:23 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-09-01 11:32:07 -0700
commit25502127feba592f2312380b350122c445020707 (patch)
tree114d7f6ac5b79b5922af4dded2493bc732952083 /pp_ctl.c
parentecadf9b7005812a5eb20b351ef9bcd042c7e3daf (diff)
downloadperl-25502127feba592f2312380b350122c445020707.tar.gz
[perl #115768] improve (caller)[2] line numbers
warn and die have special code (closest_cop) to find a nulled nextstate op closest to the warn or die op, to get the line number from it. This commit extends that capability to caller, so that if (1) { foo(); } sub foo { warn +(caller)[2] } shows the right line number.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index b9ef68f1e9..4ce8ddb57b 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1811,6 +1811,7 @@ PP(pp_caller)
const HEK *stash_hek;
I32 count = 0;
bool has_arg = MAXARG && TOPs;
+ const COP *lcop;
if (MAXARG) {
if (has_arg)
@@ -1854,7 +1855,11 @@ PP(pp_caller)
PUSHTARG;
}
mPUSHs(newSVpv(OutCopFILE(cx->blk_oldcop), 0));
- mPUSHi((I32)CopLINE(cx->blk_oldcop));
+ lcop = closest_cop(cx->blk_oldcop, cx->blk_oldcop->op_sibling,
+ cx->blk_sub.retop, TRUE);
+ if (!lcop)
+ lcop = cx->blk_oldcop;
+ mPUSHi((I32)CopLINE(lcop));
if (!has_arg)
RETURN;
if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) {