Allow both "--no<flag>" and "--no-<flag>" to disable <flag>.
We shouldn't need to know whether to use --no or --no- as prefix. The latter is more intuitive and also what chromium uses. R=machenbach@chromium.org BUG= Review URL: https://codereview.chromium.org/22851009 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16261 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
6337281204
commit
0cc3a7fde9
11
src/flags.cc
11
src/flags.cc
@ -268,6 +268,11 @@ List<const char*>* 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') {
|
||||
|
Loading…
Reference in New Issue
Block a user