mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
([NSString -substringFromRange:]): Implement it using CString's for
now so we can get it working; (we'll fix everything for Unichar's in the next release). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1690 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
84fa615ff1
commit
f9e121c2f5
1 changed files with 9 additions and 5 deletions
|
@ -206,7 +206,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
+ (NSString*) stringWithCharacters: (const unichar*)chars
|
+ (NSString*) stringWithCharacters: (const unichar*)chars
|
||||||
length: (unsigned int)length
|
length: (unsigned int)length
|
||||||
{
|
{
|
||||||
[self notImplemented:_cmd];
|
[self notImplemented:_cmd];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,15 +483,19 @@ handle_printf_atsign (FILE *stream,
|
||||||
|
|
||||||
- (NSString*) substringFromRange: (NSRange)aRange
|
- (NSString*) substringFromRange: (NSRange)aRange
|
||||||
{
|
{
|
||||||
unichar buffer[aRange.length];
|
char buffer[aRange.length];
|
||||||
int count = [self length];
|
int count = [self length];
|
||||||
|
|
||||||
if (aRange.location > count)
|
if (aRange.location > count)
|
||||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||||
if (aRange.length > (count - aRange.location))
|
if (aRange.length > (count - aRange.location))
|
||||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||||
[self getCharacters: buffer range: aRange];
|
/* This will only DTRT for CString's... but that's all we have right now. */
|
||||||
return [[self class] stringWithCharacters: buffer length: aRange.length];
|
[self getCString: buffer
|
||||||
|
maxLength: aRange.length
|
||||||
|
range: aRange
|
||||||
|
remainingRange: NULL];
|
||||||
|
return [[self class] stringWithCString: buffer length: aRange.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) substringToIndex: (unsigned int)index
|
- (NSString*) substringToIndex: (unsigned int)index
|
||||||
|
@ -933,7 +937,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* xxx check to make sure aRange is within self; raise NSStringBoundsError */
|
/* xxx check to make sure aRange is within self; raise NSStringBoundsError */
|
||||||
assert(aRange.location + aRange.length < [self cStringLength]);
|
assert(aRange.location + aRange.length <= [self cStringLength]);
|
||||||
if (maxLength < aRange.length)
|
if (maxLength < aRange.length)
|
||||||
{
|
{
|
||||||
len = maxLength;
|
len = maxLength;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue