I'm checking this in.

This fixes PR 28658.  I've already checked in the mauve test case.
Anthony tells me that this bug was revealed by the jetty test suite.

I took a fairly conservative interpretation here.

Tom

2006-08-09  Tom Tromey  <[EMAIL PROTECTED]>

        PR classpath/28658:
        * java/text/SimpleDateFormat.java (parse): Let an unquoted space in
        the pattern match any number of spaces in the text.

Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/SimpleDateFormat.java,v
retrieving revision 1.53
diff -u -r1.53 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java     8 May 2006 13:19:22 -0000       1.53
+++ java/text/SimpleDateFormat.java     9 Aug 2006 19:34:42 -0000
@@ -917,7 +917,25 @@
                || ((ch < 'a' || ch > 'z')
                    && (ch < 'A' || ch > 'Z')))
              {
-               if (! expect (dateStr, pos, ch))
+                if (quote_start == -1 && ch == ' ')
+                  {
+                    // A single unquoted space in the pattern may match
+                    // any number of spaces in the input.
+                    int index = pos.getIndex();
+                    int save = index;
+                    while (index < dateStr.length()
+                           && Character.isWhitespace(dateStr.charAt(index)))
+                      ++index;
+                    if (index > save)
+                      pos.setIndex(index);
+                    else
+                      {
+                        // Didn't see any whitespace.
+                        pos.setErrorIndex(index);
+                        return null;
+                      }
+                  }
+                else if (! expect (dateStr, pos, ch))
                  return null;
                continue;
              }

Reply via email to