From 93f37dfa37485876105a23b2ccfd4b4fe8f6f2bb Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 13 Sep 1999 04:11:39 +0000 Subject: [PATCH] Tidyups and bugfixes based on compiler warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4881 72102866-910b-0410-8b05-ffd578937521 --- Source/NSCoder.m | 1 + Source/NSDate.m | 6 +- Source/NSNotificationCenter.m | 23 +-- Source/NSString.m | 3 +- Source/Unicode.m | 372 +++++++++++++++++++--------------- 5 files changed, 224 insertions(+), 181 deletions(-) diff --git a/Source/NSCoder.m b/Source/NSCoder.m index bcc25a3ee..19105837c 100644 --- a/Source/NSCoder.m +++ b/Source/NSCoder.m @@ -182,6 +182,7 @@ @encode(unsigned), &count); *l = count; array = objc_malloc(count); + where = array; while (count-- > 0) (*imp)(self, @selector(decodeValueOfObjCType:at:), type, where++); diff --git a/Source/NSDate.m b/Source/NSDate.m index 27d155eb0..1a5a0d01e 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -634,10 +634,10 @@ GSTimeNow() break; default: - dtoIndex++; if (debug) NSLog(@"odd char (unicode %d) in NSDateTimeOrdering.\n", - [dto characterAtIndex: index]); + [dto characterAtIndex: dtoIndex]); + dtoIndex++; break; } } @@ -763,7 +763,7 @@ GSTimeNow() default: if (debug) NSLog(@"unexpected char (unicode%d) in NSDateTimeOrdering.\n", - [dto characterAtIndex: index]); + [dto characterAtIndex: dtoIndex]); break; } } diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index 19bedb05d..6c8f2127f 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -1012,21 +1012,18 @@ static NSNotificationCenter *default_center = nil; * Post the notification to all the observers that specified neither * NAME nor OBJECT. */ - if (o != ENDOBS) + for (o = WILDCARD; o != ENDOBS; o = o->next) { - for (o = WILDCARD; o != ENDOBS; o = o->next) - { - GSIArrayAddItem(a, (GSIArrayItem)o); - } - count = GSIArrayCount(a); - while (count-- > arrayBase) - { - o = GSIArrayItemAtIndex(a, count).ext; - if (o->next != 0) - (*o->method)(o->observer, o->selector, notification); - } - GSIArrayRemoveItemsFromIndex(a, arrayBase); + GSIArrayAddItem(a, (GSIArrayItem)o); } + count = GSIArrayCount(a); + while (count-- > arrayBase) + { + o = GSIArrayItemAtIndex(a, count).ext; + if (o->next != 0) + (*o->method)(o->observer, o->selector, notification); + } + GSIArrayRemoveItemsFromIndex(a, arrayBase); /* * Post the notification to all the observers that specified OBJECT, diff --git a/Source/NSString.m b/Source/NSString.m index 9cf56f83b..55fe49a36 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -144,7 +144,8 @@ pathSeps() myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"]; #endif RETAIN(myPathSeps); - sepMember = [myPathSeps methodForSelector: @selector(characterIsMember:)]; + sepMember = (BOOL (*)(NSCharacterSet*, SEL, unichar)) + [myPathSeps methodForSelector: @selector(characterIsMember:)]; } return myPathSeps; } diff --git a/Source/Unicode.m b/Source/Unicode.m index cc5ee4298..85ced21d8 100644 --- a/Source/Unicode.m +++ b/Source/Unicode.m @@ -1,7 +1,7 @@ /* Support functions for Unicode implementation Copyright (C) 1997 Free Software Foundation, Inc. - Written by: Stevo Crvenkovski + Written by: Stevo Crvenkovski < stevo@btinternet.com > Date: March 1997 This file is part of the GNUstep Base Library. @@ -35,138 +35,174 @@ struct _ucc_ {unichar from; char to;}; #define FALSE 0 #define TRUE 1 -unichar encode_chartouni(char c, NSStringEncoding enc) +typedef unsigned char unc; + +unichar +encode_chartouni(char c, NSStringEncoding enc) { - /* All that I could find in Next documentation - on NSNonLossyASCIIStringEncoding was <>. */ - if((enc==NSNonLossyASCIIStringEncoding) - || (enc==NSASCIIStringEncoding) - || (enc==NSISOLatin1StringEncoding)) - return (unichar)((unsigned char)c); - - if((enc==NSNEXTSTEPStringEncoding)) - if((unsigned char)c>. */ + if ((enc == NSNonLossyASCIIStringEncoding) + || (enc == NSASCIIStringEncoding) + || (enc == NSISOLatin1StringEncoding)) + { + return (unichar)((unc)c); + } + if ((enc == NSNEXTSTEPStringEncoding)) + { + if ((unc)c < Next_conv_base) + return (unichar)((unc)c); else - return(Next_char_to_uni_table[(unsigned char)c - Next_conv_base]); - - if((enc==NSCyrillicStringEncoding)) - if((unsigned char)c 0) + && (i < Next_uni_to_char_table_size)); + return res?0:Next_uni_to_char_table[--i].to; + } + } - if((enc== NSNEXTSTEPStringEncoding)) - if(u<(unichar)Next_conv_base) - return (char)u; - else - { - while(((res=u-Next_uni_to_char_table[i++].from)>0) && (i0) && (i 0) + && (i < Cyrillic_uni_to_char_table_size)); + return res ? 0 : Cyrillic_uni_to_char_table[--i].to; + } + } #if 0 - if((enc==NSSymbolStringEncoding)) - if(u<(unichar)Symbol_conv_base) - return (char)u; - else - { - while(((res=u-Symbol_uni_to_char_table[i++].from)>0) && (i 0) + && (i < Symbol_uni_to_char_table_size)); + return res ? '*' : Symbol_uni_to_char_table[--i].to; + } + } #endif - return 0; + return 0; } -unichar chartouni(char c) +unichar +chartouni(char c) { static NSStringEncoding enc = GSUndefinedEncoding; - if (enc == 0) enc = [NSString defaultCStringEncoding]; + + if (enc == 0) + enc = [NSString defaultCStringEncoding]; return encode_chartouni(c, enc); } -char unitochar(unichar u) +char +unitochar(unichar u) { - unsigned char res; + unc res; static NSStringEncoding enc = GSUndefinedEncoding; - if (enc == 0) enc = [NSString defaultCStringEncoding]; - if((res=encode_unitochar(u, enc))) + + if (enc == 0) + enc = [NSString defaultCStringEncoding]; + if ((res = encode_unitochar(u, enc))) return res; else return '*'; } -int strtoustr(unichar * u1,const char *s1,int size) - { - int count; - for(count=0;(count0)&&(count0)&&(count 0) && (count < t_len_tolower)); + return res ? ch : t_tolower[--count][1]; +} + +unichar +uni_toupper(unichar ch) +{ + int res; + int count = 0; + + while (((res = ch - t_toupper[count++][0]) > 0) && (count < t_len_toupper)); + return res ? ch : t_toupper[--count][1]; +} + +unsigned char +uni_cop(unichar u) { unichar count,first,last,comp; BOOL notfound; @@ -207,49 +249,51 @@ unsigned char uni_cop(unichar u) first = 0; last = uni_cop_table_size; notfound = TRUE; - count=0; + count =0; - if(u > (unichar)0x0080) // no nonspacing in ascii - { - while(notfound && (first <= last)) + if (u > (unichar)0x0080) // no nonspacing in ascii { - if(!(first==last)) - { - count = (first + last) / 2; - comp=uni_cop_table[count].code; - if(comp < u) - first = count+1; - else - if(comp > u) - last = count-1; - else - notfound = FALSE; - } - else /* first==last */ - { - if(u == uni_cop_table[first].code) - return uni_cop_table[first].cop; - return 0; - } /* else */ - } /* while notfound ...*/ - return notfound?0:uni_cop_table[count].cop; - } + while (notfound && (first <= last)) + { + if (!(first == last)) + { + count = (first + last) / 2; + comp = uni_cop_table[count].code; + if (comp < u) + first = count+1; + else + if (comp > u) + last = count-1; + else + notfound = FALSE; + } + else /* first == last */ + { + if (u == uni_cop_table[first].code) + return uni_cop_table[first].cop; + return 0; + } /* else */ + } /* while notfound ...*/ + return notfound ? 0 : uni_cop_table[count].cop; + } else /* u is ascii */ return 0; } -BOOL uni_isnonsp(unichar u) +BOOL +uni_isnonsp(unichar u) { #define TRUE 1 #define FALSE 0 // check is uni_cop good for this - if(uni_cop(u)) + if (uni_cop(u)) return TRUE; else return FALSE; } -unichar *uni_is_decomp(unichar u) +unichar* +uni_is_decomp(unichar u) { unichar count,first,last,comp; BOOL notfound; @@ -257,33 +301,33 @@ unichar *uni_is_decomp(unichar u) first = 0; last = uni_dec_table_size; notfound = TRUE; - count=0; + count =0; - if(u > (unichar)0x0080) // no composites in ascii - { - while(notfound && (first <= last)) + if (u > (unichar)0x0080) // no composites in ascii { - if(!(first==last)) - { - count = (first + last) / 2; - comp=uni_dec_table[count].code; - if(comp < u) - first = count+1; - else - if(comp > u) - last = count-1; - else - notfound = FALSE; - } - else /* first==last */ - { - if(u == uni_dec_table[first].code) - return uni_dec_table[first].decomp; - return 0; - } /* else */ - } /* while notfound ...*/ - return notfound?0:uni_dec_table[count].decomp; - } + while (notfound && (first <= last)) + { + if (!(first == last)) + { + count = (first + last) / 2; + comp = uni_dec_table[count].code; + if (comp < u) + first = count+1; + else + if (comp > u) + last = count-1; + else + notfound = FALSE; + } + else /* first == last */ + { + if (u == uni_dec_table[first].code) + return uni_dec_table[first].decomp; + return 0; + } /* else */ + } /* while notfound ...*/ + return notfound ? 0 : uni_dec_table[count].decomp; + } else /* u is ascii */ return 0; }