harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r766655 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Scanner.java test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
Date Mon, 20 Apr 2009 11:25:19 GMT
Author: tellison
Date: Mon Apr 20 11:25:19 2009
New Revision: 766655

URL: http://svn.apache.org/viewvc?rev=766655&view=rev
Log:
Apply patch for HARMONY-6087 ([luni] java.util.Scanner behaves differently with RI while parsing
specific pattern )

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Scanner.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Scanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Scanner.java?rev=766655&r1=766654&r2=766655&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Scanner.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Scanner.java Mon
Apr 20 11:25:19 2009
@@ -372,10 +372,12 @@
          * bug is fixed.
          */
         int oldLimit = buffer.limit();
-        buffer.limit(horizonLineSeparator);
+        // Considering the look ahead feature, the line terminator should be involved as
RI
+        buffer.limit(horizonLineSeparator + terminatorLength);
         // ========== To deal with regex bug ====================
 
-        matcher.region(findStartIndex, horizonLineSeparator);
+        // Considering the look ahead feature, the line terminator should be involved as
RI
+        matcher.region(findStartIndex, horizonLineSeparator + terminatorLength);
         if (matcher.find()) {
             // The scanner advances past the input that matched
             findStartIndex = matcher.end();
@@ -384,6 +386,18 @@
             if (horizonLineSeparator == matcher.end()) {
                 findStartIndex += terminatorLength;
             }
+            // the line terminator itself should not be a part of
+            // the match result according to the Spec
+            if (horizonLineSeparator != bufferLength
+                    && (horizonLineSeparator + terminatorLength == matcher
+                            .end())) {
+                // ========== To deal with regex bug ====================
+                buffer.limit(oldLimit);
+                // ========== To deal with regex bug ====================
+
+                matchSuccessful = false;
+                return null;
+            }
             matchSuccessful = true;
 
             // ========== To deal with regex bug ====================

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java?rev=766655&r1=766654&r2=766655&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
Mon Apr 20 11:25:19 2009
@@ -5154,6 +5154,10 @@
         result = s.findInLine("est");
         // RI fails. It is a RI's bug.
         assertNull(result);
+        
+        s = new Scanner( "   *\n");
+        result = s.findInLine(Pattern.compile( "^\\s*(?:\\*(?=[^/]))"));
+        assertEquals("   *", result);
     }
 
     /**



Mime
View raw message