Minor fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6289 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-03-16 12:41:01 +00:00
parent 154341cecc
commit b597cab253
3 changed files with 33 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Thu Mar 16 11:37:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSRange.m: NSRangeFromString() bugfix by karl@nfox.com
* Source/NSData.m: ([-hash]) new implementation by karl
Sat Mar 11 21:04:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk> Sat Mar 11 21:04:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* GSDoc/gsdoc.m: Updated for recent version of xml library. * GSDoc/gsdoc.m: Updated for recent version of xml library.

View file

@ -478,7 +478,32 @@ failure:
- (unsigned) hash - (unsigned) hash
{ {
return [self length]; unsigned char buf[64];
unsigned l = [self length];
unsigned ret =0;
l = MIN(l,64);
/*
* hash for empty data matches hash for empty string
*/
if (l == 0)
{
return 0xfffffffe;
}
[self getBytes: &buf range: NSMakeRange(0, l)];
while (l-- > 0)
{
ret = (ret << 5 ) + ret + buf[l];
}
// Again, match NSString
if (ret == 0)
{
ret = 0xffffffff;
}
return ret;
} }
- (BOOL) isEqual: anObject - (BOOL) isEqual: anObject

View file

@ -65,7 +65,7 @@ NSRangeFromString(NSString* string)
&& (*scanStringImp)(scanner, scanStringSel, @"location", NULL) && (*scanStringImp)(scanner, scanStringSel, @"location", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"=", NULL) && (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
&& (*scanIntImp)(scanner, scanIntSel, &range.location) && (*scanIntImp)(scanner, scanIntSel, &range.location)
&& (*scanStringImp)(scanner, scanStringSel, @";", NULL) && (*scanStringImp)(scanner, scanStringSel, @",", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"length", NULL) && (*scanStringImp)(scanner, scanStringSel, @"length", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"=", NULL) && (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
&& (*scanIntImp)(scanner, scanIntSel, &range.length) && (*scanIntImp)(scanner, scanIntSel, &range.length)
@ -79,7 +79,7 @@ NSString *
NSStringFromRange(NSRange range) NSStringFromRange(NSRange range)
{ {
setupCache(); setupCache();
return [NSStringClass stringWithFormat: @"{location = %d, length = %d}", return [NSStringClass stringWithFormat: @"{location=%d, length=%d}",
range.location, range.length]; range.location, range.length];
} }