mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +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
f3f69cccc2
commit
336c7bf021
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>
|
||||
|
||||
* Source/GSICUString.m:
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* contents directly.
|
||||
*/
|
||||
UText* UTextInitWithNSString(UText *txt, NSString *str);
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -24,7 +23,6 @@ UText* UTextInitWithNSString(UText *txt, NSString *str);
|
|||
* reflected in the underlying NSMutableString.
|
||||
*/
|
||||
UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
||||
|
||||
/**
|
||||
* GSUTextString is an NSString subclass that is backed by a libicu UText
|
||||
* 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
|
||||
{
|
||||
@public
|
||||
/** The UText structure containing the libicu string interface. */
|
||||
UText txt;
|
||||
@public
|
||||
/** The UText structure containing the libicu string interface. */
|
||||
UText txt;
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -45,9 +43,9 @@ UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
|||
*/
|
||||
@interface GSUTextMutableString : NSMutableString
|
||||
{
|
||||
@public
|
||||
/** The UText structure containing the libicu string interface. */
|
||||
UText txt;
|
||||
@public
|
||||
/** The UText structure containing the libicu string interface. */
|
||||
UText txt;
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -56,10 +54,10 @@ UText* UTextInitWithNSMutableString(UText *txt, NSMutableString *str);
|
|||
*/
|
||||
static inline void free_string(unichar **buf)
|
||||
{
|
||||
if (0 != *buf)
|
||||
{
|
||||
free(*buf);
|
||||
}
|
||||
if (0 != *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.
|
||||
*/
|
||||
#define TEMP_BUFFER(name, size)\
|
||||
__attribute__((cleanup(free_string))) unichar *name ##_onheap = 0;\
|
||||
unichar name ## _onstack[64 / sizeof(unichar)];\
|
||||
unichar *name = name ## _onstack;\
|
||||
if (size > 64)\
|
||||
{\
|
||||
name ## _onheap = malloc(size);\
|
||||
name = name ## _onheap;\
|
||||
}
|
||||
__attribute__((cleanup(free_string))) unichar *name ##_onheap = 0;\
|
||||
unichar name ## _onstack[64 / sizeof(unichar)];\
|
||||
unichar *name = name ## _onstack;\
|
||||
if (size > 64)\
|
||||
{\
|
||||
name ## _onheap = malloc(size);\
|
||||
name = name ## _onheap;\
|
||||
}
|
||||
|
||||
|
|
|
@ -263,19 +263,12 @@ UTextNSMutableStringClone(UText *dest,
|
|||
UErrorCode *status)
|
||||
{
|
||||
NSMutableString *str = (NSMutableString*)src->p;
|
||||
UText *txt;
|
||||
|
||||
if (deep)
|
||||
{
|
||||
str = [str mutableCopy];
|
||||
txt = UTextInitWithNSMutableString(dest, str);
|
||||
[str release];
|
||||
}
|
||||
else
|
||||
{
|
||||
txt = UTextInitWithNSMutableString(dest, str);
|
||||
}
|
||||
return txt;
|
||||
return UTextInitWithNSMutableString(dest, str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,41 +93,21 @@ typedef struct objc_category* Category;
|
|||
* arrays are allocated on the stack (for speed), but large arrays are
|
||||
* allocated from the heap (to avoid stack overflow).
|
||||
*/
|
||||
#if __GNUC__ > 3
|
||||
__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) { \
|
||||
#define GS_BEGINITEMBUF(P, S, T) { \
|
||||
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \
|
||||
T *_base = ((S) <= GS_MAX_OBJECTS_FROM_STACK) ? _ibuf \
|
||||
: (T*)NSZoneMalloc(NSDefaultMallocZone(), (S) * sizeof(T)); \
|
||||
T *(P) = _base;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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
|
||||
* the array and this macro to end it.
|
||||
*/
|
||||
#if __GNUC__ > 3
|
||||
# define GS_ENDITEMBUF() }
|
||||
#else
|
||||
# define GS_ENDITEMBUF() \
|
||||
#define GS_ENDITEMBUF() \
|
||||
if (_base != _ibuf) \
|
||||
NSZoneFree(NSDefaultMallocZone(), _base); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
|
||||
FOR_IN (id, obj, enumerator)
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(enumerator)
|
||||
END_FOR_IN(self)
|
||||
return set;
|
||||
}
|
||||
|
||||
|
@ -1725,7 +1725,7 @@ compare(id elem1, id elem2, void* context)
|
|||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
|
||||
FOR_IN (id, obj, enumerator)
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
return count;
|
||||
|
@ -1735,7 +1735,7 @@ compare(id elem1, id elem2, void* context)
|
|||
return NSNotFound;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(enumerator)
|
||||
END_FOR_IN(self)
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
|
|||
NSRange tmpRange;
|
||||
IMP getImp;
|
||||
|
||||
if (NSMaxRange(rangeLimit) > [self length])
|
||||
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"RangeError in method -attributesAtIndex:longestEffectiveRange:inRange: in class NSAttributedString"];
|
||||
|
@ -548,7 +548,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
|
|||
BOOL (*eImp)(id,SEL,id);
|
||||
IMP getImp;
|
||||
|
||||
if (NSMaxRange(rangeLimit) > [self length])
|
||||
if (rangeLimit.location < 0 || NSMaxRange(rangeLimit) > [self length])
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
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
|
||||
{
|
||||
off_t off;
|
||||
int fd;
|
||||
|
||||
#if defined(__MINGW__)
|
||||
|
@ -3034,15 +3033,14 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
return nil;
|
||||
}
|
||||
/* Find size of file to be mapped. */
|
||||
off = lseek(fd, 0, SEEK_END);
|
||||
if (off < 0)
|
||||
length = lseek(fd, 0, SEEK_END);
|
||||
if (length < 0)
|
||||
{
|
||||
NSWarnMLog(@"unable to seek to eof %@ - %@", path, [NSError _last]);
|
||||
close(fd);
|
||||
DESTROY(self);
|
||||
return nil;
|
||||
}
|
||||
length = off;
|
||||
/* Position at start of file. */
|
||||
if (lseek(fd, 0, SEEK_SET) != 0)
|
||||
{
|
||||
|
|
|
@ -313,7 +313,6 @@ static NSString *newKey(SEL _cmd)
|
|||
unsigned len = strlen(name);
|
||||
NSString *key;
|
||||
unsigned i;
|
||||
NSCAssert(len > 0, @"Invalid selector name!");
|
||||
|
||||
if (*name == '_')
|
||||
{
|
||||
|
|
|
@ -654,7 +654,7 @@ static NSRecursiveLock *classLock = nil;
|
|||
#if GS_USE_ICU == 1
|
||||
int32_t length = 0;
|
||||
unichar buffer[ULOC_FULLNAME_CAPACITY];
|
||||
UErrorCode status = 0;
|
||||
UErrorCode status;
|
||||
const char *keyword = NULL;
|
||||
const char *locale = [_localeId UTF8String];
|
||||
|
||||
|
|
|
@ -452,7 +452,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
|||
if (_inf == 0)
|
||||
{
|
||||
[self methodInfo];
|
||||
NSAssert(0 != _inf, @"Initialising failed");
|
||||
}
|
||||
return _inf[index+1];
|
||||
}
|
||||
|
@ -472,7 +471,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
|||
if (_inf == 0)
|
||||
{
|
||||
[self methodInfo];
|
||||
NSAssert(0 != _inf, @"Initialising failed");
|
||||
}
|
||||
return _inf[index+1].qtype;
|
||||
}
|
||||
|
@ -482,7 +480,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
|||
if (_inf == 0)
|
||||
{
|
||||
[self methodInfo];
|
||||
NSAssert(0 != _inf, @"Initialising failed");
|
||||
}
|
||||
return (_inf[0].qual & _F_ONEWAY) ? YES : NO;
|
||||
}
|
||||
|
@ -492,7 +489,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
|||
if (_inf == 0)
|
||||
{
|
||||
[self methodInfo];
|
||||
NSAssert(0 != _inf, @"Initialising failed");
|
||||
}
|
||||
return _inf[0].size;
|
||||
}
|
||||
|
@ -502,7 +498,6 @@ next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
|||
if (_inf == 0)
|
||||
{
|
||||
[self methodInfo];
|
||||
NSAssert(0 != _inf, @"Initialising failed");
|
||||
}
|
||||
return _inf[0].qtype;
|
||||
}
|
||||
|
|
|
@ -1464,14 +1464,22 @@ PString(NSString *obj, NSMutableData *output)
|
|||
else if ([obj rangeOfCharacterFromSet: oldQuotables].length > 0
|
||||
|| [obj characterAtIndex: 0] == '/')
|
||||
{
|
||||
unichar tmp[length <= 1024 ? length : 0];
|
||||
unichar *ustring;
|
||||
unichar *from;
|
||||
unichar *end;
|
||||
unsigned char *ptr;
|
||||
int base = [output length];
|
||||
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];
|
||||
[obj getCharacters: ustring];
|
||||
for (from = ustring; from < end; from++)
|
||||
|
@ -1573,7 +1581,10 @@ PString(NSString *obj, NSMutableData *output)
|
|||
}
|
||||
*ptr++ = '"';
|
||||
|
||||
GS_ENDITEMBUF();
|
||||
if (ustring != tmp)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), ustring);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -277,6 +277,7 @@ commonModes(void)
|
|||
static BOOL entered_multi_threaded_state = NO;
|
||||
|
||||
static NSThread *defaultThread;
|
||||
static NSLock *thread_creation_lock;
|
||||
|
||||
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",
|
||||
thread);
|
||||
}
|
||||
[(id)thread release];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -458,15 +458,17 @@ unregisterActiveThread(NSThread *thread)
|
|||
|
||||
if (t == nil)
|
||||
{
|
||||
[thread_creation_lock lock];
|
||||
t = pthread_getspecific(thread_object_key);
|
||||
if (t == nil)
|
||||
{
|
||||
t = [self new];
|
||||
t->_active = YES;
|
||||
pthread_setspecific(thread_object_key, t);
|
||||
[t release];
|
||||
[thread_creation_lock unlock];
|
||||
return YES;
|
||||
}
|
||||
[thread_creation_lock unlock];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
@ -527,6 +529,7 @@ unregisterActiveThread(NSThread *thread)
|
|||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to create thread key!"];
|
||||
}
|
||||
thread_creation_lock = [NSLock new];
|
||||
/*
|
||||
* Ensure that the default thread exists.
|
||||
*/
|
||||
|
|
|
@ -1196,6 +1196,7 @@ static Class NSDataMallocClass;
|
|||
{
|
||||
NSLog(@"Loss of information converting decoded value to uint16_t");
|
||||
}
|
||||
*(uint8_t*)address = (uint8_t)big;
|
||||
*(uint16_t*)address = (uint16_t)big;
|
||||
return;
|
||||
case 4:
|
||||
|
|
Loading…
Reference in a new issue