Hi dear list members,
IMHO the following code in NSPredicate.m is wrong:
(line 944 ff.)
NSString *regex;
/* The right hand is a pattern with '?' meaning match one character,
* and '*' meaning match zero or more characters, so translate that
* into a regex.
*/
regex = [rightResult stringByReplacingOccurrencesOfString: @"*"
withString: @".*"];
// wrong!
regex = [regex stringByReplacingOccurrencesOfString: @"?"
withString: @".?"];
// wrong!
regex = [NSString stringWithFormat: @"^%@$", regex];
return GSICUStringMatchesRegex(leftResult, regex, compareOptions);
In case the caller wants to use a "*" as a literal (and not as a "joker"
matching any character), the relavant part of the string rightResult
would be
"\*"
This code converts it into
"\.*"
and this will not yield the expected results.
On MacOS the following "Like" predicate matches:
leftResult = "**/*" and rightResult = "\*\*\/\*"
On GNUstep it matches only if the replacements shown above are removed.
So the stringByReplacingOccurrencesOfString calls must replace only
those "*" or "?" in the string that are not escaped. Any objections?
Regards,
Mathias
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep