diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-11-05 21:09:53 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-11-05 21:09:53 +0100 |
commit | e251c6463913bcd7c9c40b4dc168010f6de68b5a (patch) | |
tree | a8d2cfcfa09de64d86b10f1a6137373b553f078b /src/main.c | |
parent | 436557eca3da4492def86d5ef8c2d84c5d1c3e71 (diff) |
Check for whitespace after regex using islbrk()
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -330,14 +330,13 @@ pattern_comp(u8view_t pat) reopts |= PCRE2_UCP; for (;;) { - if (ucsgnext(&g, &pat) == 0) + if (ucsgnext(&g, &pat) == 0 || islbrk(g)) break; - if (g.len != 1) - goto bad_flag; - if (uprop_is_pat_ws(*g.p)) + int w = ucsnext(&ch, &g); + if (uprop_is_pat_ws(ch)) break; - switch (*g.p) { + switch (ch) { case 'i': reopts |= PCRE2_CASELESS; break; case 'I': reopts &= ~PCRE2_CASELESS; break; case 'l': reopts |= PCRE2_LITERAL; break; @@ -345,7 +344,7 @@ pattern_comp(u8view_t pat) case 'u': reopts |= PCRE2_UCP; break; case 'U': reopts &= ~PCRE2_UCP; break; default: - bad_flag: + VSHFT(&g, -w); cerr(EXIT_FATAL, "Unknown regex flag %s%.*s%s", lquot, SV_PRI_ARGS(g), rquot); } |