diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-15 18:25:05 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-02-15 18:25:05 +0000 |
commit | 73659bf1a819ac7d9f9fcae022ed8755e46824eb (patch) | |
tree | 19c2161a32d232f397694d968b60dc293a96fbae /toke.c | |
parent | b9582b6a1927c5927eaaf0fdf154d2cefbf4c002 (diff) | |
download | perl-73659bf1a819ac7d9f9fcae022ed8755e46824eb.tar.gz |
avoid accidental #line directives (from Rick Delaney
<rick@consumercontact.com>)
p4raw-id: //depot/perl@5108
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -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) |