Another use of tolower() found and removed ... retain tolower() when the

internal 8bit encoding in not latin1 and uni_tolower() is therefore not
usable.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35386 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-08-09 18:57:20 +00:00
parent cbbdf7a3df
commit b618b41512
2 changed files with 47 additions and 5 deletions

View file

@ -3,6 +3,9 @@
* Source/NSPropertyList.m:
Fix problem considering a lack of whitespace at the end of the
list as an error.
* GSeq.h: Replace tolower() with uni_tolower() where using 8bit
strings and the internal coding is latin1 and may not be the same
as the native encoding.
2012-08-08 Riccardo Mottola <rm@gnu.org>

View file

@ -459,21 +459,60 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, NSUInteger mask, NSRange aRange)
if (mask & NSCaseInsensitiveSearch)
{
#if GSEQ_O == GSEQ_CS || GSEQ_S == GSEQ_CS
if (GSPrivateDefaultCStringEncoding() == NSISOLatin1StringEncoding)
{
/* Using latin1 internally, rather than native encoding,
* so we can't use native tolower() function.
*/
for (i = 0; i < end; i++)
{
unichar c1 = uni_tolower((unichar)sBuf[i]);
unichar c2 = uni_tolower((unichar)oBuf[i]);
if (c1 < c2)
return NSOrderedAscending;
if (c1 > c2)
return NSOrderedDescending;
}
}
else
{
/* We are not using latin1 encoding internally, so we trust
* that the internal encoding matches the native encoding
* and the native tolower() function will work.
*/
for (i = 0; i < end; i++)
{
#if GSEQ_S == GSEQ_CS
unichar c1 = tolower(sBuf[i]);
#else
unichar c1 = uni_tolower((unichar)sBuf[i]);
#endif
#if GSEQ_O == GSEQ_CS
unichar c2 = tolower(oBuf[i]);
#else
unichar c2 = uni_tolower((unichar)oBuf[i]);
#endif
if (c1 < c2)
return NSOrderedAscending;
if (c1 > c2)
return NSOrderedDescending;
}
}
#else
for (i = 0; i < end; i++)
{
#if GSEQ_O == GSEQ_CS && GSEQ_S == GSEQ_CS
char c1 = tolower(sBuf[i]);
char c2 = tolower(oBuf[i]);
#else
unichar c1 = uni_tolower((unichar)sBuf[i]);
unichar c2 = uni_tolower((unichar)oBuf[i]);
#endif
if (c1 < c2)
return NSOrderedAscending;
if (c1 > c2)
return NSOrderedDescending;
}
#endif
}
else
{