diff options
author | Rui Ueyama <ruiu@google.com> | 2013-08-28 20:04:31 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-08-28 20:04:31 +0000 |
commit | 2957273b888dabe8be8e2fa5ac691e39879685c4 (patch) | |
tree | 275ac46fd8d334c7ae15c3391cb95c76e22f3e74 /utils | |
parent | 435798e96a64738b55a01055dde1bc9a88a15191 (diff) | |
download | llvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.gz llvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.bz2 llvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.xz |
Option parsing: support case-insensitive option matching.
Re-submitting r189416 with fix for Windows build on where strcasecmp is not defined.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/OptParserEmitter.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp index 86328bf18f..7fb7d65a70 100644 --- a/utils/TableGen/OptParserEmitter.cpp +++ b/utils/TableGen/OptParserEmitter.cpp @@ -13,18 +13,23 @@ #include "llvm/ADT/Twine.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" +#include <cstring> +#include <cctype> #include <map> using namespace llvm; +// Ordering on Info. The logic should match with the consumer-side function in +// llvm/Option/OptTable.h. static int StrCmpOptionName(const char *A, const char *B) { - char a = *A, b = *B; + const char *X = A, *Y = B; + char a = tolower(*A), b = tolower(*B); while (a == b) { if (a == '\0') - return 0; + return strcmp(A, B); - a = *++A; - b = *++B; + a = tolower(*++X); + b = tolower(*++Y); } if (a == '\0') // A is a prefix of B. @@ -50,7 +55,7 @@ static int CompareOptionRecords(const void *Av, const void *Bv) { if (!ASent) if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(), B->getValueAsString("Name").c_str())) - return Cmp; + return Cmp; if (!ASent) { std::vector<std::string> APrefixes = A->getValueAsListOfStrings("Prefixes"); |