Skip to content

Commit ca79298

Browse files
committed
regcomp.c: Avoid UTF8SKIPs
This value is now returned from the isID(FIRST|CONT)_lazy_if_safe macros. Use it instead of re-deriving it. This also simplifies the code
1 parent 6f05113 commit ca79298

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

regcomp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,19 +2522,16 @@ S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags)
25222522
PERL_ARGS_ASSERT_REG_SCAN_NAME;
25232523

25242524
assert (RExC_parse <= RExC_end);
2525+
Size_t advance;
25252526
if (RExC_parse == RExC_end) NOOP;
2526-
else if (isIDFIRST_lazy_if_safe(RExC_parse, RExC_end, UTF)) {
2527+
else if ((advance = isIDFIRST_lazy_if_safe(RExC_parse, RExC_end, UTF))) {
25272528
/* Note that the code here assumes well-formed UTF-8. Skip IDFIRST by
25282529
* using do...while */
2529-
if (UTF)
25302530
do {
2531-
RExC_parse_inc_utf8();
2531+
RExC_parse_advance(advance);
25322532
} while ( RExC_parse < RExC_end
2533-
&& isWORDCHAR_utf8_safe((U8*)RExC_parse, (U8*) RExC_end));
2534-
else
2535-
do {
2536-
RExC_parse_inc_by(1);
2537-
} while (RExC_parse < RExC_end && isWORDCHAR(*RExC_parse));
2533+
&& (advance = isWORDCHAR_utf8_safe( (U8 *) RExC_parse,
2534+
(U8 *) RExC_end)));
25382535
} else {
25392536
RExC_parse_inc_by(1); /* so the <- from the vFAIL is after the offending
25402537
character */

regcomp_internal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ struct RExC_state_t {
279279
* output during the parse process.
280280
*/
281281

282+
/* RExC_parse_advance(count)
283+
*
284+
* Increment RExC_parse to point at the next codepoint, when we *know* that the
285+
* correct byte count is in the passed parameter */
286+
#define RExC_parse_advance(count) STMT_START { \
287+
RExC_parse += count; \
288+
} STMT_END
289+
282290
/* RExC_parse_incf(flag)
283291
*
284292
* Increment RExC_parse to point at the next codepoint, while doing

0 commit comments

Comments
 (0)