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

Shankar Kalpathi Easwaran shankarke at gmail.com
Tue Aug 27 11:28:41 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;
+
----------------
Cant we just use strncasecmp here ? 


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



More information about the llvm-commits mailing list