diff --git a/src/flags.cc b/src/flags.cc index 855e20712c..4e18cc8c80 100644 --- a/src/flags.cc +++ b/src/flags.cc @@ -268,6 +268,11 @@ List* FlagList::argv() { } +inline char NormalizeChar(char ch) { + return ch == '_' ? '-' : ch; +} + + // Helper function to parse flags: Takes an argument arg and splits it into // a flag name and flag value (or NULL if they are missing). is_bool is set // if the arg started with "-no" or "--no". The buffer may be used to NUL- @@ -295,6 +300,7 @@ static void SplitArgument(const char* arg, } if (arg[0] == 'n' && arg[1] == 'o') { arg += 2; // remove "no" + if (NormalizeChar(arg[0]) == '-') arg++; // remove dash after "no". *is_bool = true; } *name = arg; @@ -318,11 +324,6 @@ static void SplitArgument(const char* arg, } -inline char NormalizeChar(char ch) { - return ch == '_' ? '-' : ch; -} - - static bool EqualNames(const char* a, const char* b) { for (int i = 0; NormalizeChar(a[i]) == NormalizeChar(b[i]); i++) { if (a[i] == '\0') {