diff options
author | Karl Williamson <khw@cpan.org> | 2020-01-16 13:17:32 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-01-23 15:46:56 -0700 |
commit | 8d1e72f0f234299a86ddd5ce728d7cff6b44a547 (patch) | |
tree | 477d458f1df8f1dd50551ced45ac7de81fd7368b /toke.c | |
parent | 73351a7160e044aa54e64f7da1c78c3401a64c7b (diff) | |
download | perl-8d1e72f0f234299a86ddd5ce728d7cff6b44a547.tar.gz |
Restructure grok_bslash_[ox]
This commit causes these functions to allow a caller to request any
messages generated to be returned to the caller, instead of always being
handled within these functions. The messages are somewhat changed from
previously to be clearer. I did not find any code in CPAN that relied
on the previous message text.
Like the previous commit for grok_bslash_c, here are two reasons to do
this, repeated here.
1) In pattern compilation this brings these messages into conformity
with the other ones that get generated in pattern compilation, where
there is a particular syntax, including marking the exact position in
the parse where the problem occurred.
2) These could generate truncated messages due to the (mostly)
single-pass nature of pattern compilation that is now in effect. It
keeps track of where during a parse a message has been output, and
won't output it again if a second parsing pass turns out to be
necessary. Prior to this commit, it had to assume that a message
from one of these functions did get output, and this caused some
out-of-bounds reads when a subparse (using a constructed pattern) was
executed. The possibility of those went away in commit 5d894ca5213,
which guarantees it won't try to read outside bounds, but that may
still mean it is outputting text from the wrong parse, giving
meaningless results. This commit should stop that possibility.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -3552,12 +3552,13 @@ S_scan_const(pTHX_ char *start) { const char* error; - bool valid = grok_bslash_o(&s, send, + if (! grok_bslash_o(&s, send, &uv, &error, - TRUE, /* Output warning */ + NULL, FALSE, /* Not strict */ - UTF); - if (! valid) { + FALSE, /* No illegal cp's */ + UTF)) + { yyerror(error); uv = 0; /* drop through to ensure range ends are set */ } @@ -3569,12 +3570,13 @@ S_scan_const(pTHX_ char *start) { const char* error; - bool valid = grok_bslash_x(&s, send, + if (! grok_bslash_x(&s, send, &uv, &error, - TRUE, /* Output warning */ + NULL, FALSE, /* Not strict */ - UTF); - if (! valid) { + FALSE, /* No illegal cp's */ + UTF)) + { yyerror(error); uv = 0; /* drop through to ensure range ends are set */ } |