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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « tools/flags/SkCommandLineFlags.h ('k') | tools/flags/SkCommonFlags.cpp » ('j') | 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"
(...skipping 11 matching lines...) Expand all
22 info->fDefaultString.set(defaultValue); 22 info->fDefaultString.set(defaultValue);
23 23
24 info->fStrings = pStrings; 24 info->fStrings = pStrings;
25 SetDefaultStrings(pStrings, defaultValue); 25 SetDefaultStrings(pStrings, defaultValue);
26 return true; 26 return true;
27 } 27 }
28 28
29 void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings, 29 void SkFlagInfo::SetDefaultStrings(SkCommandLineFlags::StringArray* pStrings,
30 const char* defaultValue) { 30 const char* defaultValue) {
31 pStrings->reset(); 31 pStrings->reset();
32 if (NULL == defaultValue) { 32 if (nullptr == defaultValue) {
33 return; 33 return;
34 } 34 }
35 // If default is "", leave the array empty. 35 // If default is "", leave the array empty.
36 size_t defaultLength = strlen(defaultValue); 36 size_t defaultLength = strlen(defaultValue);
37 if (defaultLength > 0) { 37 if (defaultLength > 0) {
38 const char* const defaultEnd = defaultValue + defaultLength; 38 const char* const defaultEnd = defaultValue + defaultLength;
39 const char* begin = defaultValue; 39 const char* begin = defaultValue;
40 while (true) { 40 while (true) {
41 while (begin < defaultEnd && ' ' == *begin) { 41 while (begin < defaultEnd && ' ' == *begin) {
42 begin++; 42 begin++;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 SkDebugf("Requested help for unrecognized flags:\n"); 261 SkDebugf("Requested help for unrecognized flags:\n");
262 for (int k = 0; k < helpFlags.count(); k++) { 262 for (int k = 0; k < helpFlags.count(); k++) {
263 SkDebugf(" --%s\n", helpFlags[k]); 263 SkDebugf(" --%s\n", helpFlags[k]);
264 } 264 }
265 } 265 }
266 helpPrinted = true; 266 helpPrinted = true;
267 } 267 }
268 if (!helpPrinted) { 268 if (!helpPrinted) {
269 bool flagMatched = false; 269 bool flagMatched = false;
270 SkFlagInfo* flag = gHead; 270 SkFlagInfo* flag = gHead;
271 while (flag != NULL) { 271 while (flag != nullptr) {
272 if (flag->match(argv[i])) { 272 if (flag->match(argv[i])) {
273 flagMatched = true; 273 flagMatched = true;
274 switch (flag->getFlagType()) { 274 switch (flag->getFlagType()) {
275 case SkFlagInfo::kBool_FlagType: 275 case SkFlagInfo::kBool_FlagType:
276 // Can be handled by match, above, but can also be s et by the next 276 // Can be handled by match, above, but can also be s et by the next
277 // string. 277 // string.
278 if (i+1 < argc && !SkStrStartsWith(argv[i+1], '-')) { 278 if (i+1 < argc && !SkStrStartsWith(argv[i+1], '-')) {
279 i++; 279 i++;
280 bool value; 280 bool value;
281 if (parse_bool_arg(argv[i], &value)) { 281 if (parse_bool_arg(argv[i], &value)) {
282 flag->setBool(value); 282 flag->setBool(value);
283 } 283 }
284 } 284 }
285 break; 285 break;
286 case SkFlagInfo::kString_FlagType: 286 case SkFlagInfo::kString_FlagType:
287 flag->resetStrings(); 287 flag->resetStrings();
288 // Add all arguments until another flag is reached. 288 // Add all arguments until another flag is reached.
289 while (i+1 < argc) { 289 while (i+1 < argc) {
290 char* end = NULL; 290 char* end = nullptr;
291 // Negative numbers aren't flags. 291 // Negative numbers aren't flags.
292 ignore_result(strtod(argv[i+1], &end)); 292 ignore_result(strtod(argv[i+1], &end));
293 if (end == argv[i+1] && SkStrStartsWith(argv[i+1 ], '-')) { 293 if (end == argv[i+1] && SkStrStartsWith(argv[i+1 ], '-')) {
294 break; 294 break;
295 } 295 }
296 i++; 296 i++;
297 flag->append(argv[i]); 297 flag->append(argv[i]);
298 } 298 }
299 break; 299 break;
300 case SkFlagInfo::kInt_FlagType: 300 case SkFlagInfo::kInt_FlagType:
(...skipping 23 matching lines...) Expand all
324 } else { 324 } else {
325 SkDebugf("Got unknown flag '%s'. Exiting.\n", argv[i]); 325 SkDebugf("Got unknown flag '%s'. Exiting.\n", argv[i]);
326 exit(-1); 326 exit(-1);
327 } 327 }
328 } 328 }
329 } 329 }
330 } 330 }
331 // Since all of the flags have been set, release the memory used by each 331 // Since all of the flags have been set, release the memory used by each
332 // flag. FLAGS_x can still be used after this. 332 // flag. FLAGS_x can still be used after this.
333 SkFlagInfo* flag = gHead; 333 SkFlagInfo* flag = gHead;
334 gHead = NULL; 334 gHead = nullptr;
335 while (flag != NULL) { 335 while (flag != nullptr) {
336 SkFlagInfo* next = flag->next(); 336 SkFlagInfo* next = flag->next();
337 delete flag; 337 delete flag;
338 flag = next; 338 flag = next;
339 } 339 }
340 if (helpPrinted) { 340 if (helpPrinted) {
341 exit(0); 341 exit(0);
342 } 342 }
343 } 343 }
344 344
345 namespace { 345 namespace {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 377 }
378 378
379 } // namespace 379 } // namespace
380 380
381 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) { 381 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
382 return ShouldSkipImpl(strings, name); 382 return ShouldSkipImpl(strings, name);
383 } 383 }
384 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name ) { 384 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name ) {
385 return ShouldSkipImpl(strings, name); 385 return ShouldSkipImpl(strings, name);
386 } 386 }
OLDNEW
« no previous file with comments | « tools/flags/SkCommandLineFlags.h ('k') | tools/flags/SkCommonFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698