summaryrefslogtreecommitdiff
path: root/lib/uwildmat
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-08-08 14:06:59 +0300
committerPetri Latvala <petri.latvala@intel.com>2018-08-09 10:33:28 +0300
commitf0bec8572bfc0960841435155002455fc1dabd67 (patch)
tree7f2f7fba27d7173c7315c51257ab7fe785f2f498 /lib/uwildmat
parent0c57495e924b25acbaa58ec41ff03aba38183d96 (diff)
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 <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/uwildmat')
-rw-r--r--lib/uwildmat/uwildmat.c11
1 files changed, 8 insertions, 3 deletions
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 <ctype.h>
#include <string.h>
#include <stdint.h>
#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;