summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-17 06:32:39 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-17 06:32:39 +0000
commit60e6418e713a685accbfac231ad24b33f7569c3a (patch)
tree20623cdf73bd1bb5fc60ae3ada0b7543696df3cd
parent6f06b55ffd47b279dd1684acb9b556a45e4754a3 (diff)
downloadperl-60e6418e713a685accbfac231ad24b33f7569c3a.tar.gz
fix skipspace() to properly account for newlines in eval''-ed
strings (caused bogus line numbers in diagnostics and debugger) p4raw-id: //depot/perl@2242
-rw-r--r--t/pragma/warn/pp_ctl6
-rw-r--r--t/pragma/warn/toke12
-rw-r--r--toke.c13
3 files changed, 22 insertions, 9 deletions
diff --git a/t/pragma/warn/pp_ctl b/t/pragma/warn/pp_ctl
index e017d8a0a8..4f17f1f892 100644
--- a/t/pragma/warn/pp_ctl
+++ b/t/pragma/warn/pp_ctl
@@ -86,7 +86,7 @@ Exiting subroutine via last at - line 3.
########
# pp_ctl.c
use warning 'unsafe' ;
-{ eval "last" }
+{ eval "last;" }
print STDERR $@ ;
EXPECT
Exiting eval via last at (eval 1) line 1.
@@ -119,10 +119,10 @@ Exiting subroutine via last at - line 3.
########
# pp_ctl.c
use warning 'unsafe' ;
-joe: { eval "last joe" }
+joe: { eval "last joe;" }
print STDERR $@ ;
EXPECT
-Exiting eval via last at (eval 1) line 2.
+Exiting eval via last at (eval 1) line 1.
########
# pp_ctl.c
use warning 'unsafe' ;
diff --git a/t/pragma/warn/toke b/t/pragma/warn/toke
index 6cc4a500a4..da6c0dc9ae 100644
--- a/t/pragma/warn/toke
+++ b/t/pragma/warn/toke
@@ -290,9 +290,10 @@ Misplaced _ in number at - line 4.
########
# toke.c
use warning 'unsafe' ;
+#line 25 "bar"
$a = FRED:: ;
EXPECT
-Bareword "FRED::" refers to nonexistent package at - line 3.
+Bareword "FRED::" refers to nonexistent package at bar line 25.
########
# toke.c
use warning 'ambiguous' ;
@@ -303,9 +304,14 @@ Ambiguous call resolved as CORE::time(), qualify as such or use & at - line 4.
########
# toke.c
use warning 'utf8' ;
-$_ = " \x{123} " ;
+eval <<'EOE';
+{
+#line 30 "foo"
+ $_ = " \x{123} " ;
+}
+EOE
EXPECT
-Use of \x{} without utf8 declaration at - line 3.
+Use of \x{} without utf8 declaration at foo line 30.
########
# toke.c
use warning 'utf8' ;
diff --git a/toke.c b/toke.c
index 6755b8aaef..fb54cee87c 100644
--- a/toke.c
+++ b/toke.c
@@ -445,13 +445,20 @@ skipspace(register char *s)
}
for (;;) {
STRLEN prevlen;
- while (s < PL_bufend && isSPACE(*s))
- s++;
+ while (s < PL_bufend && isSPACE(*s)) {
+ if (*s++ == '\n' && PL_in_eval && !PL_rsfp)
+ incline(s);
+ }
if (s < PL_bufend && *s == '#') {
while (s < PL_bufend && *s != '\n')
s++;
- if (s < PL_bufend)
+ if (s < PL_bufend) {
s++;
+ if (PL_in_eval && !PL_rsfp) {
+ incline(s);
+ continue;
+ }
+ }
}
if (s < PL_bufend || !PL_rsfp || PL_lex_state != LEX_NORMAL)
return s;