mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
* Source/GSString.m: Remove GSString copyWithZone:.
* Source/NSString.m: Raise exception when no is provided for the string. This brings our implementation closer to the Cocoa one. * Source/GSString.m: Add similar exceptions.
This commit is contained in:
parent
1066ec7015
commit
5a72e1cfa8
3 changed files with 49 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2018-07-06 Fred Kiefer <fredkiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/GSString.m: Remove GSString copyWithZone:.
|
||||||
|
* Source/NSString.m: Raise exception when no is provided for the
|
||||||
|
string. This brings our implementation closer to the Cocoa one.
|
||||||
|
* Source/GSString.m: Add similar exceptions.
|
||||||
|
|
||||||
2018-07-02 Richard Frith-Macdonald <rfm@gnu.org>
|
2018-07-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Tests/base/NSString/test00.m: : Move _unicodeString from here...
|
* Tests/base/NSString/test00.m: : Move _unicodeString from here...
|
||||||
|
|
|
@ -1556,6 +1556,9 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
||||||
size_t len;
|
size_t len;
|
||||||
GSStr me;
|
GSStr me;
|
||||||
|
|
||||||
|
if (NULL == format)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[GSPlaceholderString-initWithFormat:locale:arguments:]: NULL format"];
|
||||||
/*
|
/*
|
||||||
* First we provide an array of unichar characters containing the
|
* First we provide an array of unichar characters containing the
|
||||||
* format string. For performance reasons we try to use an on-stack
|
* format string. For performance reasons we try to use an on-stack
|
||||||
|
@ -1630,7 +1633,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
||||||
|
|
||||||
if (string == nil)
|
if (string == nil)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"-initWithString: given nil string"];
|
format: @"GSPlaceholderString-initWithString: given nil string"];
|
||||||
if (NO == [string isKindOfClass: NSStringClass]) // may be proxy
|
if (NO == [string isKindOfClass: NSStringClass]) // may be proxy
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"-initWithString: given non-string object"];
|
format: @"-initWithString: given non-string object"];
|
||||||
|
@ -1679,10 +1682,9 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
||||||
GSStr me;
|
GSStr me;
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
|
|
||||||
if (0 == bytes)
|
if (NULL == bytes)
|
||||||
{
|
[NSException raise: NSInvalidArgumentException
|
||||||
return (id)@"";
|
format: @"[GSPlaceholderString-initWithUTF8String:]: NULL cString"];
|
||||||
}
|
|
||||||
/* Skip leading BOM
|
/* Skip leading BOM
|
||||||
*/
|
*/
|
||||||
if (b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF)
|
if (b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF)
|
||||||
|
@ -3649,12 +3651,6 @@ transmute(GSStr self, NSString *aString)
|
||||||
setup(YES);
|
setup(YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone*)z
|
|
||||||
{
|
|
||||||
[self subclassResponsibility: _cmd];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return a 28-bit hash value for the string contents - this
|
* Return a 28-bit hash value for the string contents - this
|
||||||
* MUST match the algorithm used by the NSString base class.
|
* MUST match the algorithm used by the NSString base class.
|
||||||
|
@ -5062,6 +5058,9 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
unichar *fmt = fbuf;
|
unichar *fmt = fbuf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
if (NULL == format)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[GSMutableString-initWithFormat:locale:arguments:]: NULL format"];
|
||||||
/*
|
/*
|
||||||
* First we provide an array of unichar characters containing the
|
* First we provide an array of unichar characters containing the
|
||||||
* format string. For performance reasons we try to use an on-stack
|
* format string. For performance reasons we try to use an on-stack
|
||||||
|
|
|
@ -938,6 +938,9 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
{
|
{
|
||||||
NSString *obj;
|
NSString *obj;
|
||||||
|
|
||||||
|
if (NULL == aString)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString+stringWithString:]: NULL string"];
|
||||||
obj = [self allocWithZone: NSDefaultMallocZone()];
|
obj = [self allocWithZone: NSDefaultMallocZone()];
|
||||||
obj = [obj initWithString: aString];
|
obj = [obj initWithString: aString];
|
||||||
return AUTORELEASE(obj);
|
return AUTORELEASE(obj);
|
||||||
|
@ -964,10 +967,12 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
+ (id) stringWithCString: (const char*)byteString
|
+ (id) stringWithCString: (const char*)byteString
|
||||||
{
|
{
|
||||||
NSString *obj;
|
NSString *obj;
|
||||||
unsigned length = byteString ? strlen(byteString) : 0;
|
|
||||||
|
|
||||||
|
if (NULL == byteString)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString+stringWithCString:]: NULL cString"];
|
||||||
obj = [self allocWithZone: NSDefaultMallocZone()];
|
obj = [self allocWithZone: NSDefaultMallocZone()];
|
||||||
obj = [obj initWithCString: byteString length: length];
|
obj = [obj initWithCString: byteString];
|
||||||
return AUTORELEASE(obj);
|
return AUTORELEASE(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,16 +1120,16 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
+ (id) stringWithFormat: (NSString*)format,...
|
+ (id) stringWithFormat: (NSString*)format,...
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
id ret;
|
NSString *obj;
|
||||||
|
|
||||||
|
if (NULL == format)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString+stringWithFormat:]: NULL format"];
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
if (format == nil)
|
obj = [self allocWithZone: NSDefaultMallocZone()];
|
||||||
ret = nil;
|
obj = [obj initWithFormat: format arguments: ap];
|
||||||
else
|
|
||||||
ret = AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
|
||||||
initWithFormat: format arguments: ap]);
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return AUTORELEASE(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1275,8 +1280,11 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
- (id) initWithCString: (const char*)byteString
|
- (id) initWithCString: (const char*)byteString
|
||||||
encoding: (NSStringEncoding)encoding
|
encoding: (NSStringEncoding)encoding
|
||||||
{
|
{
|
||||||
|
if (NULL == byteString)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString-initWithCString:encoding:]: NULL cString"];
|
||||||
return [self initWithBytes: byteString
|
return [self initWithBytes: byteString
|
||||||
length: (byteString ? strlen(byteString) : 0)
|
length: strlen(byteString)
|
||||||
encoding: encoding];
|
encoding: encoding];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,8 +1307,11 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
*/
|
*/
|
||||||
- (id) initWithCString: (const char*)byteString
|
- (id) initWithCString: (const char*)byteString
|
||||||
{
|
{
|
||||||
|
if (NULL == byteString)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString-initWithCString:]: NULL cString"];
|
||||||
return [self initWithBytes: byteString
|
return [self initWithBytes: byteString
|
||||||
length: (byteString ? strlen(byteString) : 0)
|
length: strlen(byteString)
|
||||||
encoding: _DefaultStringEncoding];
|
encoding: _DefaultStringEncoding];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,6 +1322,9 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
{
|
{
|
||||||
unsigned length = [string length];
|
unsigned length = [string length];
|
||||||
|
|
||||||
|
if (NULL == string)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString-initWithString:]: NULL string"];
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
unichar *s = NSZoneMalloc([self zone], sizeof(unichar)*length);
|
unichar *s = NSZoneMalloc([self zone], sizeof(unichar)*length);
|
||||||
|
@ -1334,8 +1348,11 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
*/
|
*/
|
||||||
- (id) initWithUTF8String: (const char *)bytes
|
- (id) initWithUTF8String: (const char *)bytes
|
||||||
{
|
{
|
||||||
|
if (NULL == bytes)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString-initWithUTF8String:]: NULL cString"];
|
||||||
return [self initWithBytes: bytes
|
return [self initWithBytes: bytes
|
||||||
length: (bytes ? strlen(bytes) : 0)
|
length: strlen(bytes)
|
||||||
encoding: NSUTF8StringEncoding];
|
encoding: NSUTF8StringEncoding];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,6 +1404,9 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
unichar *fmt = fbuf;
|
unichar *fmt = fbuf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
if (NULL == format)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"[NSString-initWithFormat:locale:arguments:]: NULL format"];
|
||||||
/*
|
/*
|
||||||
* First we provide an array of unichar characters containing the
|
* First we provide an array of unichar characters containing the
|
||||||
* format string. For performance reasons we try to use an on-stack
|
* format string. For performance reasons we try to use an on-stack
|
||||||
|
|
Loading…
Reference in a new issue