This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fix -verbose gij option


Thomas Fitzsimmons wrote:

Hi,

This patch fixes problems with parsing gij's -verbose option that I
introduced with my option revamp patch.

OK for mainline and gcc-4_0-branch?

Tom

2005-04-07 Thomas Fitzsimmons <fitzsim@redhat.com>

* prims.cc (parse_verbose_args): Fix verbose argument parsing.



OK for HEAD.


Mark: is this ok for the 4.0 branch? This patch fixes a recent regression in libgcj.

Bryce


------------------------------------------------------------------------

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.3463
diff -u -r1.3463 ChangeLog
--- ChangeLog	6 Apr 2005 22:29:59 -0000	1.3463
+++ ChangeLog	7 Apr 2005 22:25:18 -0000
@@ -1,3 +1,7 @@
+2005-04-07  Thomas Fitzsimmons  <fitzsim@redhat.com>
+
+	* prims.cc (parse_verbose_args): Fix verbose argument parsing.
+
2005-04-06  Andrew Haley  <aph@redhat.com>

	* testsuite/libjava.lang/bytearray.java: New file.
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.109
diff -u -r1.109 prims.cc
--- prims.cc	5 Apr 2005 22:26:22 -0000	1.109
+++ prims.cc	7 Apr 2005 22:25:19 -0000
@@ -1049,7 +1049,7 @@
parse_verbose_args (char* option_string,
                    bool ignore_unrecognized)
{
-  size_t len = sizeof ("-verbose");
+  size_t len = sizeof ("-verbose") - 1;

  if (strlen (option_string) < len)
    return -1;
@@ -1058,69 +1058,72 @@
      && option_string[len + 1] != '\0')
    {
      char* verbose_args = option_string + len + 1;
-      size_t last = 0;

      do
	{
	  if (! strncmp (verbose_args,
-			 "gc", (last = sizeof ("gc")) - 1)
-	      && (verbose_args[last] == '\0'
-		  || verbose_args[last] == ','))
-	    {
-	      // FIXME: we should add functions to boehm-gc that
-	      // toggle GC_print_stats, GC_PRINT_ADDRESS_MAP and
-	      // GC_print_back_height.
-
-	    }
+			 "gc", sizeof ("gc") - 1))
+            {
+              if (verbose_args[sizeof ("gc") - 1] == '\0'
+                  || verbose_args[sizeof ("gc") - 1] == ',')
+                {
+                  // FIXME: we should add functions to boehm-gc that
+                  // toggle GC_print_stats, GC_PRINT_ADDRESS_MAP and
+                  // GC_print_back_height.
+                  verbose_args += sizeof ("gc") - 1;
+                }
+              else
+                {
+                verbose_arg_err:
+                  fprintf (stderr, "libgcj: unknown verbose option: %s\n",
+                           option_string);
+                  return -1;
+                }
+            }
	  else if (! strncmp (verbose_args,
			      "class",
-			      (last = sizeof ("class")) - 1)
-		   && (verbose_args[last] == '\0'
-		       || verbose_args[last] == ','))
-	    {
-	      gcj::verbose_class_flag = true;
-	    }
+			      sizeof ("class") - 1))
+            {
+              if (verbose_args[sizeof ("class") - 1] == '\0'
+                  || verbose_args[sizeof ("class") - 1] == ',')
+                {
+                  gcj::verbose_class_flag = true;
+                  verbose_args += sizeof ("class") - 1;
+                }
+              else
+                goto verbose_arg_err;
+            }
	  else if (! strncmp (verbose_args, "jni",
-			      (last = sizeof ("jni")) - 1)
-		   && (verbose_args[last] == '\0'
-		       || verbose_args[last] == ','))
-	    {
-	      // FIXME: enable JNI messages.
-	    }
+			      sizeof ("jni") - 1))
+            {
+              if (verbose_args[sizeof ("jni") - 1] == '\0'
+                  || verbose_args[sizeof ("jni") - 1] == ',')
+                {
+                  // FIXME: enable JNI messages.
+                  verbose_args += sizeof ("jni") - 1;
+                }
+              else
+                goto verbose_arg_err;
+            }
	  else if (ignore_unrecognized
		   && verbose_args[0] == 'X')
	    {
	      // ignore unrecognized non-standard verbose option
-	      last = 0;
-	      while (verbose_args[last] != '\0'
-		     && verbose_args[last++] != ',');
+	      while (verbose_args[0] != '\0'
+		     && verbose_args[0] != ',')
+                verbose_args++;
	    }
+          else if (verbose_args[0] == ',')
+            {
+              verbose_args++;
+            }
+          else
+            goto verbose_arg_err;

- if (strlen (verbose_args) >= last)
- {
- if (verbose_args[last] == ',')
- {
- if (verbose_args[last + 1] == '\0')
- // trailing comma
- return -1;
- else
- {
- verbose_args = verbose_args + last + 1;
- last = 0;
- }
- }
- // here verbose_args[last] is either '\0' or
- // the first character in the next verbose
- // argument.
- }
- else
- // partial option
- return -1;
-
- // verbose_args[last] will be '\0' here if we're
- // done.
+ if (verbose_args[0] == ',')
+ verbose_args++;
}
- while (verbose_args[last] != '\0');
+ while (verbose_args[0] != '\0');
}
else if (option_string[len] == 'g'
&& option_string[len + 1] == 'c'




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]