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

Side by Side Diff: tools/flags/SkCommandLineFlags.cpp

Issue 1127603003: ignore_result() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 7 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
« 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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkTDArray.h" 9 #include "SkTDArray.h"
10 #include "SkTSort.h" 10 #include "SkTSort.h"
11 11
12 DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing." ); 12 DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing." );
13 13
14 template <typename T> static void ignore_result(const T&) {}
tfarina 2015/05/04 17:39:31 I checked in chromium, and this is equal how they
15
14 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, 16 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName,
15 SkCommandLineFlags::StringArray* pStrings, 17 SkCommandLineFlags::StringArray* pStrings,
16 const char* defaultValue, const char* helpStri ng) { 18 const char* defaultValue, const char* helpStri ng) {
17 SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType , helpString)); 19 SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType , helpString));
18 info->fDefaultString.set(defaultValue); 20 info->fDefaultString.set(defaultValue);
19 21
20 info->fStrings = pStrings; 22 info->fStrings = pStrings;
21 SetDefaultStrings(pStrings, defaultValue); 23 SetDefaultStrings(pStrings, defaultValue);
22 return true; 24 return true;
23 } 25 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (parse_bool_arg(argv[i], &value)) { 279 if (parse_bool_arg(argv[i], &value)) {
278 flag->setBool(value); 280 flag->setBool(value);
279 } 281 }
280 } 282 }
281 break; 283 break;
282 case SkFlagInfo::kString_FlagType: 284 case SkFlagInfo::kString_FlagType:
283 flag->resetStrings(); 285 flag->resetStrings();
284 // Add all arguments until another flag is reached. 286 // Add all arguments until another flag is reached.
285 while (i+1 < argc) { 287 while (i+1 < argc) {
286 char* end = NULL; 288 char* end = NULL;
287 (void)strtod(argv[i+1], &end); // Negative numbe rs aren't flags. 289 // Negative numbers aren't flags.
290 ignore_result(strtod(argv[i+1], &end));
288 if (end == argv[i+1] && SkStrStartsWith(argv[i+1 ], '-')) { 291 if (end == argv[i+1] && SkStrStartsWith(argv[i+1 ], '-')) {
289 break; 292 break;
290 } 293 }
291 i++; 294 i++;
292 flag->append(argv[i]); 295 flag->append(argv[i]);
293 } 296 }
294 break; 297 break;
295 case SkFlagInfo::kInt_FlagType: 298 case SkFlagInfo::kInt_FlagType:
296 i++; 299 i++;
297 flag->setInt(atoi(argv[i])); 300 flag->setInt(atoi(argv[i]));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 374 }
372 375
373 } // namespace 376 } // namespace
374 377
375 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) { 378 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
376 return ShouldSkipImpl(strings, name); 379 return ShouldSkipImpl(strings, name);
377 } 380 }
378 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name ) { 381 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name ) {
379 return ShouldSkipImpl(strings, name); 382 return ShouldSkipImpl(strings, name);
380 } 383 }
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