mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 01:01:03 +00:00
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
This commit is contained in:
parent
1a3f09f836
commit
93f37dfa37
5 changed files with 224 additions and 181 deletions
|
@ -182,6 +182,7 @@
|
||||||
@encode(unsigned), &count);
|
@encode(unsigned), &count);
|
||||||
*l = count;
|
*l = count;
|
||||||
array = objc_malloc(count);
|
array = objc_malloc(count);
|
||||||
|
where = array;
|
||||||
while (count-- > 0)
|
while (count-- > 0)
|
||||||
(*imp)(self, @selector(decodeValueOfObjCType:at:), type, where++);
|
(*imp)(self, @selector(decodeValueOfObjCType:at:), type, where++);
|
||||||
|
|
||||||
|
|
|
@ -634,10 +634,10 @@ GSTimeNow()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dtoIndex++;
|
|
||||||
if (debug)
|
if (debug)
|
||||||
NSLog(@"odd char (unicode %d) in NSDateTimeOrdering.\n",
|
NSLog(@"odd char (unicode %d) in NSDateTimeOrdering.\n",
|
||||||
[dto characterAtIndex: index]);
|
[dto characterAtIndex: dtoIndex]);
|
||||||
|
dtoIndex++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ GSTimeNow()
|
||||||
default:
|
default:
|
||||||
if (debug)
|
if (debug)
|
||||||
NSLog(@"unexpected char (unicode%d) in NSDateTimeOrdering.\n",
|
NSLog(@"unexpected char (unicode%d) in NSDateTimeOrdering.\n",
|
||||||
[dto characterAtIndex: index]);
|
[dto characterAtIndex: dtoIndex]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1012,8 +1012,6 @@ static NSNotificationCenter *default_center = nil;
|
||||||
* Post the notification to all the observers that specified neither
|
* Post the notification to all the observers that specified neither
|
||||||
* NAME nor OBJECT.
|
* 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);
|
GSIArrayAddItem(a, (GSIArrayItem)o);
|
||||||
|
@ -1026,7 +1024,6 @@ static NSNotificationCenter *default_center = nil;
|
||||||
(*o->method)(o->observer, o->selector, notification);
|
(*o->method)(o->observer, o->selector, notification);
|
||||||
}
|
}
|
||||||
GSIArrayRemoveItemsFromIndex(a, arrayBase);
|
GSIArrayRemoveItemsFromIndex(a, arrayBase);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Post the notification to all the observers that specified OBJECT,
|
* Post the notification to all the observers that specified OBJECT,
|
||||||
|
|
|
@ -144,7 +144,8 @@ pathSeps()
|
||||||
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
myPathSeps = [NSCharacterSet characterSetWithCharactersInString: @"/"];
|
||||||
#endif
|
#endif
|
||||||
RETAIN(myPathSeps);
|
RETAIN(myPathSeps);
|
||||||
sepMember = [myPathSeps methodForSelector: @selector(characterIsMember:)];
|
sepMember = (BOOL (*)(NSCharacterSet*, SEL, unichar))
|
||||||
|
[myPathSeps methodForSelector: @selector(characterIsMember:)];
|
||||||
}
|
}
|
||||||
return myPathSeps;
|
return myPathSeps;
|
||||||
}
|
}
|
||||||
|
|
108
Source/Unicode.m
108
Source/Unicode.m
|
@ -35,134 +35,170 @@ struct _ucc_ {unichar from; char to;};
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define TRUE 1
|
#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
|
/* All that I could find in Next documentation
|
||||||
on NSNonLossyASCIIStringEncoding was << forthcoming >>. */
|
on NSNonLossyASCIIStringEncoding was << forthcoming >>. */
|
||||||
if ((enc == NSNonLossyASCIIStringEncoding)
|
if ((enc == NSNonLossyASCIIStringEncoding)
|
||||||
|| (enc == NSASCIIStringEncoding)
|
|| (enc == NSASCIIStringEncoding)
|
||||||
|| (enc == NSISOLatin1StringEncoding))
|
|| (enc == NSISOLatin1StringEncoding))
|
||||||
return (unichar)((unsigned char)c);
|
{
|
||||||
|
return (unichar)((unc)c);
|
||||||
|
}
|
||||||
if ((enc == NSNEXTSTEPStringEncoding))
|
if ((enc == NSNEXTSTEPStringEncoding))
|
||||||
if((unsigned char)c<Next_conv_base)
|
{
|
||||||
return (unichar)((unsigned char)c);
|
if ((unc)c < Next_conv_base)
|
||||||
|
return (unichar)((unc)c);
|
||||||
else
|
else
|
||||||
return(Next_char_to_uni_table[(unsigned char)c - Next_conv_base]);
|
return(Next_char_to_uni_table[(unc)c - Next_conv_base]);
|
||||||
|
}
|
||||||
if ((enc == NSCyrillicStringEncoding))
|
if ((enc == NSCyrillicStringEncoding))
|
||||||
if((unsigned char)c<Cyrillic_conv_base)
|
{
|
||||||
return (unichar)((unsigned char)c);
|
if ((unc)c < Cyrillic_conv_base)
|
||||||
|
return (unichar)((unc)c);
|
||||||
else
|
else
|
||||||
return(Cyrillic_char_to_uni_table[(unsigned char)c - Cyrillic_conv_base]);
|
return(Cyrillic_char_to_uni_table[(unc)c - Cyrillic_conv_base]);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ((enc == NSSymbolStringEncoding))
|
if ((enc == NSSymbolStringEncoding))
|
||||||
if((unsigned char)c<Symbol_conv_base)
|
{
|
||||||
return (unichar)((unsigned char)c);
|
if ((unc)c < Symbol_conv_base)
|
||||||
|
return (unichar)((unc)c);
|
||||||
else
|
else
|
||||||
return(Symbol_char_to_uni_table[(unsigned char)c - Symbol_conv_base]);
|
return(Symbol_char_to_uni_table[(unc)c - Symbol_conv_base]);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char encode_unitochar(unichar u, NSStringEncoding enc)
|
char
|
||||||
|
encode_unitochar(unichar u, NSStringEncoding enc)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int i =0;
|
int i =0;
|
||||||
|
|
||||||
if ((enc == NSNonLossyASCIIStringEncoding)
|
if ((enc == NSNonLossyASCIIStringEncoding)
|
||||||
|| (enc == NSASCIIStringEncoding))
|
|| (enc == NSASCIIStringEncoding))
|
||||||
|
{
|
||||||
if (u <128)
|
if (u <128)
|
||||||
return (char)u;
|
return (char)u;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((enc == NSISOLatin1StringEncoding))
|
if ((enc == NSISOLatin1StringEncoding))
|
||||||
|
{
|
||||||
if (u <256)
|
if (u <256)
|
||||||
return (char)u;
|
return (char)u;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((enc == NSNEXTSTEPStringEncoding))
|
if ((enc == NSNEXTSTEPStringEncoding))
|
||||||
|
{
|
||||||
if (u <(unichar)Next_conv_base)
|
if (u <(unichar)Next_conv_base)
|
||||||
return (char)u;
|
return (char)u;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(((res=u-Next_uni_to_char_table[i++].from)>0) && (i<Next_uni_to_char_table_size));
|
while (((res = u-Next_uni_to_char_table[i++].from) > 0)
|
||||||
|
&& (i < Next_uni_to_char_table_size));
|
||||||
return res?0:Next_uni_to_char_table[--i].to;
|
return res?0:Next_uni_to_char_table[--i].to;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((enc == NSCyrillicStringEncoding))
|
if ((enc == NSCyrillicStringEncoding))
|
||||||
|
{
|
||||||
if (u <(unichar)Cyrillic_conv_base)
|
if (u <(unichar)Cyrillic_conv_base)
|
||||||
return (char)u;
|
return (char)u;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(((res=u-Cyrillic_uni_to_char_table[i++].from)>0) && (i<Cyrillic_uni_to_char_table_size));
|
while (((res = u-Cyrillic_uni_to_char_table[i++].from) > 0)
|
||||||
|
&& (i < Cyrillic_uni_to_char_table_size));
|
||||||
return res ? 0 : Cyrillic_uni_to_char_table[--i].to;
|
return res ? 0 : Cyrillic_uni_to_char_table[--i].to;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if ((enc == NSSymbolStringEncoding))
|
if ((enc == NSSymbolStringEncoding))
|
||||||
|
{
|
||||||
if (u <(unichar)Symbol_conv_base)
|
if (u <(unichar)Symbol_conv_base)
|
||||||
return (char)u;
|
return (char)u;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while(((res=u-Symbol_uni_to_char_table[i++].from)>0) && (i<Symbol_uni_to_char_table_size));
|
while (((res = u-Symbol_uni_to_char_table[i++].from) > 0)
|
||||||
|
&& (i < Symbol_uni_to_char_table_size));
|
||||||
return res ? '*' : Symbol_uni_to_char_table[--i].to;
|
return res ? '*' : Symbol_uni_to_char_table[--i].to;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unichar chartouni(char c)
|
unichar
|
||||||
|
chartouni(char c)
|
||||||
{
|
{
|
||||||
static NSStringEncoding enc = GSUndefinedEncoding;
|
static NSStringEncoding enc = GSUndefinedEncoding;
|
||||||
if (enc == 0) enc = [NSString defaultCStringEncoding];
|
|
||||||
|
if (enc == 0)
|
||||||
|
enc = [NSString defaultCStringEncoding];
|
||||||
return encode_chartouni(c, enc);
|
return encode_chartouni(c, enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
char unitochar(unichar u)
|
char
|
||||||
|
unitochar(unichar u)
|
||||||
{
|
{
|
||||||
unsigned char res;
|
unc res;
|
||||||
static NSStringEncoding enc = GSUndefinedEncoding;
|
static NSStringEncoding enc = GSUndefinedEncoding;
|
||||||
if (enc == 0) enc = [NSString defaultCStringEncoding];
|
|
||||||
|
if (enc == 0)
|
||||||
|
enc = [NSString defaultCStringEncoding];
|
||||||
if ((res = encode_unitochar(u, enc)))
|
if ((res = encode_unitochar(u, enc)))
|
||||||
return res;
|
return res;
|
||||||
else
|
else
|
||||||
return '*';
|
return '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
int strtoustr(unichar * u1,const char *s1,int size)
|
int
|
||||||
|
strtoustr(unichar * u1,const char *s1,int size)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0; (count < size) && (s1[count] != 0); count++)
|
for (count = 0; (count < size) && (s1[count] != 0); count++)
|
||||||
u1[count] = chartouni(s1[count]);
|
u1[count] = chartouni(s1[count]);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ustrtostr(char *s2,unichar *u1,int size)
|
int
|
||||||
|
ustrtostr(char *s2,unichar *u1,int size)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0; (count < size) && (u1[count] != (unichar)0); count++)
|
for (count = 0; (count < size) && (u1[count] != (unichar)0); count++)
|
||||||
s2[count] = unitochar(u1[count]);
|
s2[count] = unitochar(u1[count]);
|
||||||
return(count);
|
return(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int encode_strtoustr(unichar * u1,const char *s1,int size, NSStringEncoding enc)
|
int
|
||||||
|
encode_strtoustr(unichar * u1,const char *s1,int size, NSStringEncoding enc)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0; (count < size) && (s1[count] != 0); count++)
|
for (count = 0; (count < size) && (s1[count] != 0); count++)
|
||||||
u1[count] = encode_chartouni(s1[count], enc);
|
u1[count] = encode_chartouni(s1[count], enc);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int encode_ustrtostr(char *s2,unichar *u1,int size, NSStringEncoding enc)
|
int
|
||||||
|
encode_ustrtostr(char *s2,unichar *u1,int size, NSStringEncoding enc)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
for (count = 0; (count < size) && (u1[count] != (unichar)0); count++)
|
for (count = 0; (count < size) && (u1[count] != (unichar)0); count++)
|
||||||
s2[count] = encode_unitochar(u1[count], enc);
|
s2[count] = encode_unitochar(u1[count], enc);
|
||||||
return(count);
|
return(count);
|
||||||
|
@ -174,6 +210,7 @@ int
|
||||||
uslen (unichar *u)
|
uslen (unichar *u)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
while (u[len] != 0)
|
while (u[len] != 0)
|
||||||
{
|
{
|
||||||
if (u[++len] == 0)
|
if (u[++len] == 0)
|
||||||
|
@ -183,23 +220,28 @@ uslen (unichar *u)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
unichar uni_tolower(unichar ch)
|
unichar
|
||||||
|
uni_tolower(unichar ch)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (((res = ch - t_tolower[count++][0]) > 0) && (count < t_len_tolower));
|
while (((res = ch - t_tolower[count++][0]) > 0) && (count < t_len_tolower));
|
||||||
return res ? ch : t_tolower[--count][1];
|
return res ? ch : t_tolower[--count][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
unichar uni_toupper(unichar ch)
|
unichar
|
||||||
|
uni_toupper(unichar ch)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
while (((res = ch - t_toupper[count++][0]) > 0) && (count < t_len_toupper));
|
while (((res = ch - t_toupper[count++][0]) > 0) && (count < t_len_toupper));
|
||||||
return res ? ch : t_toupper[--count][1];
|
return res ? ch : t_toupper[--count][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char uni_cop(unichar u)
|
unsigned char
|
||||||
|
uni_cop(unichar u)
|
||||||
{
|
{
|
||||||
unichar count,first,last,comp;
|
unichar count,first,last,comp;
|
||||||
BOOL notfound;
|
BOOL notfound;
|
||||||
|
@ -238,7 +280,8 @@ unsigned char uni_cop(unichar u)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL uni_isnonsp(unichar u)
|
BOOL
|
||||||
|
uni_isnonsp(unichar u)
|
||||||
{
|
{
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
@ -249,7 +292,8 @@ BOOL uni_isnonsp(unichar u)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unichar *uni_is_decomp(unichar u)
|
unichar*
|
||||||
|
uni_is_decomp(unichar u)
|
||||||
{
|
{
|
||||||
unichar count,first,last,comp;
|
unichar count,first,last,comp;
|
||||||
BOOL notfound;
|
BOOL notfound;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue