From a88b0eb08cdd338cf4546a099c37d3079c709fb7 Mon Sep 17 00:00:00 2001 From: CaS Date: Sun, 10 Nov 2002 06:19:17 +0000 Subject: [PATCH] Tidied git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14965 72102866-910b-0410-8b05-ffd578937521 --- Source/GSeq.h | 24 +++++++++++++++-------- Source/NSString.m | 23 +++++++++++++--------- Source/NSUserDefaults.m | 42 +++++++++++++++++++++-------------------- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/Source/GSeq.h b/Source/GSeq.h index f967cd4da..5854f7ab2 100644 --- a/Source/GSeq.h +++ b/Source/GSeq.h @@ -370,7 +370,8 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange) #endif #if GSEQ_S == GSEQ_NS - sgImp = (void (*)())[(id)s methodForSelector: gcrSel]; + sgImp = (void (*)(NSString*,SEL,unichar*,NSRange)) + [(id)s methodForSelector: gcrSel]; GSEQ_SGETR(sBuf, aRange); #else #if GSEQ_S == GSEQ_CS @@ -380,7 +381,8 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange) #endif #endif #if GSEQ_O == GSEQ_NS - ogImp = (void (*)())[(id)o methodForSelector: gcrSel]; + ogImp = (void (*)(NSString*,SEL,unichar*,NSRange)) + [(id)o methodForSelector: gcrSel]; GSEQ_OGETR(oBuf, NSMakeRange(0, oLen)); #else #if GSEQ_O == GSEQ_CS @@ -559,18 +561,24 @@ GSEQ_STRRANGE(NSString *ss, NSString *os, unsigned mask, NSRange aRange) * Cache method implementations for getting characters and ranges */ #if GSEQ_S == GSEQ_NS - scImp = (unichar (*)())[(id)s methodForSelector: caiSel]; - sgImp = (void (*)())[(id)s methodForSelector: gcrSel]; + scImp = (unichar (*)(NSString*,SEL,unsigned)) + [(id)s methodForSelector: caiSel]; + sgImp = (void (*)(NSString*,SEL,unichar*,NSRange)) + [(id)s methodForSelector: gcrSel]; #endif #if GSEQ_O == GSEQ_NS - ocImp = (unichar (*)())[(id)o methodForSelector: caiSel]; - ogImp = (void (*)())[(id)o methodForSelector: gcrSel]; + ocImp = (unichar (*)(NSString*,SEL,unsigned)) + [(id)o methodForSelector: caiSel]; + ogImp = (void (*)(NSString*,SEL,unichar*,NSRange)) + [(id)o methodForSelector: gcrSel]; #endif #if GSEQ_S == GSEQ_NS || GSEQ_S == GSEQ_US - srImp = (NSRange (*)())[(id)s methodForSelector: ranSel]; + srImp = (NSRange (*)(NSString*,SEL,unsigned)) + [(id)s methodForSelector: ranSel]; #endif #if GSEQ_O == GSEQ_NS || GSEQ_O == GSEQ_US - orImp = (NSRange (*)())[(id)o methodForSelector: ranSel]; + orImp = (NSRange (*)(NSString*,SEL,unsigned)) + [(id)o methodForSelector: ranSel]; #endif switch (mask) diff --git a/Source/NSString.m b/Source/NSString.m index 7db81346d..7a3a1544c 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -122,7 +122,7 @@ static SEL cMemberSel = 0; static unsigned const char *hexdigitsBitmapRep = NULL; #define GS_IS_HEXDIGIT(X) IS_BIT_SET(hexdigitsBitmapRep[(X)/8], (X) % 8) -static void setupHexdigits() +static void setupHexdigits(void) { if (hexdigitsBitmapRep == NULL) { @@ -141,7 +141,7 @@ static NSCharacterSet *oldQuotables = nil; static unsigned const char *quotablesBitmapRep = NULL; #define GS_IS_QUOTABLE(X) IS_BIT_SET(quotablesBitmapRep[(X)/8], (X) % 8) -static void setupQuotables() +static void setupQuotables(void) { if (quotablesBitmapRep == NULL) { @@ -170,7 +170,7 @@ static void setupQuotables() static unsigned const char *whitespaceBitmapRep = NULL; #define GS_IS_WHITESPACE(X) IS_BIT_SET(whitespaceBitmapRep[(X)/8], (X) % 8) -static void setupWhitespace() +static void setupWhitespace(void) { if (whitespaceBitmapRep == NULL) { @@ -214,7 +214,7 @@ static NSCharacterSet *myPathSeps = nil; * method 'cos that would cause recursion. */ static NSCharacterSet* -pathSeps() +pathSeps(void) { if (myPathSeps == nil) { @@ -1436,7 +1436,8 @@ handle_printf_atsign (FILE *stream, GS_RANGE_CHECK(aRange, l); - caiImp = (unichar (*)())[self methodForSelector: caiSel]; + caiImp = (unichar (*)(NSString*,SEL,unsigned)) + [self methodForSelector: caiSel]; for (i = 0; i < aRange.length; i++) { @@ -1585,7 +1586,8 @@ handle_printf_atsign (FILE *stream, range.location = NSNotFound; range.length = 0; - cImp = (unichar(*)(id,SEL,unsigned int)) [self methodForSelector: caiSel]; + cImp = (unichar(*)(id,SEL,unsigned int)) + [self methodForSelector: caiSel]; mImp = (BOOL(*)(id,SEL,unichar)) [aSet methodForSelector: cMemberSel]; @@ -1690,7 +1692,8 @@ handle_printf_atsign (FILE *stream, if (anIndex >= length) [NSException raise: NSRangeException format:@"Invalid location."]; - caiImp = (unichar (*)())[self methodForSelector: caiSel]; + caiImp = (unichar (*)(NSString*,SEL,unsigned)) + [self methodForSelector: caiSel]; for (start = anIndex; start > 0; start--) { @@ -1890,8 +1893,10 @@ handle_printf_atsign (FILE *stream, if (!oLength) return aString; - scImp = (unichar (*)())[self methodForSelector: caiSel]; - ocImp = (unichar (*)())[aString methodForSelector: caiSel]; + scImp = (unichar (*)(NSString*,SEL,unsigned)) + [self methodForSelector: caiSel]; + ocImp = (unichar (*)(NSString*,SEL,unsigned)) + [aString methodForSelector: caiSel]; while ((sIndex < sLength) && (oIndex < oLength)) { diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index beb9cf55f..a145c7e2d 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -1092,6 +1092,15 @@ static BOOL isPlistObject(id o) */ - (void) setObject: (id)value forKey: (NSString*)defaultName { + NSMutableDictionary *dict; + id obj; + + if ([defaultName isKindOfClass: [NSString class]] == NO + || [defaultName length] == 0) + { + [NSException raise: NSInvalidArgumentException + format: @"attempt to set object with bad key (%@)", defaultName]; + } if (value == nil) { [NSException raise: NSInvalidArgumentException @@ -1104,28 +1113,21 @@ static BOOL isPlistObject(id o) defaultName]; } - if (defaultName != nil && ([defaultName length] > 0)) + [_lock lock]; + obj = [_persDomains objectForKey: processName]; + if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) { - NSMutableDictionary *dict; - id obj; - - [_lock lock]; - obj = [_persDomains objectForKey: processName]; - if ([obj isKindOfClass: NSMutableDictionaryClass] == YES) - { - dict = obj; - } - else - { - dict = [obj mutableCopy]; - [_persDomains setObject: dict forKey: processName]; - RELEASE(dict); - } - [dict setObject: value forKey: defaultName]; - [self __changePersistentDomain: processName]; - [_lock unlock]; + dict = obj; } - return; + else + { + dict = [obj mutableCopy]; + [_persDomains setObject: dict forKey: processName]; + RELEASE(dict); + } + [dict setObject: value forKey: defaultName]; + [self __changePersistentDomain: processName]; + [_lock unlock]; } /**