mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Revert back to working code!
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32072 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b21d800c2a
commit
e679d4e99e
13 changed files with 57 additions and 71 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-02-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
Revert everything back to svn 32051 due to loads of commits of broken
|
||||||
|
code which have been occurring to fast for anyone to review, and either
|
||||||
|
don't compile or fail the testsuite.
|
||||||
|
Lets go through things checking that they at least compile with gcc
|
||||||
|
and pass the testsuite before we recommit them!
|
||||||
|
|
||||||
2011-02-11 Richard Frith-Macdonald <rfm@gnu.org>
|
2011-02-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSICUString.m:
|
* Source/GSICUString.m:
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* contents directly.
|
* contents directly.
|
||||||
*/
|
*/
|
||||||
UText* UTextInitWithNSString(UText *txt, NSString *str);
|
UText* UTextInitWithNSString(UText *txt, NSString *str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises a UText structure with an NSMutableString. If txt is NULL, then
|
* Initialises a UText structure with an NSMutableString. If txt is NULL, then
|
||||||
* this allocates a new structure on the heap, otherwise it fills in the
|
* this allocates a new structure on the heap, otherwise it fills in the
|
||||||
|
@ -24,7 +23,6 @@ UText* UTextInitWithNSString(UText *txt, NSString *str);
|
||||||
* reflected in the underlying NSMutableString.
|
* reflected in the underlying NSMutableString.
|
||||||
*/
|
*/
|
||||||
UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GSUTextString is an NSString subclass that is backed by a libicu UText
|
* GSUTextString is an NSString subclass that is backed by a libicu UText
|
||||||
* structure. This class is intended to be used when returning UText created
|
* structure. This class is intended to be used when returning UText created
|
||||||
|
@ -32,9 +30,9 @@ UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
||||||
*/
|
*/
|
||||||
@interface GSUTextString : NSString
|
@interface GSUTextString : NSString
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
/** The UText structure containing the libicu string interface. */
|
/** The UText structure containing the libicu string interface. */
|
||||||
UText txt;
|
UText txt;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -45,9 +43,9 @@ UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
||||||
*/
|
*/
|
||||||
@interface GSUTextMutableString : NSMutableString
|
@interface GSUTextMutableString : NSMutableString
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
/** The UText structure containing the libicu string interface. */
|
/** The UText structure containing the libicu string interface. */
|
||||||
UText txt;
|
UText txt;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -56,10 +54,10 @@ UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
||||||
*/
|
*/
|
||||||
static inline void free_string(unichar **buf)
|
static inline void free_string(unichar **buf)
|
||||||
{
|
{
|
||||||
if (0 != *buf)
|
if (0 != *buf)
|
||||||
{
|
{
|
||||||
free(*buf);
|
free(*buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,12 +68,12 @@ static inline void free_string(unichar **buf)
|
||||||
* Buffers created in this way are exception safe when using native exceptions.
|
* Buffers created in this way are exception safe when using native exceptions.
|
||||||
*/
|
*/
|
||||||
#define TEMP_BUFFER(name, size)\
|
#define TEMP_BUFFER(name, size)\
|
||||||
__attribute__((cleanup(free_string))) unichar *name ##_onheap = 0;\
|
__attribute__((cleanup(free_string))) unichar *name ##_onheap = 0;\
|
||||||
unichar name ## _onstack[64 / sizeof(unichar)];\
|
unichar name ## _onstack[64 / sizeof(unichar)];\
|
||||||
unichar *name = name ## _onstack;\
|
unichar *name = name ## _onstack;\
|
||||||
if (size > 64)\
|
if (size > 64)\
|
||||||
{\
|
{\
|
||||||
name ## _onheap = malloc(size);\
|
name ## _onheap = malloc(size);\
|
||||||
name = name ## _onheap;\
|
name = name ## _onheap;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,19 +263,12 @@ UTextNSMutableStringClone(UText *dest,
|
||||||
UErrorCode *status)
|
UErrorCode *status)
|
||||||
{
|
{
|
||||||
NSMutableString *str = (NSMutableString*)src->p;
|
NSMutableString *str = (NSMutableString*)src->p;
|
||||||
UText *txt;
|
|
||||||
|
|
||||||
if (deep)
|
if (deep)
|
||||||
{
|
{
|
||||||
str = [str mutableCopy];
|
str = [str mutableCopy];
|
||||||
txt = UTextInitWithNSMutableString(dest, str);
|
|
||||||
[str release];
|
|
||||||
}
|
}
|
||||||
else
|
return UTextInitWithNSMutableString(dest, str);
|
||||||
{
|
|
||||||
txt = UTextInitWithNSMutableString(dest, str);
|
|
||||||
}
|
|
||||||
return txt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,41 +93,21 @@ typedef struct objc_category* Category;
|
||||||
* arrays are allocated on the stack (for speed), but large arrays are
|
* arrays are allocated on the stack (for speed), but large arrays are
|
||||||
* allocated from the heap (to avoid stack overflow).
|
* allocated from the heap (to avoid stack overflow).
|
||||||
*/
|
*/
|
||||||
#if __GNUC__ > 3
|
#define GS_BEGINITEMBUF(P, S, T) { \
|
||||||
__attribute__((unused)) static void GSFreeTempBuffer(void **b)
|
|
||||||
{
|
|
||||||
if (NULL != *b) free(*b);
|
|
||||||
}
|
|
||||||
# define GS_BEGINITEMBUF(P, S, T) { \
|
|
||||||
T _ibuf[GS_MAX_OBJECTS_FROM_STACK];\
|
|
||||||
T *P = _ibuf;\
|
|
||||||
__attribute__((cleanup(GSFreeTempBuffer))) void *_base = 0;\
|
|
||||||
if (S > GS_MAX_OBJECTS_FROM_STACK)\
|
|
||||||
{\
|
|
||||||
_base = malloc(S);\
|
|
||||||
P = _base;\
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
# define GS_BEGINITEMBUF(P, S, T) { \
|
|
||||||
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \
|
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \
|
||||||
T *_base = ((S) <= GS_MAX_OBJECTS_FROM_STACK) ? _ibuf \
|
T *_base = ((S) <= GS_MAX_OBJECTS_FROM_STACK) ? _ibuf \
|
||||||
: (T*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(T)); \
|
: (T*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(T)); \
|
||||||
T *(P) = _base;
|
T *(P) = _base;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro to manage memory for chunks of code that need to work with
|
* Macro to manage memory for chunks of code that need to work with
|
||||||
* arrays of items. Use GS_BEGINITEMBUF() to start the block of code using
|
* arrays of items. Use GS_BEGINITEMBUF() to start the block of code using
|
||||||
* the array and this macro to end it.
|
* the array and this macro to end it.
|
||||||
*/
|
*/
|
||||||
#if __GNUC__ > 3
|
#define GS_ENDITEMBUF() \
|
||||||
# define GS_ENDITEMBUF() }
|
|
||||||
#else
|
|
||||||
# define GS_ENDITEMBUF() \
|
|
||||||
if (_base != _ibuf) \
|
if (_base != _ibuf) \
|
||||||
NSZoneFree(NSDefaultMallocZone(), _base); \
|
NSZoneFree(NSDefaultMallocZone(), _base); \
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro to manage memory for chunks of code that need to work with
|
* Macro to manage memory for chunks of code that need to work with
|
||||||
|
|
|
@ -1680,7 +1680,7 @@ compare(id elem1, id elem2, void* context)
|
||||||
enumerator = [self reverseObjectEnumerator];
|
enumerator = [self reverseObjectEnumerator];
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_IN (id, obj, enumerator)
|
FOR_IN (id, obj, self)
|
||||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||||
{
|
{
|
||||||
/* TODO: It would be more efficient to collect an NSRange and only
|
/* TODO: It would be more efficient to collect an NSRange and only
|
||||||
|
@ -1692,7 +1692,7 @@ compare(id elem1, id elem2, void* context)
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
END_FOR_IN(enumerator)
|
END_FOR_IN(self)
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1725,7 +1725,7 @@ compare(id elem1, id elem2, void* context)
|
||||||
enumerator = [self reverseObjectEnumerator];
|
enumerator = [self reverseObjectEnumerator];
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_IN (id, obj, enumerator)
|
FOR_IN (id, obj, self)
|
||||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||||
{
|
{
|
||||||
return count;
|
return count;
|
||||||
|
@ -1735,7 +1735,7 @@ compare(id elem1, id elem2, void* context)
|
||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
END_FOR_IN(enumerator)
|
END_FOR_IN(self)
|
||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
|
||||||
NSRange tmpRange;
|
NSRange tmpRange;
|
||||||
IMP getImp;
|
IMP getImp;
|
||||||
|
|
||||||
if (NSMaxRange(rangeLimit) > [self length])
|
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
format: @"RangeError in method -attributesAtIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
format: @"RangeError in method -attributesAtIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
||||||
|
@ -548,7 +548,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
|
||||||
BOOL (*eImp)(id,SEL,id);
|
BOOL (*eImp)(id,SEL,id);
|
||||||
IMP getImp;
|
IMP getImp;
|
||||||
|
|
||||||
if (NSMaxRange(rangeLimit) > [self length])
|
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
format: @"RangeError in method -attribute:atIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
format: @"RangeError in method -attribute:atIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
||||||
|
|
|
@ -3006,7 +3006,6 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
||||||
*/
|
*/
|
||||||
- (id) initWithContentsOfMappedFile: (NSString*)path
|
- (id) initWithContentsOfMappedFile: (NSString*)path
|
||||||
{
|
{
|
||||||
off_t off;
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
#if defined(__MINGW__)
|
#if defined(__MINGW__)
|
||||||
|
@ -3034,15 +3033,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
/* Find size of file to be mapped. */
|
/* Find size of file to be mapped. */
|
||||||
off = lseek(fd, 0, SEEK_END);
|
length = lseek(fd, 0, SEEK_END);
|
||||||
if (off < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
NSWarnMLog(@"unable to seek to eof %@ - %@", path, [NSError _last]);
|
NSWarnMLog(@"unable to seek to eof %@ - %@", path, [NSError _last]);
|
||||||
close(fd);
|
close(fd);
|
||||||
DESTROY(self);
|
DESTROY(self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
length = off;
|
|
||||||
/* Position at start of file. */
|
/* Position at start of file. */
|
||||||
if (lseek(fd, 0, SEEK_SET) != 0)
|
if (lseek(fd, 0, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -313,7 +313,6 @@ static NSString *newKey(SEL _cmd)
|
||||||
unsigned len = strlen(name);
|
unsigned len = strlen(name);
|
||||||
NSString *key;
|
NSString *key;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
NSCAssert(len > 0, @"Invalid selector name!");
|
|
||||||
|
|
||||||
if (*name == '_')
|
if (*name == '_')
|
||||||
{
|
{
|
||||||
|
|
|
@ -654,7 +654,7 @@ static NSRecursiveLock *classLock = nil;
|
||||||
#if GS_USE_ICU == 1
|
#if GS_USE_ICU == 1
|
||||||
int32_t length = 0;
|
int32_t length = 0;
|
||||||
unichar buffer[ULOC_FULLNAME_CAPACITY];
|
unichar buffer[ULOC_FULLNAME_CAPACITY];
|
||||||
UErrorCode status = 0;
|
UErrorCode status;
|
||||||
const char *keyword = NULL;
|
const char *keyword = NULL;
|
||||||
const char *locale = [_localeId UTF8String];
|
const char *locale = [_localeId UTF8String];
|
||||||
|
|
||||||
|
|
|
@ -452,7 +452,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||||
if (_inf == 0)
|
if (_inf == 0)
|
||||||
{
|
{
|
||||||
[self methodInfo];
|
[self methodInfo];
|
||||||
NSAssert(0 != _inf, @"Initialising failed");
|
|
||||||
}
|
}
|
||||||
return _inf[index+1];
|
return _inf[index+1];
|
||||||
}
|
}
|
||||||
|
@ -472,7 +471,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||||
if (_inf == 0)
|
if (_inf == 0)
|
||||||
{
|
{
|
||||||
[self methodInfo];
|
[self methodInfo];
|
||||||
NSAssert(0 != _inf, @"Initialising failed");
|
|
||||||
}
|
}
|
||||||
return _inf[index+1].qtype;
|
return _inf[index+1].qtype;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +480,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||||
if (_inf == 0)
|
if (_inf == 0)
|
||||||
{
|
{
|
||||||
[self methodInfo];
|
[self methodInfo];
|
||||||
NSAssert(0 != _inf, @"Initialising failed");
|
|
||||||
}
|
}
|
||||||
return (_inf[0].qual & _F_ONEWAY) ? YES : NO;
|
return (_inf[0].qual & _F_ONEWAY) ? YES : NO;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +489,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||||
if (_inf == 0)
|
if (_inf == 0)
|
||||||
{
|
{
|
||||||
[self methodInfo];
|
[self methodInfo];
|
||||||
NSAssert(0 != _inf, @"Initialising failed");
|
|
||||||
}
|
}
|
||||||
return _inf[0].size;
|
return _inf[0].size;
|
||||||
}
|
}
|
||||||
|
@ -502,7 +498,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||||
if (_inf == 0)
|
if (_inf == 0)
|
||||||
{
|
{
|
||||||
[self methodInfo];
|
[self methodInfo];
|
||||||
NSAssert(0 != _inf, @"Initialising failed");
|
|
||||||
}
|
}
|
||||||
return _inf[0].qtype;
|
return _inf[0].qtype;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1464,14 +1464,22 @@ PString(NSString *obj, NSMutableData *output)
|
||||||
else if ([obj rangeOfCharacterFromSet: oldQuotables].length > 0
|
else if ([obj rangeOfCharacterFromSet: oldQuotables].length > 0
|
||||||
|| [obj characterAtIndex: 0] == '/')
|
|| [obj characterAtIndex: 0] == '/')
|
||||||
{
|
{
|
||||||
|
unichar tmp[length <= 1024 ? length : 0];
|
||||||
unichar *ustring;
|
unichar *ustring;
|
||||||
unichar *from;
|
unichar *from;
|
||||||
unichar *end;
|
unichar *end;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
int base = [output length];
|
int base = [output length];
|
||||||
int len = 0;
|
int len = 0;
|
||||||
GS_BEGINITEMBUF(tmp, (length * sizeof(unichar)), unichar)
|
|
||||||
|
|
||||||
|
if (length <= 1024)
|
||||||
|
{
|
||||||
|
ustring = tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ustring = NSAllocateCollectable(sizeof(unichar) * length, 0);
|
||||||
|
}
|
||||||
end = &ustring[length];
|
end = &ustring[length];
|
||||||
[obj getCharacters: ustring];
|
[obj getCharacters: ustring];
|
||||||
for (from = ustring; from < end; from++)
|
for (from = ustring; from < end; from++)
|
||||||
|
@ -1573,7 +1581,10 @@ PString(NSString *obj, NSMutableData *output)
|
||||||
}
|
}
|
||||||
*ptr++ = '"';
|
*ptr++ = '"';
|
||||||
|
|
||||||
GS_ENDITEMBUF();
|
if (ustring != tmp)
|
||||||
|
{
|
||||||
|
NSZoneFree(NSDefaultMallocZone(), ustring);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -277,6 +277,7 @@ commonModes(void)
|
||||||
static BOOL entered_multi_threaded_state = NO;
|
static BOOL entered_multi_threaded_state = NO;
|
||||||
|
|
||||||
static NSThread *defaultThread;
|
static NSThread *defaultThread;
|
||||||
|
static NSLock *thread_creation_lock;
|
||||||
|
|
||||||
static pthread_key_t thread_object_key;
|
static pthread_key_t thread_object_key;
|
||||||
|
|
||||||
|
@ -304,7 +305,6 @@ static void exitedThread(void *thread)
|
||||||
fprintf(stderr, "WARNING thread %p terminated without calling +exit!\n",
|
fprintf(stderr, "WARNING thread %p terminated without calling +exit!\n",
|
||||||
thread);
|
thread);
|
||||||
}
|
}
|
||||||
[(id)thread release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,15 +458,17 @@ unregisterActiveThread(NSThread *thread)
|
||||||
|
|
||||||
if (t == nil)
|
if (t == nil)
|
||||||
{
|
{
|
||||||
|
[thread_creation_lock lock];
|
||||||
t = pthread_getspecific(thread_object_key);
|
t = pthread_getspecific(thread_object_key);
|
||||||
if (t == nil)
|
if (t == nil)
|
||||||
{
|
{
|
||||||
t = [self new];
|
t = [self new];
|
||||||
t->_active = YES;
|
t->_active = YES;
|
||||||
pthread_setspecific(thread_object_key, t);
|
pthread_setspecific(thread_object_key, t);
|
||||||
[t release];
|
[thread_creation_lock unlock];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
[thread_creation_lock unlock];
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -527,6 +529,7 @@ unregisterActiveThread(NSThread *thread)
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"Unable to create thread key!"];
|
format: @"Unable to create thread key!"];
|
||||||
}
|
}
|
||||||
|
thread_creation_lock = [NSLock new];
|
||||||
/*
|
/*
|
||||||
* Ensure that the default thread exists.
|
* Ensure that the default thread exists.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1196,6 +1196,7 @@ static Class NSDataMallocClass;
|
||||||
{
|
{
|
||||||
NSLog(@"Loss of information converting decoded value to uint16_t");
|
NSLog(@"Loss of information converting decoded value to uint16_t");
|
||||||
}
|
}
|
||||||
|
*(uint8_t*)address = (uint8_t)big;
|
||||||
*(uint16_t*)address = (uint16_t)big;
|
*(uint16_t*)address = (uint16_t)big;
|
||||||
return;
|
return;
|
||||||
case 4:
|
case 4:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue