summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRasmus Villemoes <[email protected]>2025-05-13 10:40:29 +0200
committerTom Rini <[email protected]>2025-05-29 08:25:18 -0600
commit457f19815c8f8b74c36d8cbef454a0b575ea7068 (patch)
treee002e1e25f0de814bc4559f648af91711492ace6 /lib
parentebdd78c487f6599f693e53e707606d7295f20f6e (diff)
slre: refactor is_any_but()
As preparation for fixing the handling of backslash-escapes used inside a character class, refactor is_any_but() to be defined in terms of is_any_of() so we don't have to repeat the same logic in two places. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/slre.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/slre.c b/lib/slre.c
index 4f455400d3a..5cb0d3ec7fa 100644
--- a/lib/slre.c
+++ b/lib/slre.c
@@ -484,17 +484,14 @@ is_any_of(const unsigned char *p, int len, const char *s, int *ofs)
static int
is_any_but(const unsigned char *p, int len, const char *s, int *ofs)
{
- int i, ch;
-
- ch = s[*ofs];
+ int dummy = *ofs;
- for (i = 0; i < len; i++) {
- if (p[i] == ch)
- return 0;
+ if (is_any_of(p, len, s, &dummy)) {
+ return 0;
+ } else {
+ (*ofs)++;
+ return 1;
}
-
- (*ofs)++;
- return 1;
}
static int