This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Stop using len to indicate trailing ::
authorFather Chrysostomos <sprout@cpan.org>
Wed, 3 Sep 2014 19:59:15 +0000 (12:59 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 4 Sep 2014 02:07:53 +0000 (19:07 -0700)
This variable stores the length of the word we are parsing.  But at
one point it starts being used as a boolean to indicate that we have a
bareword ending in two colons.  So if are looking up are bareword that
does not end in ::, we have to call strlen() to scan the string and
determine the length.

toke.c

diff --git a/toke.c b/toke.c
index e5e3ddf..6303103 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -6477,6 +6477,7 @@ Perl_yylex(pTHX)
                    lastchar && PL_bufptr - 2 >= PL_linestart
                         ? PL_bufptr[-2]
                         : 0;
+               bool safebw;
 
 
                /* Get the rest if it looks like a package qualifier */
@@ -6520,6 +6521,7 @@ Perl_yylex(pTHX)
                    PL_tokenbuf[len] = '\0';
                    gv = NULL;
                    gvp = 0;
+                   safebw = TRUE;
                }
                else {
                    if (!lex && !gv) {
@@ -6531,14 +6533,14 @@ Perl_yylex(pTHX)
                                               GV_NOADD_NOINIT | ( UTF ? SVf_UTF8 : 0 ),
                                               SVt_PVCV);
                    }
-                   len = 0;
+                   safebw = FALSE;
                }
 
                /* if we saw a global override before, get the right name */
 
                if (!sv)
                  sv = S_newSV_maybe_utf8(aTHX_ PL_tokenbuf,
-                   len ? len : strlen(PL_tokenbuf));
+                                               len);
                if (gvp) {
                    SV * const tmp_sv = sv;
                    sv = newSVpvs("CORE::GLOBAL::");
@@ -6553,7 +6555,7 @@ Perl_yylex(pTHX)
                pl_yylval.opval->op_private = OPpCONST_BARE;
 
                /* And if "Foo::", then that's what it certainly is. */
-               if (len)
+               if (safebw)
                    goto safe_bareword;
 
                if (!off)