diff --git a/ChangeLog b/ChangeLog index f25a71e70..0c469120d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2003-03-30 Adam Fedor + + * Headers/gnustep/base/NSString.h: (stringByTrimmingLeadSpaces, + stringByTrimmingTailSpaces, stringByTrimmingSpaces, + stringByReplacingString:withString:, replaceString:withString:, + trimLeadSpaces, trimTailSpaces, trimSpaces): Move to GSCategories.h + * Headers/gnustep/base/NSValue.h (valueFromString): Idem. + * Source/NSNumber.m (valueFromString:): Move to GSCategories.m + * Source/NSString.m: Idem as above. + * Source/Additions/GSCategories.m: Methods moved here. + * Source/Additions/GSCompatibility.h: Rearrange, add + NSDistantObject, NSFileHandle category, GSCurrentThreadDictionary(). + * Source/Additions/GSCompatibility.m: Add GSCurrentThreadDictionary + NSDistantObject, and NSFileHandle methods. + 2003-03-28 20:48 Alexander Malmberg * configure.ac: Fail the configure if neither ffcall nor ffi is diff --git a/Headers/gnustep/base/GSCategories.h b/Headers/gnustep/base/GSCategories.h index 643f71065..1c2979913 100644 --- a/Headers/gnustep/base/GSCategories.h +++ b/Headers/gnustep/base/GSCategories.h @@ -32,6 +32,7 @@ #include #include #include +#include #else #include #endif @@ -53,11 +54,25 @@ @interface NSString (GSCategories) - (NSString*) stringByDeletingPrefix: (NSString*)prefix; - (NSString*) stringByDeletingSuffix: (NSString*)suffix; +- (NSString*) stringByTrimmingLeadSpaces; +- (NSString*) stringByTrimmingTailSpaces; +- (NSString*) stringByTrimmingSpaces; +- (NSString*) stringByReplacingString: (NSString*)replace + withString: (NSString*)by; @end @interface NSMutableString (GSCategories) - (void) deleteSuffix: (NSString*)suffix; - (void) deletePrefix: (NSString*)prefix; +- (void) replaceString: (NSString*)replace + withString: (NSString*)by; +- (void) trimLeadSpaces; +- (void) trimTailSpaces; +- (void) trimSpaces; +@end + +@interface NSNumber(GSCategories) ++ (NSValue*) valueFromString: (NSString *)string; @end /* This is also defined in NSObject.h, but added here for use with the diff --git a/Headers/gnustep/base/NSString.h b/Headers/gnustep/base/NSString.h index 86e9a9b70..388dd3312 100644 --- a/Headers/gnustep/base/NSString.h +++ b/Headers/gnustep/base/NSString.h @@ -366,21 +366,8 @@ extern struct objc_class _NSConstantStringClassReference; #ifndef NO_GNUSTEP -@interface NSString (GNUstep) -- (NSString*) stringByReplacingString: (NSString*)replace - withString: (NSString*)by; -- (NSString*) stringByTrimmingLeadSpaces; -- (NSString*) stringByTrimmingTailSpaces; -- (NSString*) stringByTrimmingSpaces; -@end - @interface NSMutableString (GNUstep) - (NSString*) immutableProxy; -- (void) replaceString: (NSString*)replace - withString: (NSString*)by; -- (void) trimLeadSpaces; -- (void) trimTailSpaces; -- (void) trimSpaces; @end #endif /* NO_GNUSTEP */ diff --git a/Headers/gnustep/base/NSValue.h b/Headers/gnustep/base/NSValue.h index 3e7b51867..d4041f9ee 100644 --- a/Headers/gnustep/base/NSValue.h +++ b/Headers/gnustep/base/NSValue.h @@ -43,7 +43,6 @@ #ifndef STRICT_OPENSTEP + (NSValue*) valueWithBytes: (const void*)value objCType: (const char*)type; -+ (NSValue*) valueFromString: (NSString*)string; /* Designated initializer for all concrete subclasses */ - (id) initWithBytes: (const void*)data objCType: (const char*)type; - (BOOL) isEqualToValue: (NSValue*)other; diff --git a/Source/Additions/GSCategories.m b/Source/Additions/GSCategories.m index 40d3e2f28..b31d6fdc2 100644 --- a/Source/Additions/GSCategories.m +++ b/Source/Additions/GSCategories.m @@ -507,6 +507,31 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16]) @end +/** + * GNUstep specific (non-standard) additions to the NSNumber class. + */ +@implementation NSNumber(GSCategories) + ++ (NSValue*) valueFromString: (NSString*)string +{ + /* FIXME: implement this better */ + const char *str; + + str = [string cString]; + if (strchr(str, '.') >= 0 || strchr(str, 'e') >= 0 + || strchr(str, 'E') >= 0) + return [NSNumber numberWithDouble: atof(str)]; + else if (strchr(str, '-') >= 0) + return [NSNumber numberWithInt: atoi(str)]; + else + return [NSNumber numberWithUnsignedInt: atoi(str)]; + return [NSNumber numberWithInt: 0]; +} + +@end + + + /** * Extension methods for the NSObject class */ @@ -579,8 +604,8 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16]) @end -/** - * Extension methods for the NSObject class +/** + * GNUstep specific (non-standard) additions to the NSString class. */ @implementation NSString (GSCategories) @@ -606,8 +631,139 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16]) return [self substringToIndex: ([self length] - [suffix length])]; } +/** + * Returns a string formed by removing leading white space from the + * receiver. + */ +- (NSString*) stringByTrimmingLeadSpaces +{ + unsigned length = [self length]; + + if (length > 0) + { + unsigned start = 0; + unichar (*caiImp)(NSString*, SEL, unsigned int); + SEL caiSel = @selector(characterAtIndex:); + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (start < length && isspace((*caiImp)(self, caiSel, start))) + { + start++; + } + if (start > 0) + { + return [self substringFromIndex: start]; + } + } + return self; +} + +/** + * Returns a string formed by removing trailing white space from the + * receiver. + */ +- (NSString*) stringByTrimmingTailSpaces +{ + unsigned length = [self length]; + + if (length > 0) + { + unsigned end = length; + unichar (*caiImp)(NSString*, SEL, unsigned int); + SEL caiSel = @selector(characterAtIndex:); + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (end > 0) + { + if (!isspace((*caiImp)(self, caiSel, end - 1))) + { + break; + } + end--; + } + if (end < length) + { + return [self substringToIndex: end]; + } + } + return self; +} + +/** + * Returns a string formed by removing both leading and trailing + * white space from the receiver. + */ +- (NSString*) stringByTrimmingSpaces +{ + unsigned length = [self length]; + + if (length > 0) + { + unsigned start = 0; + unsigned end = length; + unichar (*caiImp)(NSString*, SEL, unsigned int); + SEL caiSel = @selector(characterAtIndex:); + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (start < length && isspace((*caiImp)(self, caiSel, start))) + { + start++; + } + while (end > start) + { + if (!isspace((*caiImp)(self, caiSel, end - 1))) + { + break; + } + end--; + } + if (start > 0 || end < length) + { + if (start < end) + { + return [self substringFromRange: + NSMakeRange(start, end - start)]; + } + else + { + return [NSString string]; + } + } + } + return self; +} + +/** + * Returns a string in which any (and all) occurrances of + * replace in the receiver have been replaced with by. + * Returns the receiver if replace + * does not occur within the receiver. NB. an empty string is + * not considered to exist within the receiver. + */ +- (NSString*) stringByReplacingString: (NSString*)replace + withString: (NSString*)by +{ + NSRange range = [self rangeOfString: replace]; + + if (range.length > 0) + { + NSMutableString *tmp = [self mutableCopy]; + NSString *str; + + [tmp replaceString: replace withString: by]; + str = AUTORELEASE([tmp copy]); + RELEASE(tmp); + return str; + } + else + return self; +} + @end +/** + * GNUstep specific (non-standard) additions to the NSMutableString class. + */ @implementation NSMutableString (GSCategories) /** @@ -633,4 +789,81 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16]) [self deleteCharactersInRange: NSMakeRange(0, [prefix length])]; } +/** + * Replaces all occurrances of the string replace with the string by + * in the receiver.
+ * Has no effect if replace does not occur within the + * receiver. NB. an empty string is not considered to exist within + * the receiver.
+ * Calls - replaceOccurrencesOfString:withString:options:range: passing + * zero for the options and a range from 0 with the length of the receiver. + */ +- (void) replaceString: (NSString*)replace + withString: (NSString*)by +{ + [self replaceOccurrencesOfString: replace + withString: by + options: 0 + range: NSMakeRange(0, [self length])]; +} + +/** + * Removes all leading white space from the receiver. + */ +- (void) trimLeadSpaces +{ + unsigned length = [self length]; + + if (length > 0) + { + unsigned start = 0; + unichar (*caiImp)(NSString*, SEL, unsigned int); + SEL caiSel = @selector(characterAtIndex:); + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (start < length && isspace((*caiImp)(self, caiSel, start))) + { + start++; + } + if (start > 0) + { + [self deleteCharactersInRange: NSMakeRange(0, start)]; + } + } +} + +/** + * Removes all trailing white space from the receiver. + */ +- (void) trimTailSpaces +{ + unsigned length = [self length]; + + if (length > 0) + { + unsigned end = length; + unichar (*caiImp)(NSString*, SEL, unsigned int); + SEL caiSel = @selector(characterAtIndex:); + + caiImp = (unichar (*)())[self methodForSelector: caiSel]; + while (end > 0 && isspace((*caiImp)(self, caiSel, end - 1))) + { + end--; + } + if (end < length) + { + [self deleteCharactersInRange: NSMakeRange(end, length - end)]; + } + } +} + +/** + * Removes all leading or trailing white space from the receiver. + */ +- (void) trimSpaces +{ + [self trimTailSpaces]; + [self trimLeadSpaces]; +} + @end diff --git a/Source/Additions/GSCompatibility.h b/Source/Additions/GSCompatibility.h index 1448b031e..10c4ed672 100644 --- a/Source/Additions/GSCompatibility.h +++ b/Source/Additions/GSCompatibility.h @@ -35,6 +35,10 @@ @class NSMutableSet; +/* ------------------------------------------------------------------------ + * Macros + */ + // Following are also defined in gnustep-base/Headers/gnustep/base/NSObject.h #define IF_NO_GC(x) \ x @@ -110,8 +114,6 @@ format: @"in %s, range { %u, %u } extends beyond size (%u)", \ sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE] -GS_EXPORT NSRecursiveLock *gnustep_global_lock; - /* Taken from gnustep-base/Headers/gnustep/base/NSString.h */ typedef enum _NSGNUstepStringEncoding { @@ -143,20 +145,41 @@ typedef enum _NSGNUstepStringEncoding NSBIG5StringEncoding // Traditional chinese } NSGNUstepStringEncoding; +/* ------------------------------------------------------------------------ + * Variables + */ +GS_EXPORT NSRecursiveLock *gnustep_global_lock; + +/* ------------------------------------------------------------------------ + * Class/Method Extensions + */ + @interface NSObject(GSCompatibility) + (id) notImplemented:(SEL)selector; - (BOOL) isInstance; @end +@interface NSArray (GSCompatibility) +- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy; +@end + +@interface NSDistantObject (GSCompatibility) ++ (void) setDebug: (int)val; +@end + +@interface NSFileHandle(GSCompatibility) ++ (id) fileHandleAsServerAtAddress: (NSString*)address + service: (NSString*)service + protocol: (NSString*)protocol; +- (NSString*) socketAddress; +@end + // Used only in EOFault.m, -[EOFault forward::], for Object compatibility @interface NSInvocation(GSCompatibility) - (retval_t) returnFrame:(arglist_t)args; - (id) initWithArgframe:(arglist_t)args selector:(SEL)selector; @end -GS_EXPORT NSArray *NSStandardLibraryPaths(); -GS_EXPORT NSString *GetEncodingName(NSStringEncoding availableEncodingValue); - @interface NSString(GSCompatibility) - (BOOL) boolValue; @end @@ -166,14 +189,18 @@ GS_EXPORT BOOL GSDebugSet(NSString *level); - (NSMutableSet *) debugSet; @end +/* ------------------------------------------------------------------------ + * Functions + */ + +GS_EXPORT NSArray *NSStandardLibraryPaths(); +GS_EXPORT NSString *GetEncodingName(NSStringEncoding availableEncodingValue); + +GS_EXPORT NSMutableDictionary *GSCurrentThreadDictionary(); + GS_EXPORT NSString *GSDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSString *fmt); GS_EXPORT NSString *GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt); -@interface NSArray (GSCompatibility) -- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy; -@end - - #endif /* NexT_FOUNDATION_LIB */ #endif diff --git a/Source/Additions/GSCompatibility.m b/Source/Additions/GSCompatibility.m index a67a47387..efac5bd50 100644 --- a/Source/Additions/GSCompatibility.m +++ b/Source/Additions/GSCompatibility.m @@ -35,6 +35,11 @@ NSString *GetEncodingName(NSStringEncoding availableEncodingValue) return (NSString *)CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(availableEncodingValue)); } +NSMutableDictionary *GSCurrentThreadDictionary() +{ + return [[NSThread currentThread] threadDictionary]; +} + NSArray *NSStandardLibraryPaths() { return NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSAllDomainsMask, YES); @@ -108,6 +113,206 @@ GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt) @end +@interface NSDistantObject (GSCategoriesRevealed) +// This method is implemented in MacOS X 10.2.4, but is not public ++ (void) _enableLogging:(BOOL)flag; +@end + +@implementation NSDistantObject (GSCompatibility) + ++ (void) setDebug: (int)val +{ + if([self respondsToSelector:@selector(_enableLogging:)]) + [self _enableLogging:!!val]; +} +@end + +#include +#include +#include +#include +#include +#include + +@implementation NSFileHandle(GSCompatibility) +// From GSFileHandle.m + +static BOOL +getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin) +{ + const char *proto = "tcp"; + struct servent *sp; + + if (pcl) + { + proto = [pcl lossyCString]; + } + memset(sin, '\0', sizeof(*sin)); + sin->sin_family = AF_INET; + + /* + * If we were given a hostname, we use any address for that host. + * Otherwise we expect the given name to be an address unless it is + * a null (any address). + */ + if (name) + { + NSHost* host = [NSHost hostWithName: name]; + + if (host != nil) + { + name = [host address]; + } +#ifndef HAVE_INET_ATON + sin->sin_addr.s_addr = inet_addr([name lossyCString]); + if (sin->sin_addr.s_addr == INADDR_NONE) +#else + if (inet_aton([name lossyCString], &sin->sin_addr) == 0) +#endif + { + return NO; + } + } + else + { + sin->sin_addr.s_addr = NSSwapHostIntToBig(INADDR_ANY); + } + if (svc == nil) + { + sin->sin_port = 0; + return YES; + } + else if ((sp = getservbyname([svc lossyCString], proto)) == 0) + { + const char* ptr = [svc lossyCString]; + int val = atoi(ptr); + + while (isdigit(*ptr)) + { + ptr++; + } + if (*ptr == '\0' && val <= 0xffff) + { + unsigned short v = val; + + sin->sin_port = NSSwapHostShortToBig(v); + return YES; + } + else if (strcmp(ptr, "gdomap") == 0) + { + unsigned short v; +#ifdef GDOMAP_PORT_OVERRIDE + v = GDOMAP_PORT_OVERRIDE; +#else + v = 538; // IANA allocated port +#endif + sin->sin_port = NSSwapHostShortToBig(v); + return YES; + } + else + { + return NO; + } + } + else + { + sin->sin_port = sp->s_port; + return YES; + } +} + +- (id) initAsServerAtAddress: (NSString*)a + service: (NSString*)s + protocol: (NSString*)p +{ +#ifndef BROKEN_SO_REUSEADDR + int status = 1; +#endif + int net; + struct sockaddr_in sin; + int size = sizeof(sin); + + if (getAddr(a, s, p, &sin) == NO) + { + RELEASE(self); + NSLog(@"bad address-service-protocol combination"); + return nil; + } + + if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) + { + NSLog(@"unable to create socket - %s", GSLastErrorStr(errno)); + RELEASE(self); + return nil; + } + +#ifndef BROKEN_SO_REUSEADDR + /* + * Under decent systems, SO_REUSEADDR means that the port can be reused + * immediately that this process exits. Under some it means + * that multiple processes can serve the same port simultaneously. + * We don't want that broken behavior! + */ + setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status)); +#endif + + if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0) + { + NSLog(@"unable to bind to port %s:%d - %s", inet_ntoa(sin.sin_addr), + NSSwapBigShortToHost(sin.sin_port), GSLastErrorStr(errno)); + (void) close(net); + RELEASE(self); + return nil; + } + + if (listen(net, 5) < 0) + { + NSLog(@"unable to listen on port - %s", GSLastErrorStr(errno)); + (void) close(net); + RELEASE(self); + return nil; + } + + if (getsockname(net, (struct sockaddr*)&sin, &size) < 0) + { + NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); + (void) close(net); + RELEASE(self); + return nil; + } + + self = [self initWithFileDescriptor: net closeOnDealloc: YES]; + + return self; +} + ++ (id) fileHandleAsServerAtAddress: (NSString*)address + service: (NSString*)service + protocol: (NSString*)protocol +{ + id o = [self allocWithZone: NSDefaultMallocZone()]; + + return AUTORELEASE([o initAsServerAtAddress: address + service: service + protocol: protocol]); +} + +- (NSString*) socketAddress +{ + struct sockaddr_in sin; + int size = sizeof(sin); + + if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0) + { + NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno)); + return nil; + } + + return [[[NSString alloc] initWithCString: (char*)inet_ntoa(sin.sin_addr)] + autorelease]; +@end + + @implementation NSProcessInfo(GSCompatibility) static NSMutableSet *_debug_set = nil; diff --git a/Source/NSNumber.m b/Source/NSNumber.m index 7757f3be0..9c83cc41c 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -468,22 +468,6 @@ static Class doubleNumberClass; return AUTORELEASE(theObj); } -+ (NSValue*) valueFromString: (NSString*)string -{ - /* FIXME: implement this better */ - const char *str; - - str = [string cString]; - if (strchr(str, '.') >= 0 || strchr(str, 'e') >= 0 - || strchr(str, 'E') >= 0) - return [NSNumber numberWithDouble: atof(str)]; - else if (strchr(str, '-') >= 0) - return [NSNumber numberWithInt: atoi(str)]; - else - return [NSNumber numberWithUnsignedInt: atoi(str)]; - return [NSNumber numberWithInt: 0]; -} - /* * A moderately sane default init method - a zero value integer. */ diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 15cfb45f4..ced14c330 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -83,6 +83,7 @@ #include #include #include +#include "gnustep/base/GSCategories.h" #include "GSPrivate.h" diff --git a/Source/NSString.m b/Source/NSString.m index d82ac58ec..2a9b82fe8 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -4318,139 +4318,6 @@ handle_printf_atsign (FILE *stream, @end - -/** - * GNUstep specific (non-standard) additions to the NSString class. - * The methods in this category are not available in MacOS-X - */ -@implementation NSString (GNUstep) -/** - * Returns a string formed by removing leading white space from the - * receiver. - */ -- (NSString*) stringByTrimmingLeadSpaces -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned start = 0; - unichar (*caiImp)(NSString*, SEL, unsigned int); - - caiImp = (unichar (*)())[self methodForSelector: caiSel]; - while (start < length && isspace((*caiImp)(self, caiSel, start))) - { - start++; - } - if (start > 0) - { - return [self substringFromIndex: start]; - } - } - return self; -} - -/** - * Returns a string formed by removing trailing white space from the - * receiver. - */ -- (NSString*) stringByTrimmingTailSpaces -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned end = length; - unichar (*caiImp)(NSString*, SEL, unsigned int); - - caiImp = (unichar (*)())[self methodForSelector: caiSel]; - while (end > 0) - { - if (!isspace((*caiImp)(self, caiSel, end - 1))) - { - break; - } - end--; - } - if (end < length) - { - return [self substringToIndex: end]; - } - } - return self; -} - -/** - * Returns a string formed by removing both leading and trailing - * white space from the receiver. - */ -- (NSString*) stringByTrimmingSpaces -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned start = 0; - unsigned end = length; - unichar (*caiImp)(NSString*, SEL, unsigned int); - - caiImp = (unichar (*)())[self methodForSelector: caiSel]; - while (start < length && isspace((*caiImp)(self, caiSel, start))) - { - start++; - } - while (end > start) - { - if (!isspace((*caiImp)(self, caiSel, end - 1))) - { - break; - } - end--; - } - if (start > 0 || end < length) - { - if (start < end) - { - return [self substringFromRange: - NSMakeRange(start, end - start)]; - } - else - { - return [NSStringClass string]; - } - } - } - return self; -} - -/** - * Returns a string in which any (and all) occurrances of - * replace in the receiver have been replaced with by. - * Returns the receiver if replace - * does not occur within the receiver. NB. an empty string is - * not considered to exist within the receiver. - */ -- (NSString*) stringByReplacingString: (NSString*)replace - withString: (NSString*)by -{ - NSRange range = [self rangeOfString: replace]; - - if (range.length > 0) - { - NSMutableString *tmp = [self mutableCopy]; - NSString *str; - - [tmp replaceString: replace withString: by]; - str = AUTORELEASE([tmp copy]); - RELEASE(tmp); - return str; - } - else - return self; -} - -@end - /** * GNUstep specific (non-standard) additions to the NSMutableString class. * The methods in this category are not available in MacOS-X @@ -4478,81 +4345,6 @@ handle_printf_atsign (FILE *stream, } } -/** - * Replaces all occurrances of the string replace with the string by - * in the receiver.
- * Has no effect if replace does not occur within the - * receiver. NB. an empty string is not considered to exist within - * the receiver.
- * Calls - replaceOccurrencesOfString:withString:options:range: passing - * zero for the options and a range from 0 with the length of the receiver. - */ -- (void) replaceString: (NSString*)replace - withString: (NSString*)by -{ - [self replaceOccurrencesOfString: replace - withString: by - options: 0 - range: NSMakeRange(0, [self length])]; -} - -/** - * Removes all leading white space from the receiver. - */ -- (void) trimLeadSpaces -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned start = 0; - unichar (*caiImp)(NSString*, SEL, unsigned int); - - caiImp = (unichar (*)())[self methodForSelector: caiSel]; - while (start < length && isspace((*caiImp)(self, caiSel, start))) - { - start++; - } - if (start > 0) - { - [self deleteCharactersInRange: NSMakeRange(0, start)]; - } - } -} - -/** - * Removes all trailing white space from the receiver. - */ -- (void) trimTailSpaces -{ - unsigned length = [self length]; - - if (length > 0) - { - unsigned end = length; - unichar (*caiImp)(NSString*, SEL, unsigned int); - - caiImp = (unichar (*)())[self methodForSelector: caiSel]; - while (end > 0 && isspace((*caiImp)(self, caiSel, end - 1))) - { - end--; - } - if (end < length) - { - [self deleteCharactersInRange: NSMakeRange(end, length - end)]; - } - } -} - -/** - * Removes all leading or trailing white space from the receiver. - */ -- (void) trimSpaces -{ - [self trimTailSpaces]; - [self trimLeadSpaces]; -} - @end diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index eeb1ff0b1..0080f27b1 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -75,8 +75,10 @@ #include #include #include +#include "gnustep/base/GSCategories.h" #include + #define NOID #include "tzfile.h" diff --git a/Source/NSUser.m b/Source/NSUser.m index f92684688..038a6ecf7 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -38,6 +38,7 @@ #include #include #include +#include "gnustep/base/GSCategories.h" #include "GSPrivate.h" diff --git a/Tools/AGSHtml.m b/Tools/AGSHtml.m index 746ac69d6..ccb65c408 100644 --- a/Tools/AGSHtml.m +++ b/Tools/AGSHtml.m @@ -23,10 +23,8 @@ #include #include "AGSHtml.h" #include "gnustep/base/GNUstep.h" -#ifdef NeXT_Foundation_LIBRARY #include "gnustep/base/GSCategories.h" #include "gnustep/base/GSCompatibility.h" -#endif static int XML_ELEMENT_NODE; static int XML_ENTITY_REF_NODE; diff --git a/Tools/AGSIndex.m b/Tools/AGSIndex.m index 5fd1378c0..aefbfabb8 100644 --- a/Tools/AGSIndex.m +++ b/Tools/AGSIndex.m @@ -23,10 +23,8 @@ #include #include "AGSIndex.h" #include "gnustep/base/GNUstep.h" -#ifdef NeXT_Foundation_LIBRARY #include "gnustep/base/GSCategories.h" #include "gnustep/base/GSCompatibility.h" -#endif static int XML_ELEMENT_NODE; static int XML_TEXT_NODE; diff --git a/Tools/AGSOutput.m b/Tools/AGSOutput.m index 2f404886b..1411afce5 100644 --- a/Tools/AGSOutput.m +++ b/Tools/AGSOutput.m @@ -22,9 +22,7 @@ #include "AGSOutput.h" #include "gnustep/base/GNUstep.h" -#ifdef NeXT_Foundation_LIBRARY #include "gnustep/base/GSCategories.h" -#endif @interface AGSOutput (Private) - (NSString*) mergeMarkup: (NSString*)markup diff --git a/Tools/AGSParser.m b/Tools/AGSParser.m index 87c51639a..8a7478a14 100644 --- a/Tools/AGSParser.m +++ b/Tools/AGSParser.m @@ -22,9 +22,7 @@ #include "AGSParser.h" #include "gnustep/base/GNUstep.h" -#ifdef NeXT_Foundation_LIBRARY #include "gnustep/base/GSCategories.h" -#endif @implementation AGSParser