[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-igt-dev
Subject:    [igt-dev] [PATCH i-g-t 2/4] uwildmat: Case-insensitive test selection
From:       Petri Latvala <petri.latvala () intel ! com>
Date:       2018-04-30 9:28:46
Message-ID: 20180430092848.10830-3-petri.latvala () intel ! com
[Download RAW message or body]

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>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela@intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
---
 lib/uwildmat/uwildmat.c | 11 ++++++++---
 1 file 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;
 
-- 
2.14.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic