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]

Patch: FYI: java.text bug fix


I'm checking this in.

This fixes a bug reported to the Classpath bug-tracking system, plus
another buglet revealed by the test case.  I've added the test case to
Mauve.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	David Hovemeyer  <daveho@cs.umd.edu>

	* java/text/ChoiceFormat.java
	(format(double,StringBuffer,FieldPosition)): Fix fencepost error
	in check loop.
	* java/text/MessageFormat.java
	(format(Object[],StringBuffer,FieldPosition): Pass all arguments
	to MessageFormat.

Index: java/text/ChoiceFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/ChoiceFormat.java,v
retrieving revision 1.10
diff -u -r1.10 ChoiceFormat.java
--- java/text/ChoiceFormat.java 15 Jun 2002 18:38:00 -0000 1.10
+++ java/text/ChoiceFormat.java 2 Jul 2002 19:34:18 -0000
@@ -1,5 +1,5 @@
 /* ChoiceFormat.java -- Format over a range of numbers
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -259,14 +259,12 @@
     if (choiceLimits.length == 0)
       return appendBuf;
 
-    int index =  0;
+    int index = 0;
     if (! Double.isNaN(num) && num >= choiceLimits[0])
       {
 	for (; index < choiceLimits.length - 1; ++index)
 	  {
-	    if (choiceLimits[index] <= num
-		&& index != choiceLimits.length - 2
-		&& num < choiceLimits[index + 1])
+	    if (choiceLimits[index] <= num && num < choiceLimits[index + 1])
 	      break;
 	  }
       }
Index: java/text/MessageFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/MessageFormat.java,v
retrieving revision 1.10
diff -u -r1.10 MessageFormat.java
--- java/text/MessageFormat.java 22 Jan 2002 22:40:37 -0000 1.10
+++ java/text/MessageFormat.java 2 Jul 2002 19:34:18 -0000
@@ -1,5 +1,5 @@
 /* MessageFormat.java - Localized message formatting.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -373,17 +373,14 @@
 	    if (formatter instanceof ChoiceFormat)
 	      {
 		StringBuffer buf = new StringBuffer ();
-		// FIXME: don't actually know what is correct here.
-		// Can a sub-format refer to any argument, or just
-		// the single argument passed to it?  Must test
-		// against JDK.
 		formatter.format(thisArg, buf, ignore);
 		MessageFormat mf = new MessageFormat ();
 		mf.setLocale(locale);
 		mf.applyPattern(buf.toString());
-		formatter = mf;
+		mf.format(arguments, appendBuf, ignore);
 	      }
-	    formatter.format(thisArg, appendBuf, ignore);
+	    else
+	      formatter.format(thisArg, appendBuf, ignore);
 	  }
 
 	appendBuf.append(elements[i].trailer);


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