PatchSet 5872 
Date: 2005/01/18 15:23:53
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: MessageFormat fixes

2005-01-18  Dalibor Topic  <[EMAIL PROTECTED]>

Resynced with GNU Classpath.

2005-01-17  Tom Tromey  <[EMAIL PROTECTED]>

* java/text/MessageFormat.java (scanString): Changed how quoting
is handled.
(scanFormatElement): Likewise.

Members: 
        ChangeLog:1.3413->1.3414 
        libraries/javalib/java/text/MessageFormat.java:1.33->1.34 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3413 kaffe/ChangeLog:1.3414
--- kaffe/ChangeLog:1.3413      Tue Jan 18 15:18:42 2005
+++ kaffe/ChangeLog     Tue Jan 18 15:23:53 2005
@@ -2,6 +2,16 @@
 
        Resynced with GNU Classpath.
        
+       2005-01-17  Tom Tromey  <[EMAIL PROTECTED]>
+
+       * java/text/MessageFormat.java (scanString): Changed how quoting
+       is handled.
+       (scanFormatElement): Likewise.
+
+2005-01-18  Dalibor Topic  <[EMAIL PROTECTED]>
+
+       Resynced with GNU Classpath.
+       
        2005-01-17  Michael Koch  <[EMAIL PROTECTED]>
 
        PR libgcj/19444
Index: kaffe/libraries/javalib/java/text/MessageFormat.java
diff -u kaffe/libraries/javalib/java/text/MessageFormat.java:1.33 
kaffe/libraries/javalib/java/text/MessageFormat.java:1.34
--- kaffe/libraries/javalib/java/text/MessageFormat.java:1.33   Fri Dec 10 
23:16:05 2004
+++ kaffe/libraries/javalib/java/text/MessageFormat.java        Tue Jan 18 
15:23:58 2005
@@ -1,5 +1,5 @@
 /* MessageFormat.java - Localized message formatting.
-   Copyright (C) 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -193,27 +193,36 @@
   {
     int max = pat.length();
     buffer.setLength(0);
+    boolean quoted = false;
     for (; index < max; ++index)
       {
        char c = pat.charAt(index);
-       if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
+       if (quoted)
          {
-           buffer.append(pat.charAt(index + 1));
-           index += 2;
+           // In a quoted context, a single quote ends the quoting.
+           if (c == '\'')
+             quoted = false;
+           else
+             buffer.append(c);
          }
-       else if (c == '\'' && index + 1 < max
-                && pat.charAt(index + 1) == '\'')
+       // Check for '', which is a single quote.
+       else if (c == '\'' && index + 1 < max && pat.charAt(index + 1) == '\'')
          {
            buffer.append(c);
            ++index;
          }
+       else if (c == '\'')
+         {
+           // Start quoting.
+           quoted = true;
+         }
        else if (c == '{')
          break;
-       else if (c == '}')
-         throw new IllegalArgumentException("Found '}' without '{'");
        else
          buffer.append(c);
       }
+    // Note that we explicitly allow an unterminated quote.  This is
+    // done for compatibility.
     return index;
   }
 
@@ -225,39 +234,42 @@
     int max = pat.length();
     buffer.setLength(0);
     int brace_depth = 1;
+    boolean quoted = false;
 
     for (; index < max; ++index)
       {
        char c = pat.charAt(index);
-       if (c == '\'' && index + 2 < max && pat.charAt(index + 2) == '\'')
+       // First see if we should turn off quoting.
+       if (quoted)
          {
-           buffer.append(c);
-           buffer.append(pat.charAt(index + 1));
-           buffer.append(c);
-           index += 2;
+           if (c == '\'')
+             quoted = false;
+           // In both cases we fall through to inserting the
+           // character here.
          }
+       // See if we have just a plain quote to insert.
        else if (c == '\'' && index + 1 < max
                 && pat.charAt(index + 1) == '\'')
          {
            buffer.append(c);
            ++index;
          }
+       // See if quoting should turn on.
+       else if (c == '\'')
+         quoted = true;
        else if (c == '{')
-         {
-           buffer.append(c);
-           ++brace_depth;
-         }
+         ++brace_depth;
        else if (c == '}')
          {
            if (--brace_depth == 0)
              break;
-           buffer.append(c);
          }
        // Check for TERM after braces, because TERM might be `}'.
        else if (c == term)
          break;
-       else
-         buffer.append(c);
+       // All characters, including opening and closing quotes, are
+       // inserted here.
+       buffer.append(c);
       }
     return index;
   }

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to