Minor string fixes - range checking etc.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7450 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-09-08 17:06:18 +00:00
parent 6fdd577b58
commit 0f11471fdf
4 changed files with 65 additions and 64 deletions

View file

@ -762,6 +762,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
- (void) deleteCharactersInRange: (NSRange)range
{
GS_RANGE_CHECK(range, _count);
stringDecrementCountAndFillHoleAt((NSGMutableStringStruct*)self,
range.location, range.length);
}
@ -828,12 +829,6 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
_hash = 0;
}
- (void) removeRange: (NSRange)range
{
stringDecrementCountAndFillHoleAt((NSGMutableStringStruct*)self,
range.location, range.length);
}
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned cap;
@ -856,31 +851,4 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
return unitochar(_contents_chars[index]);
}
// FOR IndexedCollection and OrderedCollection SUPPORT;
- (void) insertObject: newObject atIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count+1);
// one for the next char, one for the '\0';
if (_count >= _capacity)
{
_capacity = _count;
if (_capacity < 2)
_capacity = 2;
_contents_chars =
NSZoneRealloc(_zone, _contents_chars, sizeof(unichar)*_capacity);
}
stringIncrementCountAndMakeHoleAt((NSGMutableStringStruct*)self, index, 1);
_contents_chars[index] = [newObject charValue];
}
- (void) removeObjectAtIndex: (unsigned)index
{
CHECK_INDEX_RANGE_ERROR(index, _count);
stringDecrementCountAndFillHoleAt((NSGMutableStringStruct*)self, index, 1);
}
@end