diff options
author | Karl Williamson <khw@cpan.org> | 2021-01-13 19:51:18 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-01-20 06:51:49 -0700 |
commit | b94d36b981ff593e5ccd66531069f12e0482b4f6 (patch) | |
tree | 64fe4c7510a2ad33b700b3f621c125c5aaf3f928 /toke.c | |
parent | 20420ba9e016c0a7de5df27b5ab1fefd7902a766 (diff) | |
download | perl-b94d36b981ff593e5ccd66531069f12e0482b4f6.tar.gz |
toke.c: Slight simplification
Rather than know how far we have advanced in parsing when we have to
back up, save the checkpoint position and simply backtrack to it. This
results in slightly more maintainable code that a future commit will
take advantage of.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -3587,6 +3587,7 @@ S_scan_const(pTHX_ char *start) /* backslashes */ if (*s == '\\' && s+1 < send) { + char* bslash = s; /* point to beginning \ */ char* e; /* Can be used for ending '}', etc. */ s++; @@ -3601,13 +3602,14 @@ S_scan_const(pTHX_ char *start) { /* diag_listed_as: \%d better written as $%d */ Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX), "\\%c better written as $%c", *s, *s); - *--s = '$'; + s = bslash; + *s = '$'; break; } /* string-change backslash escapes */ if (PL_lex_inwhat != OP_TRANS && *s && memCHRs("lLuUEQF", *s)) { - --s; + s = bslash; break; } /* In a pattern, process \N, but skip any other backslash escapes. @@ -3835,8 +3837,6 @@ S_scan_const(pTHX_ char *start) /* In patterns, we can have \N{U+xxxx.yyyy.zzzz...} */ /* Check the syntax. */ - const char *orig_s; - orig_s = s - 5; if (!isXDIGIT(*s)) { bad_NU: yyerror( @@ -3857,8 +3857,8 @@ S_scan_const(pTHX_ char *start) /* Pass everything through unchanged. * +1 is for the '}' */ - Copy(orig_s, d, e - orig_s + 1, char); - d += e - orig_s + 1; + Copy(bslash, d, e - bslash + 1, char); + d += e - bslash + 1; } else { /* Not a pattern: convert the hex to string */ I32 flags = PERL_SCAN_ALLOW_UNDERSCORES |