Bug 2335 - POST-RELEASE: Bugs in StringMatcher (1GET09O)
Summary: POST-RELEASE: Bugs in StringMatcher (1GET09O)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:34 EDT by Nick Edgar CLA
Modified: 2001-12-14 15:41 EST (History)
0 users

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:34:21 EDT
There are two bugs in StringMatcher.

match(...) should match the whole string.  find(...) can find any occurrence.
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;

NOTES:

NE (9/28/01 12:16:59 PM)
	See also 1GKQ0XA: ITPJUI:WINNT - Text search for 'ß' gives results for 's'
	Should add test case for:
		"uß".toUpperCase() -> "USS"
	Another example, from http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
		"MASSE" and "Maße" 
	See http://www.unicode.org/unicode/reports/tr21/
	for discussion on case mappings.

NE (10/2/01 2:24:13 PM)
	Fixed in > 202a, for StringMatcher in org.eclipse.ui.views.navigator.
Comment 1 DJ Houghton CLA 2001-10-29 18:20:59 EST
PRODUCT VERSION:
117

Comment 2 Nick Edgar CLA 2001-12-14 15:41:39 EST
Fixed in >202a