mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Pathces from Frith-MacDonald, Yamato, Jenkins.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2709 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49be21f6c3
commit
142cab5d90
10 changed files with 210 additions and 23 deletions
|
@ -335,12 +335,35 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
|
|||
range.location, range.length);
|
||||
}
|
||||
|
||||
// xxx This should be primitive method
|
||||
- (void) replaceCharactersInRange: (NSRange)range
|
||||
- (void) replaceCharactersInRange: (NSRange)aRange
|
||||
withString: (NSString*)aString
|
||||
{
|
||||
[self deleteCharactersInRange:range];
|
||||
[self insertString:aString atIndex:range.location];
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
if (aRange.location > _count)
|
||||
[NSException raise: NSRangeException format:@"Invalid location."];
|
||||
if (aRange.length > (_count - aRange.location))
|
||||
[NSException raise: NSRangeException format:@"Invalid location+length."];
|
||||
if (_count + [aString length] - aRange.length > _capacity)
|
||||
{
|
||||
_capacity += [aString length] - aRange.length;
|
||||
OBJC_REALLOC(_contents_chars, unichar, _capacity);
|
||||
}
|
||||
offset = [aString length] - aRange.length;
|
||||
if (offset > 0)
|
||||
{
|
||||
int first = aRange.location + aRange.length;
|
||||
for (i = self->_count - 1; i >= first; i--)
|
||||
self->_contents_chars[i+offset] = self->_contents_chars[i];
|
||||
}
|
||||
else if (offset < 0)
|
||||
{
|
||||
for (i = aRange.location + aRange.length; i < self->_count; i++)
|
||||
self->_contents_chars[i+offset] = self->_contents_chars[i];
|
||||
}
|
||||
(self->_count) += offset;
|
||||
[aString getCharacters: &self->_contents_chars[aRange.location]];
|
||||
}
|
||||
|
||||
// xxx Check this
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue