[PATCH] Option parsing: support case-insensitive option matching.

Reid Kleckner rnk at google.com
Tue Aug 27 11:35:35 PDT 2013


  LGTM


================
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;
+
----------------
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


http://llvm-reviews.chandlerc.com/D1485

BRANCH
  ignore-case

ARCANIST PROJECT
  llvm



More information about the llvm-commits mailing list