aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/string.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-10-19 13:50:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-24 10:07:46 -0400
commit38d14f0c58fd89d46efd1b783d6536380af28c03 (patch)
tree741aca6b936a0e2ff860853ae0e5be815e3f3ede /tools/perf/util/string.c
parentecf1e2253ea79c6204f4d6a5e756e8fb4aed5a7e (diff)
perf list: Make vendor event matching case insensitive
Make the 'perf list' glob matching for vendor events case insensitive. This allows to use the upper case vendor events with perf list too. Now the following works: % perf list LONGEST_LAT ... cache: longest_lat_cache.miss [Core-originated cacheable demand requests missed LLC] longest_lat_cache.reference [Core-originated cacheable demand requests that refer to LLC] Signed-off-by: Andi Kleen <ak@linux.intel.com> Suggested-by: Ingo Molnar <mingo@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/1476899402-31460-1-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/string.c')
-rw-r--r--tools/perf/util/string.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 7f7e072be746..d8dfaf64b32e 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -193,7 +193,8 @@ error:
193} 193}
194 194
195/* Glob/lazy pattern matching */ 195/* Glob/lazy pattern matching */
196static bool __match_glob(const char *str, const char *pat, bool ignore_space) 196static bool __match_glob(const char *str, const char *pat, bool ignore_space,
197 bool case_ins)
197{ 198{
198 while (*str && *pat && *pat != '*') { 199 while (*str && *pat && *pat != '*') {
199 if (ignore_space) { 200 if (ignore_space) {
@@ -219,8 +220,13 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
219 return false; 220 return false;
220 else if (*pat == '\\') /* Escaped char match as normal char */ 221 else if (*pat == '\\') /* Escaped char match as normal char */
221 pat++; 222 pat++;
222 if (*str++ != *pat++) 223 if (case_ins) {
224 if (tolower(*str) != tolower(*pat))
225 return false;
226 } else if (*str != *pat)
223 return false; 227 return false;
228 str++;
229 pat++;
224 } 230 }
225 /* Check wild card */ 231 /* Check wild card */
226 if (*pat == '*') { 232 if (*pat == '*') {
@@ -229,7 +235,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
229 if (!*pat) /* Tail wild card matches all */ 235 if (!*pat) /* Tail wild card matches all */
230 return true; 236 return true;
231 while (*str) 237 while (*str)
232 if (__match_glob(str++, pat, ignore_space)) 238 if (__match_glob(str++, pat, ignore_space, case_ins))
233 return true; 239 return true;
234 } 240 }
235 return !*str && !*pat; 241 return !*str && !*pat;
@@ -249,7 +255,12 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
249 */ 255 */
250bool strglobmatch(const char *str, const char *pat) 256bool strglobmatch(const char *str, const char *pat)
251{ 257{
252 return __match_glob(str, pat, false); 258 return __match_glob(str, pat, false, false);
259}
260
261bool strglobmatch_nocase(const char *str, const char *pat)
262{
263 return __match_glob(str, pat, false, true);
253} 264}
254 265
255/** 266/**
@@ -262,7 +273,7 @@ bool strglobmatch(const char *str, const char *pat)
262 */ 273 */
263bool strlazymatch(const char *str, const char *pat) 274bool strlazymatch(const char *str, const char *pat)
264{ 275{
265 return __match_glob(str, pat, true); 276 return __match_glob(str, pat, true, false);
266} 277}
267 278
268/** 279/**