From: Gurusamy Sarathy Date: Tue, 15 Feb 2000 18:25:05 +0000 (+0000) Subject: avoid accidental #line directives (from Rick Delaney X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=73659bf1a819ac7d9f9fcae022ed8755e46824eb;p=p5sagit%2Fp5-mst-13.2.git avoid accidental #line directives (from Rick Delaney ) p4raw-id: //depot/perl@5108 --- diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index f07bdfe..7b9590e 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -593,7 +593,7 @@ this, one can control Perl's idea of filenames and line numbers in error or warning messages (especially for strings that are processed with C). The syntax for this mechanism is the same as for most C preprocessors: it matches the regular expression -C with C<$1> being the line +C with C<$1> being the line number for the next line, and C<$2> being the optional filename (specified within quotes). diff --git a/toke.c b/toke.c index da4314d..b6ffc2b 100644 --- a/toke.c +++ b/toke.c @@ -464,17 +464,22 @@ S_incline(pTHX_ char *s) dTHR; char *t; char *n; + char *e; char ch; - int sawline = 0; CopLINE_inc(PL_curcop); if (*s++ != '#') return; while (*s == ' ' || *s == '\t') s++; - if (strnEQ(s, "line ", 5)) { - s += 5; - sawline = 1; - } + if (strnEQ(s, "line", 4)) + s += 4; + else + return; + if (*s == ' ' || *s == '\t') + s++; + else + return; + while (*s == ' ' || *s == '\t') s++; if (!isDIGIT(*s)) return; n = s; @@ -482,13 +487,19 @@ S_incline(pTHX_ char *s) s++; while (*s == ' ' || *s == '\t') s++; - if (*s == '"' && (t = strchr(s+1, '"'))) + if (*s == '"' && (t = strchr(s+1, '"'))) { s++; + e = t + 1; + } else { - if (!sawline) - return; /* false alarm */ for (t = s; !isSPACE(*t); t++) ; + e = t; } + while (*e == ' ' || *e == '\t' || *e == '\r' || *e == '\f') + e++; + if (*e != '\n' && *e != '\0') + return; /* false alarm */ + ch = *t; *t = '\0'; if (t - s > 0)