harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r475869 - in /incubator/harmony/enhanced/classlib/trunk/modules/regex/src: main/java/java/util/regex/Lexer.java test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
Date Thu, 16 Nov 2006 18:57:48 GMT
Author: pyang
Date: Thu Nov 16 10:57:47 2006
New Revision: 475869

URL: http://svn.apache.org/viewvc?view=rev&rev=475869
Log:
Apply patch for HARMONY-2127 ([classlib][regex] harmony does not compile embedded flag (?c))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/Lexer.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/Lexer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/Lexer.java?view=diff&rev=475869&r1=475868&r2=475869
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/Lexer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/Lexer.java
Thu Nov 16 10:57:47 2006
@@ -1093,8 +1093,7 @@
                 return res | (1 << 8);
                 
             default:
-                throw new PatternSyntaxException(Messages.getString("regex.1A"), //$NON-NLS-1$
-                                               this.toString(), index);
+                // ignore invalid flags (HARMONY-2127)
             }
             nextIndex();
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java?view=diff&rev=475869&r1=475868&r2=475869
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
Thu Nov 16 10:57:47 2006
@@ -31,7 +31,10 @@
 			"(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)*",
 			"(a|b)*(a|b)*A(a|b)*lice.*",
 			"(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)(a|b|c|d|e|f|g|h|"
-					+ "i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)*(1|2|3|4|5|6|7|8|9|0)*|while|for|struct|if|do"
+					+ "i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)*(1|2|3|4|5|6|7|8|9|0)*|while|for|struct|if|do",
+             "x(?c)y",
+             "x(?cc)y",
+             "x(?:c)y"                
 
 	};
 
@@ -322,38 +325,49 @@
 		 */
 		String pattern = "b)a";
 		try {
-			Pattern pat = Pattern.compile(pattern);
+			Pattern.compile(pattern);
+            fail("Expected a PatternSyntacException when compiling pattern: " + pattern);
 		} catch (PatternSyntaxException e) {
-			System.out.println(e);
+			// pass
 		}
 		pattern = "bcde)a";
 		try {
-			Pattern pat = Pattern.compile(pattern);
+			Pattern.compile(pattern);
+            fail("Expected a PatternSyntacException when compiling pattern: " + pattern);
 		} catch (PatternSyntaxException e) {
-			System.out.println(e);
+			// pass
 		}
 		pattern = "bbg())a";
 		try {
 			Pattern pat = Pattern.compile(pattern);
+            fail("Expected a PatternSyntacException when compiling pattern: " + pattern);
 		} catch (PatternSyntaxException e) {
-			System.out.println(e);
+			// pass
 		}
 
 		pattern = "cdb(?i))a";
 		try {
 			Pattern pat = Pattern.compile(pattern);
-		} catch (Exception e) {
-			System.out.println(e);
+            fail("Expected a PatternSyntacException when compiling pattern: " + pattern);
+		} catch (PatternSyntaxException e) {
+			// pass
 		}
+        
+        /*
+         * This pattern should compile - HARMONY-2127
+         */
+        pattern = "x(?c)y";
+        Pattern.compile(pattern);
+
 
 		/*
 		 * this pattern doesn't match any string, but should be compiled anyway
 		 */
 		pattern = "(b\\1)a";
-		Pattern pat = Pattern.compile(pattern);
+		Pattern.compile(pattern);
 
 	}
-
+    
 	/*
 	 * Class under test for Pattern compile(String)
 	 */
@@ -403,7 +417,10 @@
 								+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" },
 				{ "ababbaAabababblice", "ababbaAliceababab", "ababbAabliceaaa",
 						"abbbAbbbliceaaa", "Alice" },
-				{ "a123", "bnxnvgds156", "for", "while", "if", "struct" }
+				{ "a123", "bnxnvgds156", "for", "while", "if", "struct" },
+                { "xy" },
+                { "xy" },
+                { "xcy" }
 
 		};
 
@@ -414,7 +431,7 @@
 						posSeq[i][j]));
 			}
 		}
-	}
+  	}
 
 	public void testTimeZoneIssue() {
 		Pattern p = Pattern.compile("GMT(\\+|\\-)(\\d+)(:(\\d+))?");



Mime
View raw message