Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: src/flags.cc

Issue 22851009: Allow both "--no<flag>" and "--no-<flag>" to disable <flag>. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: also allow --no_ Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 args->Add(buffer.ToCString().Detach()); 261 args->Add(buffer.ToCString().Detach());
262 JSArguments jsargs = *args_flag->args_variable(); 262 JSArguments jsargs = *args_flag->args_variable();
263 for (int j = 0; j < jsargs.argc(); j++) { 263 for (int j = 0; j < jsargs.argc(); j++) {
264 args->Add(StrDup(jsargs[j])); 264 args->Add(StrDup(jsargs[j]));
265 } 265 }
266 } 266 }
267 return args; 267 return args;
268 } 268 }
269 269
270 270
271 inline char NormalizeChar(char ch) {
272 return ch == '_' ? '-' : ch;
273 }
274
275
271 // Helper function to parse flags: Takes an argument arg and splits it into 276 // Helper function to parse flags: Takes an argument arg and splits it into
272 // a flag name and flag value (or NULL if they are missing). is_bool is set 277 // a flag name and flag value (or NULL if they are missing). is_bool is set
273 // if the arg started with "-no" or "--no". The buffer may be used to NUL- 278 // if the arg started with "-no" or "--no". The buffer may be used to NUL-
274 // terminate the name, it must be large enough to hold any possible name. 279 // terminate the name, it must be large enough to hold any possible name.
275 static void SplitArgument(const char* arg, 280 static void SplitArgument(const char* arg,
276 char* buffer, 281 char* buffer,
277 int buffer_size, 282 int buffer_size,
278 const char** name, 283 const char** name,
279 const char** value, 284 const char** value,
280 bool* is_bool) { 285 bool* is_bool) {
281 *name = NULL; 286 *name = NULL;
282 *value = NULL; 287 *value = NULL;
283 *is_bool = false; 288 *is_bool = false;
284 289
285 if (arg != NULL && *arg == '-') { 290 if (arg != NULL && *arg == '-') {
286 // find the begin of the flag name 291 // find the begin of the flag name
287 arg++; // remove 1st '-' 292 arg++; // remove 1st '-'
288 if (*arg == '-') { 293 if (*arg == '-') {
289 arg++; // remove 2nd '-' 294 arg++; // remove 2nd '-'
290 if (arg[0] == '\0') { 295 if (arg[0] == '\0') {
291 const char* kJSArgumentsFlagName = "js_arguments"; 296 const char* kJSArgumentsFlagName = "js_arguments";
292 *name = kJSArgumentsFlagName; 297 *name = kJSArgumentsFlagName;
293 return; 298 return;
294 } 299 }
295 } 300 }
296 if (arg[0] == 'n' && arg[1] == 'o') { 301 if (arg[0] == 'n' && arg[1] == 'o') {
297 arg += 2; // remove "no" 302 arg += 2; // remove "no"
303 if (NormalizeChar(arg[0]) == '-') arg++; // remove dash after "no".
298 *is_bool = true; 304 *is_bool = true;
299 } 305 }
300 *name = arg; 306 *name = arg;
301 307
302 // find the end of the flag name 308 // find the end of the flag name
303 while (*arg != '\0' && *arg != '=') 309 while (*arg != '\0' && *arg != '=')
304 arg++; 310 arg++;
305 311
306 // get the value if any 312 // get the value if any
307 if (*arg == '=') { 313 if (*arg == '=') {
308 // make a copy so we can NUL-terminate flag name 314 // make a copy so we can NUL-terminate flag name
309 size_t n = arg - *name; 315 size_t n = arg - *name;
310 CHECK(n < static_cast<size_t>(buffer_size)); // buffer is too small 316 CHECK(n < static_cast<size_t>(buffer_size)); // buffer is too small
311 OS::MemCopy(buffer, *name, n); 317 OS::MemCopy(buffer, *name, n);
312 buffer[n] = '\0'; 318 buffer[n] = '\0';
313 *name = buffer; 319 *name = buffer;
314 // get the value 320 // get the value
315 *value = arg + 1; 321 *value = arg + 1;
316 } 322 }
317 } 323 }
318 } 324 }
319 325
320 326
321 inline char NormalizeChar(char ch) {
322 return ch == '_' ? '-' : ch;
323 }
324
325
326 static bool EqualNames(const char* a, const char* b) { 327 static bool EqualNames(const char* a, const char* b) {
327 for (int i = 0; NormalizeChar(a[i]) == NormalizeChar(b[i]); i++) { 328 for (int i = 0; NormalizeChar(a[i]) == NormalizeChar(b[i]); i++) {
328 if (a[i] == '\0') { 329 if (a[i] == '\0') {
329 return true; 330 return true;
330 } 331 }
331 } 332 }
332 return false; 333 return false;
333 } 334 }
334 335
335 336
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 549 }
549 550
550 551
551 void FlagList::EnforceFlagImplications() { 552 void FlagList::EnforceFlagImplications() {
552 #define FLAG_MODE_DEFINE_IMPLICATIONS 553 #define FLAG_MODE_DEFINE_IMPLICATIONS
553 #include "flag-definitions.h" 554 #include "flag-definitions.h"
554 #undef FLAG_MODE_DEFINE_IMPLICATIONS 555 #undef FLAG_MODE_DEFINE_IMPLICATIONS
555 } 556 }
556 557
557 } } // namespace v8::internal 558 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698