From f0bec8572bfc0960841435155002455fc1dabd67 Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Wed, 8 Aug 2018 14:06:59 +0300 Subject: uwildmat: Case-insensitive test selection Since we only use plain ascii in subtest names, using non-locale-aware tolower() to compare case-insensitively works. Doing this within uwildmat instead of tolowering the subtest name and then calling uwildmat() is required, because of selection strings like: foo,bar,!Foo The above line will select subtest Bar, and not select Foo. Signed-off-by: Petri Latvala Reviewed-by: Arkadiusz Hiler --- lib/uwildmat/uwildmat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/uwildmat') diff --git a/lib/uwildmat/uwildmat.c b/lib/uwildmat/uwildmat.c index 09155865..3beafce2 100644 --- a/lib/uwildmat/uwildmat.c +++ b/lib/uwildmat/uwildmat.c @@ -93,6 +93,7 @@ ** accompanying test suite achieves 100% coverage of this file. */ +#include #include #include #include "uwildmat/uwildmat.h" @@ -222,6 +223,7 @@ match_class(uint32_t text, const unsigned char *start, const unsigned char *p = start; uint32_t first = 0; uint32_t last; + uint32_t lc = tolower(text); /* Check for an inverted character class (starting with ^). If the character matches the character class, we return !reversed; that way, @@ -244,12 +246,13 @@ match_class(uint32_t text, const unsigned char *start, if (allowrange && *p == '-' && p < end) { p++; p += utf8_decode(p, end, &last); - if (text >= first && text <= last) + if ((text >= first && text <= last) || + (lc >= first && lc <= last)) return !reversed; allowrange = false; } else { p += utf8_decode(p, end, &first); - if (text == first) + if (text == first || lc == first) return !reversed; allowrange = true; } @@ -272,6 +275,7 @@ match_pattern(const unsigned char *text, const unsigned char *start, bool ismeta; int matched, width; uint32_t c; + unsigned char lc; for (; p <= end; p++) { if (!*text && *p != '*') @@ -284,7 +288,8 @@ match_pattern(const unsigned char *text, const unsigned char *start, /* Fall through. */ default: - if (*text++ != *p) + lc = tolower(*text); + if (*text++ != *p && lc != *p) return false; break; -- cgit v1.2.3