[PATCH] Option parsing: support case-insensitive option matching.
Shankar Kalpathi Easwaran
shankarke at gmail.com
Tue Aug 27 11:38:26 PDT 2013
================
Comment at: include/llvm/Option/OptTable.h:29-42
@@ +28,16 @@
+inline int StrCmpOptionNameIgnoreCase(const char *A, const char *B) {
+ const char *X = A, *Y = B;
+ char a = tolower(*A), b = tolower(*B);
+ while (a == b) {
+ if (a == '\0')
+ return 0;
+
+ a = tolower(*++X);
+ b = tolower(*++Y);
+ }
+
+ if (a == '\0') // A is a prefix of B.
+ return 1;
+ if (b == '\0') // B is a prefix of A.
+ return -1;
+
----------------
Reid Kleckner wrote:
> Shankar Kalpathi Easwaran wrote:
> > Cant we just use strncasecmp here ?
> No, prefixes come later in the sort, ie
> abc
> ab
> a
>
> vs.
>
> a
> ab
> abc
What I was trying to recommend here was
if (strncasecmp(A, B, strlen(A)) == 0)
return 1;
if (strncasecmp(A, B, strlen(B)) == 0)
return 1;
http://llvm-reviews.chandlerc.com/D1485
BRANCH
ignore-case
ARCANIST PROJECT
llvm
More information about the llvm-commits
mailing list