diff options
author | Karl Williamson <khw@cpan.org> | 2017-04-24 20:27:24 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-06 12:50:06 -0700 |
commit | de62715824b6848c0aabf63dab4e7bcdc9945f9f (patch) | |
tree | 31c0022d32bb88c5d89ed9c39560d6525cf0ce52 /toke.c | |
parent | 8a0832a10f1561764283c17de01fc2ebf3097e09 (diff) | |
download | perl-de62715824b6848c0aabf63dab4e7bcdc9945f9f.tar.gz |
Add memBEGINPs() to core and use it
This macro is like memBEGINs(), but the 'P' signifies we want a proper
substring, meaning that the 2nd string parameter must not be the entire
first parameter.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -2103,8 +2103,10 @@ S_force_word(pTHX_ char *start, int token, int check_keyword, int allow_pack) if (check_keyword) { char *s2 = PL_tokenbuf; STRLEN len2 = len; - if (allow_pack && len > 6 && strBEGINs(s2, "CORE::")) - s2 += 6, len2 -= 6; + if (allow_pack && memBEGINPs(s2, len, "CORE::")) { + s2 += sizeof("CORE::") - 1; + len2 -= sizeof("CORE::") - 1; + } if (keyword(s2, len2, 0)) return start; } @@ -5369,7 +5371,9 @@ Perl_yylex(pTHX) } if (PL_parser->in_pod) { /* Incest with pod. */ - if (*s == '=' && strBEGINs(s, "=cut") && !isALPHA(s[4])) { + if ( memBEGINPs(s, (STRLEN) (PL_bufend - s), "=cut") + && !isALPHA(s[4])) + { SvPVCLEAR(PL_linestr); PL_oldoldbufptr = PL_oldbufptr = s = PL_linestart = SvPVX(PL_linestr); PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr); @@ -7950,14 +7954,17 @@ Perl_yylex(pTHX) char *p = s; SSize_t s_off = s - SvPVX(PL_linestr); - if ((PL_bufend - p) >= 3 - && strBEGINs(p, "my") && isSPACE(*(p + 2))) + if ( memBEGINPs(p, (STRLEN) (PL_bufend - p), "my") + && isSPACE(*(p + 2))) { - p += 2; + p += 2; } - else if ((PL_bufend - p) >= 4 - && strBEGINs(p, "our") && isSPACE(*(p + 3))) - p += 3; + else if ( memBEGINPs(p, (STRLEN) (PL_bufend - p), "our") + && isSPACE(*(p + 3))) + { + p += 3; + } + p = skipspace(p); /* skip optional package name, as in "for my abc $x (..)" */ if (isIDFIRST_lazy_if_safe(p, PL_bufend, UTF)) { |