mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Fixed [NSString isEqualToString:] so that it does not depend on the layout of either string. This fixes the case when the parameter is a proxy, and the case when self is a subclass that does not use the GSString layout.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30595 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5f3c8920bd
commit
c4bc2cdcf2
1 changed files with 25 additions and 4 deletions
|
@ -2175,12 +2175,33 @@ handle_printf_atsign (FILE *stream,
|
|||
*/
|
||||
- (BOOL) isEqualToString: (NSString*)aString
|
||||
{
|
||||
NSUInteger len;
|
||||
unichar selfBuffer[32];
|
||||
unichar otherBuffer[32];
|
||||
NSRange r = {0, 32};
|
||||
|
||||
if ([self hash] != [aString hash])
|
||||
return NO;
|
||||
if (strCompNsNs(self, aString, 0, (NSRange){0, [self length]})
|
||||
== NSOrderedSame)
|
||||
return YES;
|
||||
return NO;
|
||||
|
||||
len = [self length];
|
||||
if (len != [aString length])
|
||||
return NO;
|
||||
|
||||
while (r.location < len)
|
||||
{
|
||||
if (r.location + r.length > len)
|
||||
{
|
||||
r.length = len - r.location;
|
||||
}
|
||||
[self getCharacters: selfBuffer range: r];
|
||||
[aString getCharacters: otherBuffer range: r];
|
||||
if (memcmp(selfBuffer, otherBuffer, r.length) != 0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
r.location += r.length;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue