mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix for constant string case changes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32309 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9c9bb06fb4
commit
96b3bdf4b2
2 changed files with 192 additions and 109 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-02-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSString.m: Fix bugs in upper and lower casing of constant
|
||||
strings.
|
||||
|
||||
2011-02-22 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* Source/GSFFIInvocation.m (gs_find_best_typed_sel): Implemented
|
||||
|
|
|
@ -2819,6 +2819,7 @@ transmute(GSStr self, NSString *aString)
|
|||
{
|
||||
setup(NO);
|
||||
}
|
||||
|
||||
+ (void) reinitialize
|
||||
{
|
||||
setup(YES);
|
||||
|
@ -2986,95 +2987,11 @@ transmute(GSStr self, NSString *aString)
|
|||
freeWhenDone: flag];
|
||||
}
|
||||
|
||||
- (id) lowercaseString
|
||||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_tolower(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = tolower(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) uppercaseString
|
||||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_toupper(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = toupper(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation GSCString
|
||||
- (const char *) UTF8String
|
||||
{
|
||||
return UTF8String_c((GSStr)self);
|
||||
}
|
||||
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
|
@ -3107,6 +3024,31 @@ transmute(GSStr self, NSString *aString)
|
|||
return compare_c((GSStr)self, aString, mask, aRange);
|
||||
}
|
||||
|
||||
/*
|
||||
Default copy implementation. Retain if we own the buffer and the zones
|
||||
agree, create a new GSCInlineString otherwise.
|
||||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
if (!_flags.owned || NSShouldRetainWithZone(self, z) == NO)
|
||||
{
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
}
|
||||
|
||||
- (const char *) cString
|
||||
{
|
||||
return cString_c((GSStr)self, externalEncoding);
|
||||
|
@ -3231,6 +3173,25 @@ transmute(GSStr self, NSString *aString)
|
|||
return lossyCString_c((GSStr)self);
|
||||
}
|
||||
|
||||
- (id) lowercaseString
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = tolower(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
|
||||
- (id) mutableCopy
|
||||
{
|
||||
GSMutableString *obj;
|
||||
|
@ -3300,37 +3261,36 @@ transmute(GSStr self, NSString *aString)
|
|||
return substring_c((GSStr)self, aRange);
|
||||
}
|
||||
|
||||
- (id) uppercaseString
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = toupper(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
|
||||
- (const char *) UTF8String
|
||||
{
|
||||
return UTF8String_c((GSStr)self);
|
||||
}
|
||||
|
||||
// private method for Unicode level 3 implementation
|
||||
- (int) _baseLength
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
/*
|
||||
Default copy implementation. Retain if we own the buffer and the zones
|
||||
agree, create a new GSCInlineString otherwise.
|
||||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
if (!_flags.owned || NSShouldRetainWithZone(self, z) == NO)
|
||||
{
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RETAIN(self);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -3547,6 +3507,25 @@ agree, create a new GSCInlineString otherwise.
|
|||
return lossyCString_u((GSStr)self);
|
||||
}
|
||||
|
||||
- (id) lowercaseString
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_tolower(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
|
||||
- (id) mutableCopy
|
||||
{
|
||||
GSMutableString *obj;
|
||||
|
@ -3616,6 +3595,25 @@ agree, create a new GSCInlineString otherwise.
|
|||
return substring_u((GSStr)self, aRange);
|
||||
}
|
||||
|
||||
- (id) uppercaseString
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_toupper(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
|
||||
// private method for Unicode level 3 implementation
|
||||
- (int) _baseLength
|
||||
{
|
||||
|
@ -4308,6 +4306,46 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
return lossyCString_c((GSStr)self);
|
||||
}
|
||||
|
||||
- (id) lowercaseString
|
||||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_tolower(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = tolower(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) makeImmutableCopyOnFail: (BOOL)force
|
||||
{
|
||||
NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||
|
@ -4657,6 +4695,46 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
}
|
||||
}
|
||||
|
||||
- (id) uppercaseString
|
||||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_toupper(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = toupper(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
// private method for Unicode level 3 implementation
|
||||
- (int) _baseLength
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue