Bug 2382 - Need to give StringMatcher a home (1GEV0QW)
Summary: Need to give StringMatcher a home (1GEV0QW)
Status: RESOLVED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Components (show other bugs)
Version: 3.6   Edit
Hardware: All Windows 98
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: equinox.components-inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 12214 269424 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-10 22:35 EDT by Nick Edgar CLA
Modified: 2020-10-03 16:20 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2001-10-10 22:35:18 EDT
There are currently 7 copies of StringMatcher in the environment.
It needs to be given a proper home, ideally in Core.
Should coordinate with JM after the release to do this.

NOTES:

Email trace:

NE says:
Actually, this is a bug after all.

match(...) should match the whole string.  If you want to do a substring search, use find(...), which can find any occurrence (and gives you its position).

For match(...), a pattern of "" should only match the empty string.
For example: new StringMatcher("ab", false, false).match("abz") is false,
so new StringMatcher("", false, false).match("z") should be false too, but it's currently true.

This is due to the segCount == 0 test, which should check whether there are actually wildcards before returning true.
The next two tests check for empty target and empty pattern, but they're not currently reached.

I also noticed another bug, where if ignoreWildcards is true, it doesn't check the length.
So new StringMatcher("a", false, true).match("ab") currently returns true, but it should return false.

The corrected lines are:
		if (fIgnoreWildCards)
			return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
		int segCount = fSegments.length;
		if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar))  // pattern contains only '*'(s)
			return true;

I've filed 1GET09O: ITPUI:WIN2000 - Bugs in StringMatcher
but have not released the fix since we are frozen.

EG says:
As of the 118 we have 7 copies of the StringMatcher class in the system and
we would have to fix 7 classes, this is insane. We should rather make the class availble for general use and fix it once.

JW says:
This is the problem that we feared.  There is no API here, so we have N copies.  A bug is discovered late, and now everyone is scrambling.

The only possible home for this is core.  We should look at making this occur next time if we can't do anything about it now.  
(It is reasonable to believe that the implementation will want to improve over time - this is also a problem with 7 copies)

JM says:
I am happy to host a utils plugin (eg., org.eclipse.utils).  I do not want to be the one to integrate or test or fix unless it is code that I supplied.

I am willing to make this happen today.  Just let me know.

JW says:
We should do this.  Please get the correct implementation from NE.   Clients should then use your implementation 
once they can transition (or live temporarily with the incorrect one).

NE says:
Just to clarify here, that nobody is actually affected by this bug currently.  It's only when you create an empty pattern.  
James has a workaround for his situation.
None of the 7 copies are API.
So I think we should hold off, and do it after the release.

JW says:
I am glad to hold off if no change is necessary (to any of the StringMatcher implementations).  
If any change is necessary (or likely necessary), we should move now.
Given NE's comments, I assume no change is necessary given James' workaround.
(After 0.9, we should address this promptly)

JM says:
We have an adequate and safe workaround in our code and need no fix at this time.
Comment 1 DJ Houghton CLA 2001-10-29 18:24:22 EST
PRODUCT VERSION:
118

Comment 2 Nick Edgar CLA 2002-01-31 21:32:22 EST
Waiting for regexp support in JDK 1.4.
Comment 3 Tod Creasey CLA 2006-04-13 15:25:18 EDT
*** Bug 12214 has been marked as a duplicate of this bug. ***
Comment 4 Susan McCourt CLA 2009-11-02 11:59:51 EST
Reopening as this has come up again and there are even more copies of StringMatcher than when this was first reported.
Comment 5 Susan McCourt CLA 2009-11-02 12:01:20 EST
*** Bug 269424 has been marked as a duplicate of this bug. ***
Comment 6 Samantha Chan CLA 2011-01-31 17:16:51 EST
Is there any plan of fixing this? 
Is there a StringMatcher API available anywhere?
Comment 7 John Arthorne CLA 2011-02-01 09:41:37 EST
(In reply to comment #6)
> Is there a StringMatcher API available anywhere?

See java.util.regex.Matcher.
Comment 8 Eclipse Genie CLA 2019-12-03 06:51:11 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 9 Thomas Watson CLA 2019-12-03 08:41:46 EST
No plans to address this.