Skip to content

Commit

Permalink
regexec.c: Refactor macro to generalize it
Browse files Browse the repository at this point in the history
This is in preparation for a somewhat different use to be added.
  • Loading branch information
khwilliamson committed May 30, 2021
1 parent ea852e0 commit bd20d3b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions regexec.c
Expand Up @@ -1884,13 +1884,12 @@ STMT_START {
previous_occurrence_end = s; \
}

/* This differs from the above macros in that it is passed a single byte that
* is known to begin the next occurrence of the thing being looked for in 's'.
* It does a memchr to find the next occurrence of 'byte', before trying 'COND'
* at that position. */
#define REXEC_FBC_FIND_NEXT_UTF8_BYTE_SCAN(byte, COND) \
/* This is like the above macro except the function returns NULL if there is no
* occurrence, and there is a further condition that must be matched besides
* the function */
#define REXEC_FBC_FIND_NEXT_UTF8_SCAN_COND(f, COND) \
while (s < strend) { \
s = (char *) memchr(s, byte, strend -s); \
s = (char *) f; \
if (s == NULL) { \
s = (char *) strend; \
break; \
Expand All @@ -1906,6 +1905,14 @@ STMT_START {
} \
}

/* This differs from the above macros in that it is passed a single byte that
* is known to begin the next occurrence of the thing being looked for in 's'.
* It does a memchr to find the next occurrence of 'byte', before trying 'COND'
* at that position. */
#define REXEC_FBC_FIND_NEXT_UTF8_BYTE_SCAN(byte, COND) \
REXEC_FBC_FIND_NEXT_UTF8_SCAN_COND(memchr(s, byte, strend - s), \
COND)

/* The four macros below are slightly different versions of the same logic.
*
* The first is for /a and /aa when the target string is UTF-8. This can only
Expand Down

0 comments on commit bd20d3b

Please sign in to comment.