From a8ad56bd5cf29bd80eee4e22bd301d0a0b76d5e1 Mon Sep 17 00:00:00 2001 From: Stephen Flores Date: Mon, 19 Dec 2011 14:14:14 -0800 Subject: [PATCH] 6990617: Regular expression doesn't match if unicode character next to a digit Updated RemoveQEQuotation() to deal with this case correctly Reviewed-by: sherman --- .../classes/java/util/regex/Pattern.java | 21 ++++++++++- jdk/test/java/util/regex/RegExTest.java | 37 ++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/util/regex/Pattern.java b/jdk/src/share/classes/java/util/regex/Pattern.java index d89eca9845d..626d5b08657 100644 --- a/jdk/src/share/classes/java/util/regex/Pattern.java +++ b/jdk/src/share/classes/java/util/regex/Pattern.java @@ -1583,13 +1583,26 @@ loop: for(int x=0, offset=0; x 0) + if (failCount > 0) { failure = true; + + if (firstFailure == null) { + firstFailure = testName; + } + } + failCount = 0; } @@ -295,6 +306,22 @@ public class RegExTest { Matcher matcher = pattern.matcher("\ud834\udd22"); if (!matcher.find()) failCount++; + + report("Surrogate pair in Unicode escape"); + } + + // This is for bug6990617 + // Test if Pattern.RemoveQEQuoting works correctly if the octal unicode + // char encoding is only 2 or 3 digits instead of 4 and the first quoted + // char is an octal digit. + private static void removeQEQuotingTest() throws Exception { + Pattern pattern = + Pattern.compile("\\011\\Q1sometext\\E\\011\\Q2sometext\\E"); + Matcher matcher = pattern.matcher("\t1sometext\t2sometext"); + if (!matcher.find()) + failCount++; + + report("Remove Q/E Quoting"); } // This is for bug 4988891