mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
([NSString -substringFromRange:]): Raise correct exceptions.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1666 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f7d7053b71
commit
0412ab7dce
1 changed files with 7 additions and 2 deletions
|
@ -484,8 +484,13 @@ handle_printf_atsign (FILE *stream,
|
|||
- (NSString*) substringFromRange: (NSRange)aRange
|
||||
{
|
||||
unichar buffer[aRange.length];
|
||||
[self getCharacters:buffer range:aRange];
|
||||
return [[self class] stringWithCharacters:buffer length:aRange.length];
|
||||
|
||||
if (aRange.location > _count)
|
||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||
if (aRange.length > (_count - aRange.location))
|
||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||
[self getCharacters: buffer range: aRange];
|
||||
return [[self class] stringWithCharacters: buffer length: aRange.length];
|
||||
}
|
||||
|
||||
- (NSString*) substringToIndex: (unsigned int)index
|
||||
|
|
Loading…
Reference in a new issue