From: Gurusamy Sarathy Date: Tue, 17 Nov 1998 06:32:39 +0000 (+0000) Subject: fix skipspace() to properly account for newlines in eval''-ed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=60e6418e713a685accbfac231ad24b33f7569c3a;p=p5sagit%2Fp5-mst-13.2.git fix skipspace() to properly account for newlines in eval''-ed strings (caused bogus line numbers in diagnostics and debugger) p4raw-id: //depot/perl@2242 --- diff --git a/t/pragma/warn/pp_ctl b/t/pragma/warn/pp_ctl index e017d8a..4f17f1f 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 6cc4a50..da6c0dc 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 6755b8a..fb54cee 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;