mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
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
This commit is contained in:
@@ -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");
|
||||
|
Reference in New Issue
Block a user