This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c:scan_heredoc: Use PL_tokenbuf less
authorFather Chrysostomos <sprout@cpan.org>
Tue, 21 Aug 2012 08:45:15 +0000 (01:45 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 21 Aug 2012 21:11:03 +0000 (14:11 -0700)
When scanning for a heredoc terminator in a string eval or quote-like
operator, the first character we are looking for is always a newline.
So instead of setting term to *PL_tokenbuf in those two code paths,
we can just hard-code '\n'.

toke.c

diff --git a/toke.c b/toke.c
index 4f58a26..86b8c7f 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -9656,10 +9656,9 @@ S_scan_heredoc(pTHX_ register char *s)
                break;
            }
        }
-       term = *PL_tokenbuf;
        d = s;
        while (s < bufend &&
-         (*s != term || memNE(s,PL_tokenbuf,len)) ) {
+         (*s != '\n' || memNE(s,PL_tokenbuf,len)) ) {
            if (*s++ == '\n')
                CopLINE_inc(PL_curcop);
        }
@@ -9680,10 +9679,9 @@ S_scan_heredoc(pTHX_ register char *s)
        goto retval;
     }
     else if (!infile || found_newline) {
-       term = *PL_tokenbuf;
        d = s;
        while (s < PL_bufend &&
-         (*s != term || memNE(s,PL_tokenbuf,len)) ) {
+         (*s != '\n' || memNE(s,PL_tokenbuf,len)) ) {
            if (*s++ == '\n')
                CopLINE_inc(PL_curcop);
        }