| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flags.h" | 5 #include "vm/flags.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/json_stream.h" | 8 #include "vm/json_stream.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 | 10 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 break; | 203 break; |
| 204 } | 204 } |
| 205 case Flag::kString: { | 205 case Flag::kString: { |
| 206 *flag->charp_ptr_ = argument == NULL ? NULL : strdup(argument); | 206 *flag->charp_ptr_ = argument == NULL ? NULL : strdup(argument); |
| 207 break; | 207 break; |
| 208 } | 208 } |
| 209 case Flag::kInteger: { | 209 case Flag::kInteger: { |
| 210 char* endptr = NULL; | 210 char* endptr = NULL; |
| 211 int val = strtol(argument, &endptr, 10); | 211 const intptr_t len = strlen(argument); |
| 212 if (endptr != argument) { | 212 int base = 10; |
| 213 if ((len > 2) && (argument[0] == '0') && (argument[1] == 'x')) { |
| 214 base = 16; |
| 215 } |
| 216 int val = strtol(argument, &endptr, base); |
| 217 if (endptr == argument + len) { |
| 213 *flag->int_ptr_ = val; | 218 *flag->int_ptr_ = val; |
| 219 } else { |
| 220 return false; |
| 214 } | 221 } |
| 215 break; | 222 break; |
| 216 } | 223 } |
| 217 case Flag::kFunc: { | 224 case Flag::kFunc: { |
| 218 if (strcmp(argument, "true") == 0) { | 225 if (strcmp(argument, "true") == 0) { |
| 219 (flag->handler_)(true); | 226 (flag->handler_)(true); |
| 220 } else if (strcmp(argument, "false") == 0) { | 227 } else if (strcmp(argument, "false") == 0) { |
| 221 (flag->handler_)(false); | 228 (flag->handler_)(false); |
| 222 } else { | 229 } else { |
| 223 return false; | 230 return false; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 for (intptr_t i = 0; i < num_flags_; ++i) { | 440 for (intptr_t i = 0; i < num_flags_; ++i) { |
| 434 Flag* flag = flags_[i]; | 441 Flag* flag = flags_[i]; |
| 435 if (flag->changed_) { | 442 if (flag->changed_) { |
| 436 PrintFlagToJSONArray(&jsarr, flag); | 443 PrintFlagToJSONArray(&jsarr, flag); |
| 437 } | 444 } |
| 438 } | 445 } |
| 439 } | 446 } |
| 440 } | 447 } |
| 441 | 448 |
| 442 } // namespace dart | 449 } // namespace dart |
| OLD | NEW |