]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
slre: refactor is_any_but()
authorRasmus Villemoes <ravi@prevas.dk>
Tue, 13 May 2025 08:40:29 +0000 (10:40 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 29 May 2025 14:25:18 +0000 (08:25 -0600)
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 <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
lib/slre.c

index 4f455400d3a62aeb8af42497ac9f8ce0328f4fb5..5cb0d3ec7facefa12e7c94572b0cbb92a6f39996 100644 (file)
@@ -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