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: Fix MessageFormat parsing bug


I checked this in on the trunk, with Tom's approval.

This patch fixes the following MessageFormat parsing bug:
http://lists.gnu.org/archive/html/classpath/2005-06/msg00014.html

The corresponding Mauve test is:
gnu.testlet.java.text.MessageFormat.parse: greedy string matching at end

-- 
Ziga

2005-06-08  Ziga Mahkovec  <ziga.mahkovec@klika.si>

	* java/text/MessageFormat.java (parse): When parsing strings, check
	for an empty pattern trailer.

Index: java/text/MessageFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/MessageFormat.java,v
retrieving revision 1.19
diff -u -p -r1.19 MessageFormat.java
--- java/text/MessageFormat.java	24 May 2005 18:07:38 -0000	1.19
+++ java/text/MessageFormat.java	6 Jun 2005 20:44:35 -0000
@@ -658,7 +658,11 @@ public class MessageFormat extends Forma
 	  {
 	    // We have a String format.  This can lose in a number
 	    // of ways, but we give it a shot.
-	    int next_index = sourceStr.indexOf(elements[i].trailer, index);
+	    int next_index;
+	    if (elements[i].trailer.length() > 0)
+	      next_index = sourceStr.indexOf(elements[i].trailer, index);
+	    else
+	      next_index = sourceStr.length();
 	    if (next_index == -1)
 	      {
 		pos.setErrorIndex(index);



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