Revision: 9617
Author:   [email protected]
Date:     Fri Oct 14 00:34:45 2011
Log:      Ignore flags with arguments in preparser-process.

Currently, preparser-process crashes when given flags with arguments (e.g. --gc_interval 10). It can be fixed by ignoring everything in the command line except the "throws" command and its immediate arguments. This assumes that no flags appear between "throws" and its arguments.

TEST=make ia32.release.check TESTFLAGS="preparser --special-command=\"@ --gc_interval 10\""

Review URL: http://codereview.chromium.org/8268004
http://code.google.com/p/v8/source/detail?r=9617

Modified:
 /branches/bleeding_edge/preparser/preparser-process.cc

=======================================
--- /branches/bleeding_edge/preparser/preparser-process.cc Fri Jul 15 05:13:29 2011 +++ /branches/bleeding_edge/preparser/preparser-process.cc Fri Oct 14 00:34:45 2011
@@ -267,34 +267,22 @@


 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)) {
+    arg_index++;
+  }
   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.
+    arg_index++;
+    if (argc > arg_index && !IsFlag(argv[arg_index])) {
       expects.type = argv[arg_index];
-      do {
-        arg_index++;
-      } while (argc > arg_index && IsFlag(argv[arg_index]));
-      if (argc > arg_index) {
+      arg_index++;
+      if (argc > arg_index && !IsFlag(argv[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) {
+        arg_index++;
+        if (argc > arg_index && !IsFlag(argv[arg_index])) {
           expects.end_pos = atoi(argv[arg_index]);  // NOLINT
         }
       }
@@ -308,7 +296,8 @@
   // Parse command line.
   // Format:  preparser (<scriptfile> | -e "<source>")
   //                    ["throws" [<exn-type> [<start> [<end>]]]]
-  // Any flags (except an initial -s) are ignored.
+  // Any flags (except an initial -e) are ignored.
+  // Flags must not separate "throws" and its arguments.

   // Check for mandatory filename argument.
   int arg_index = 1;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to