diff options
author | Rui Ueyama <ruiu@google.com> | 2013-08-28 00:02:06 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-08-28 00:02:06 +0000 |
commit | 1997734e37775a68182b3fd508a52e0c28ff36f8 (patch) | |
tree | 0b2fccda27b7be4d26508a366e13c62cf0b1c9ef /utils | |
parent | 7b2ee399d9c1b2112962d29540c25b94fa98e8ed (diff) | |
download | llvm-1997734e37775a68182b3fd508a52e0c28ff36f8.tar.gz llvm-1997734e37775a68182b3fd508a52e0c28ff36f8.tar.bz2 llvm-1997734e37775a68182b3fd508a52e0c28ff36f8.tar.xz |
Revert "Option parsing: support case-insensitive option matching." as it broke Windows buildbot.
This reverts r189416.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/OptParserEmitter.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp index f2694361db..86328bf18f 100644 --- a/utils/TableGen/OptParserEmitter.cpp +++ b/utils/TableGen/OptParserEmitter.cpp @@ -13,25 +13,27 @@ #include "llvm/ADT/Twine.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" -#include <cstring> #include <map> -#include <strings.h> 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) { - size_t I = strlen(A); - size_t J = strlen(B); - if (I == J) { - if (int N = strcasecmp(A, B)) - return N; - return strcmp(A, B); + char a = *A, b = *B; + while (a == b) { + if (a == '\0') + return 0; + + a = *++A; + b = *++B; } - if (I < J) - return strncasecmp(A, B, I) < 0 ? -1 : 1; - return strncasecmp(A, B, J) <= 0 ? -1 : 1; + + if (a == '\0') // A is a prefix of B. + return 1; + if (b == '\0') // B is a prefix of A. + return -1; + + // Otherwise lexicographic. + return (a < b) ? -1 : 1; } static int CompareOptionRecords(const void *Av, const void *Bv) { @@ -48,7 +50,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"); |