Make more tolerant by accepting nil as input for replacing characters in range.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9053 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2001-02-08 17:12:40 +00:00
parent 087c35f0f9
commit 11fbedeedf
2 changed files with 17 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2001-02-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSString.m: permit nil string when replacing characters
in range. Treat as an empty string rather than raising exception.
2001-02-07 Jonathan Gapen <jagapen@home.com>
* Source/NSFileManager.m: Make disk space report work on FreeBSD.

View file

@ -2581,13 +2581,19 @@ transmute(ivars self, NSString *aString)
GS_RANGE_CHECK(aRange, _count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"replace characters with nil string"];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"replace characters with non-string"];
{
length = 0;
}
else if (GSObjCIsInstance(aString) == NO)
{
[NSException raise: NSInvalidArgumentException
format: @"replace characters with non-string"];
}
else
{
length = (aString == nil) ? 0 : [aString length];
}
length = (aString == nil) ? 0 : [aString length];
offset = length - aRange.length;
if (offset < 0)