mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-19 03:51:38 +00:00
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:
parent
c280ce26b5
commit
133bdaea80
2 changed files with 47 additions and 5 deletions
|
@ -3,6 +3,9 @@
|
||||||
* Source/NSPropertyList.m:
|
* Source/NSPropertyList.m:
|
||||||
Fix problem considering a lack of whitespace at the end of the
|
Fix problem considering a lack of whitespace at the end of the
|
||||||
list as an error.
|
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>
|
2012-08-08 Riccardo Mottola <rm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -459,21 +459,60 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, NSUInteger mask, NSRange aRange)
|
||||||
|
|
||||||
if (mask & NSCaseInsensitiveSearch)
|
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++)
|
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 c1 = uni_tolower((unichar)sBuf[i]);
|
||||||
unichar c2 = uni_tolower((unichar)oBuf[i]);
|
unichar c2 = uni_tolower((unichar)oBuf[i]);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (c1 < c2)
|
if (c1 < c2)
|
||||||
return NSOrderedAscending;
|
return NSOrderedAscending;
|
||||||
if (c1 > c2)
|
if (c1 > c2)
|
||||||
return NSOrderedDescending;
|
return NSOrderedDescending;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue