Chromium Code Reviews| 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/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 while ((*equals != '\0') && (*equals != '=')) { | 165 while ((*equals != '\0') && (*equals != '=')) { |
| 166 equals++; | 166 equals++; |
| 167 } | 167 } |
| 168 | 168 |
| 169 const char* argument = NULL; | 169 const char* argument = NULL; |
| 170 | 170 |
| 171 // Determine if this is an option argument. | 171 // Determine if this is an option argument. |
| 172 if (*equals != '=') { | 172 if (*equals != '=') { |
| 173 // No explicit option argument. Determine if there is a "no_" prefix | 173 // No explicit option argument. Determine if there is a "no_" prefix |
| 174 // preceding the name. | 174 // preceding the name. |
| 175 const char* kNoPrefix = "no_"; | 175 const char* kNo1Prefix = "no_"; |
| 176 const intptr_t kNoPrefixLen = strlen(kNoPrefix); | 176 const char* kNo2Prefix = "no-"; |
| 177 if (strncmp(option, kNoPrefix, kNoPrefixLen) == 0) { | 177 const intptr_t kNo1PrefixLen = strlen(kNo1Prefix); |
| 178 option += kNoPrefixLen; // Skip the "no_" when looking up the name. | 178 const intptr_t kNo2PrefixLen = strlen(kNo2Prefix); |
| 179 if (strncmp(option, kNo1Prefix, kNo1PrefixLen) == 0) { | |
| 180 option += kNo1PrefixLen; // Skip the "no_" when looking up the name. | |
| 181 argument = "false"; | |
| 182 } else if (strncmp(option, kNo2Prefix, kNo2PrefixLen) == 0) { | |
| 183 option += kNo2PrefixLen; // Skip the "no-" when looking up the name. | |
| 179 argument = "false"; | 184 argument = "false"; |
| 180 } else { | 185 } else { |
| 181 argument = "true"; | 186 argument = "true"; |
| 182 } | 187 } |
| 183 } else { | 188 } else { |
| 184 // The argument for the option starts right after the equals sign. | 189 // The argument for the option starts right after the equals sign. |
| 185 argument = equals + 1; | 190 argument = equals + 1; |
| 186 } | 191 } |
| 187 | 192 |
| 188 // Initialize the flag name. | 193 // Initialize the flag name. |
| 189 intptr_t name_len = equals - option; | 194 intptr_t name_len = equals - option; |
| 190 char* name = new char[name_len + 1]; | 195 char* name = new char[name_len + 1]; |
| 191 strncpy(name, option, name_len); | 196 strncpy(name, option, name_len); |
| 192 name[name_len] = '\0'; | 197 name[name_len] = '\0'; |
| 193 Normalize(name); | 198 Normalize(name); |
|
siva
2012/03/10 00:19:49
Would it not work if this normalization block is m
Ivan Posva
2012/03/10 00:31:30
That would work too, but then you have to ensure t
| |
| 194 | 199 |
| 195 Flag* flag = Flags::Lookup(name); | 200 Flag* flag = Flags::Lookup(name); |
| 196 if (flag == NULL) { | 201 if (flag == NULL) { |
| 197 // Collect unrecognized flags. | 202 // Collect unrecognized flags. |
| 198 char* new_flag = new char[name_len + 1]; | 203 char* new_flag = new char[name_len + 1]; |
| 199 strncpy(new_flag, name, name_len); | 204 strncpy(new_flag, name, name_len); |
| 200 new_flag[name_len] = '\0'; | 205 new_flag[name_len] = '\0'; |
| 201 Flags::Register_bool(NULL, new_flag, true, NULL); | 206 Flags::Register_bool(NULL, new_flag, true, NULL); |
| 202 } else { | 207 } else { |
| 203 // Only set values for recognized flags, skip collected | 208 // Only set values for recognized flags, skip collected |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 while (flag != NULL) { | 306 while (flag != NULL) { |
| 302 flag->Print(); | 307 flag->Print(); |
| 303 flag = flag->next_; | 308 flag = flag->next_; |
| 304 } | 309 } |
| 305 } | 310 } |
| 306 | 311 |
| 307 return true; | 312 return true; |
| 308 } | 313 } |
| 309 | 314 |
| 310 } // namespace dart | 315 } // namespace dart |
| OLD | NEW |