Chromium Code Reviews| Index: preparser/preparser-process.cc |
| diff --git a/preparser/preparser-process.cc b/preparser/preparser-process.cc |
| index e67851cbd4bb7b943371c7aa6673ef3c191b3b39..961e1d2ba44048864538da82bcf94d8f4610dd16 100644 |
| --- a/preparser/preparser-process.cc |
| +++ b/preparser/preparser-process.cc |
| @@ -267,36 +267,23 @@ void CheckException(v8::PreParserData* data, |
| ExceptionExpectation ParseExpectation(int argc, const char* argv[]) { |
| + // Parse ["throws" [<exn-type> [<start> [<end>]]]]. |
| ExceptionExpectation expects; |
| - |
| - // Parse exception expectations from (the remainder of) the command line. |
| int arg_index = 0; |
| - // Skip any flags. |
| - while (argc > arg_index && IsFlag(argv[arg_index])) arg_index++; |
| + while (argc > arg_index && strncmp("throws", argv[arg_index], 7)) |
|
Lasse Reichstein
2011/10/13 13:08:14
Braces around then-branch.
ulan
2011/10/13 13:43:18
Done.
|
| + ++arg_index; |
|
Lasse Reichstein
2011/10/13 13:08:14
For consistency with the remaining code, just use
ulan
2011/10/13 13:43:18
Done.
|
| if (argc > arg_index) { |
| - if (strncmp("throws", argv[arg_index], 7)) { |
| - // First argument after filename, if present, must be the verbatim |
| - // "throws", marking that the preparsing should fail with an exception. |
| - fail(NULL, "ERROR: Extra arguments not prefixed by \"throws\".\n"); |
| - } |
| expects.throws = true; |
| - do { |
| - arg_index++; |
| - } while (argc > arg_index && IsFlag(argv[arg_index])); |
| - if (argc > arg_index) { |
| - // Next argument is the exception type identifier. |
| - expects.type = argv[arg_index]; |
| - do { |
| - arg_index++; |
| - } while (argc > arg_index && IsFlag(argv[arg_index])); |
| - if (argc > arg_index) { |
| - expects.beg_pos = atoi(argv[arg_index]); // NOLINT |
| - do { |
| - arg_index++; |
| - } while (argc > arg_index && IsFlag(argv[arg_index])); |
| - if (argc > arg_index) { |
| - expects.end_pos = atoi(argv[arg_index]); // NOLINT |
| - } |
| + ++arg_index; |
| + if (argc == arg_index || IsFlag(argv[arg_index])) |
|
Lasse Reichstein
2011/10/13 13:08:14
Always curly braces around then-branch on multi-li
ulan
2011/10/13 13:43:18
Done.
|
| + fail(NULL, "ERROR: exception type must follow 'throws'.\n"); |
|
Lasse Reichstein
2011/10/13 13:08:14
This changes the command line to require the excep
ulan
2011/10/13 13:43:18
Yep, didn't notice that it is optional.
I prefer t
|
| + expects.type = argv[arg_index]; |
| + ++arg_index; |
| + if (argc > arg_index && !IsFlag(argv[arg_index])) { |
| + expects.beg_pos = atoi(argv[arg_index]); // NOLINT |
| + ++arg_index; |
| + if (argc > arg_index && !IsFlag(argv[arg_index])) { |
| + expects.end_pos = atoi(argv[arg_index]); // NOLINT |
| } |
| } |
| } |
| @@ -309,6 +296,7 @@ int main(int argc, const char* argv[]) { |
| // Format: preparser (<scriptfile> | -e "<source>") |
| // ["throws" [<exn-type> [<start> [<end>]]]] |
| // Any flags (except an initial -s) are ignored. |
|
Lasse Reichstein
2011/10/13 13:08:14
"-s" should probably be "-e". Mea culpa :)
ulan
2011/10/13 13:43:18
Done.
|
| + // Flags must not separate "throws" and its arguments. |
|
Lasse Reichstein
2011/10/13 13:08:14
Yes, that's perfectly fine. No good reason to allo
|
| // Check for mandatory filename argument. |
| int arg_index = 1; |