Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125631 Details for
Bug 264816
[search] AIOOBE in StringOperation.getPatternMatchingRegions(..) with pattern "?*"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch+tests
v01.txt (text/plain), 4.52 KB, created by
Frederic Fusier
on 2009-02-13 07:53:18 EST
(
hide
)
Description:
Proposed patch+tests
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-02-13 07:53:18 EST
Size:
4.52 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/internal/core/search/StringOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/StringOperation.java,v >retrieving revision 1.1 >diff -u -r1.1 StringOperation.java >--- search/org/eclipse/jdt/internal/core/search/StringOperation.java 12 Feb 2009 15:27:02 -0000 1.1 >+++ search/org/eclipse/jdt/internal/core/search/StringOperation.java 13 Feb 2009 12:40:21 -0000 >@@ -18,6 +18,8 @@ > */ > public final class StringOperation { > >+ private final static int[] EMPTY_REGIONS = new int[0]; >+ > /** > * Answers all the regions in a given name matching a given camel case pattern. > * </p><p> >@@ -85,8 +87,11 @@ > > if (name == null) > return null; // null name cannot match >- if (pattern == null) >- return new int[] { patternStart, patternEnd-patternStart }; // null pattern is equivalent to '*' >+ if (pattern == null) { >+ // null pattern cannot match any region >+ // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816 >+ return EMPTY_REGIONS; >+ } > if (patternEnd < 0) patternEnd = pattern.length(); > if (nameEnd < 0) nameEnd = name.length(); > >@@ -293,9 +298,10 @@ > */ > > if (name == null) return null; // null name cannot match >- if (pattern == null || pattern.equals("*")) { //$NON-NLS-1$ >- // null and '*' patterns match the entire name >- return new int[] { nameStart, nameEnd-nameStart }; >+ if (pattern == null) { >+ // null pattern cannot match any region >+ // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=264816 >+ return EMPTY_REGIONS; > } > int iPattern = patternStart; > int iName = nameStart; >@@ -329,6 +335,10 @@ > } > previous = ch; > } >+ if (parts == 0) { >+ if (questions <= (nameEnd - nameStart)) return EMPTY_REGIONS; >+ return null; >+ } > int[] segments = new int[parts*2]; > > /* check first segment */ >Index: search/org/eclipse/jdt/core/search/SearchPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java,v >retrieving revision 1.80 >diff -u -r1.80 SearchPattern.java >--- search/org/eclipse/jdt/core/search/SearchPattern.java 12 Feb 2009 15:27:02 -0000 1.80 >+++ search/org/eclipse/jdt/core/search/SearchPattern.java 13 Feb 2009 12:40:21 -0000 >@@ -732,7 +732,9 @@ > * pattern match behavior > * > * @param pattern the given pattern. If <code>null</code>, >- * then the returned region will be the entire given name. >+ * then an empty region (<code>new int[0]</code>) will be returned to let >+ * the client know that the name matches the pattern but no common >+ * character has been found. > * @param name the given name > * @param matchRule the rule to apply for the comparison.<br> > * The following values are accepted: >@@ -762,15 +764,16 @@ > * <li>etc.</li> > * </ul> > * @return an array of <code>int</code> having two slots per returned >- * regions: the first one is the region starting index and the second one >- * is the region length. >+ * regions (the first one is the region starting index and the second one >+ * is the region length or <code>null</code> if the given name does not >+ * match the given pattern). > * <p> >- * The returned region may be the entire given name if the given pattern >- * is either <code>null</code> (whatever the match rule is) or >- * <code>'*'</code> with a pattern match rule. >- * </p><p> >- * May also be <code>null</code> if the given name does not match >- * the given pattern. >+ * The returned regions may be empty (<code>new int[0]</code>) if the >+ * pattern is <code>null</code> (whatever the match rule is). The returned >+ * regions will also be empty if the pattern is only made of <code>'?'</code> >+ * and/or <code>'*'</code> character(s) (e.g. <code>'*'</code>, >+ * <code>'?*'</code>, <code>'???'</code>, etc.) when using a pattern >+ * match rule. > * </p> > * > * @since 3.5 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java,v >retrieving revision 1.1 >diff -u -r1.1 MatchingRegionsTest.java >Binary files /tmp/cvsvckTVT and MatchingRegionsTest.java differ
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 264816
:
125623
| 125631