Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2020-04-23 10:18:28 +0000
committerThomas Wolf2020-05-04 16:02:58 +0000
commit3ccf63dfa981d29d65b9e57f7b73fa1071c56819 (patch)
treee3bcf54b4f4e2fcf27d622ec9b24c7793334d2ea
parentc6438d916498d3054124eee77ca589ca7a053728 (diff)
downloadrt.equinox.bundles-3ccf63dfa981d29d65b9e57f7b73fa1071c56819.tar.gz
rt.equinox.bundles-3ccf63dfa981d29d65b9e57f7b73fa1071c56819.tar.xz
rt.equinox.bundles-3ccf63dfa981d29d65b9e57f7b73fa1071c56819.zip
Bug 508611 - Fix StringMatcher for patterns ending in \\*I20200505-1800I20200504-1800
Set fHasTrailingStar only to true if the pattern really has an un-escaped * at the end. The previous code handled cases with an even number of backslashes before the * incorrectly. Change-Id: I0709f86faf6b8f68d7b73291cd7bb15fa65b0bc8 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--bundles/org.eclipse.equinox.common.tests/resources/org/eclipse/equinox/common/tests/text/StringMatcherWildcardTest.txt10
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/text/StringMatcher.java9
2 files changed, 8 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.common.tests/resources/org/eclipse/equinox/common/tests/text/StringMatcherWildcardTest.txt b/bundles/org.eclipse.equinox.common.tests/resources/org/eclipse/equinox/common/tests/text/StringMatcherWildcardTest.txt
index c517aa6c6..2c136d9ad 100644
--- a/bundles/org.eclipse.equinox.common.tests/resources/org/eclipse/equinox/common/tests/text/StringMatcherWildcardTest.txt
+++ b/bundles/org.eclipse.equinox.common.tests/resources/org/eclipse/equinox/common/tests/text/StringMatcherWildcardTest.txt
@@ -44,11 +44,11 @@ false foo\* foo* true
false foo\* foobar false
false foo\\* foo* false
-# Skip for StringMatcher: even number of backslashes followed by * at the end of the pattern
-#false foo\\* foo\* true
-#false foo\\* foo\a true
-#false foo\\* foo\\* true
-#false foo\\* foo\\a true
+# Even number of backslashes followed by * at the end of the pattern
+false foo\\* foo\* true
+false foo\\* foo\a true
+false foo\\* foo\\* true
+false foo\\* foo\\a true
false foo\\* foo\ true
false foo\? foo? true
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/text/StringMatcher.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/text/StringMatcher.java
index 60ca8633f..5183ff9db 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/text/StringMatcher.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/text/StringMatcher.java
@@ -343,12 +343,6 @@ public final class StringMatcher {
if (fPattern.startsWith("*")) { //$NON-NLS-1$
fHasLeadingStar = true;
}
- if (fPattern.endsWith("*")) { //$NON-NLS-1$
- // Make sure it's not an escaped wildcard
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar = true;
- }
- }
List<String> temp = new ArrayList<>();
@@ -380,6 +374,9 @@ public final class StringMatcher {
fBound += buf.length();
buf.setLength(0);
}
+ if (pos >= fLength) {
+ fHasTrailingStar = true;
+ }
break;
case '?' :
// Append special character representing single match wildcard

Back to the top