summaryrefslogtreecommitdiff
path: root/lib/unistr/u-strcoll.h
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:17 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:17 +0200
commitbd6adfa17d453e4c486e36fed4c5779db90a8a0e (patch)
tree9798677560d5f99061afe9f0db105a8c97f2438a /lib/unistr/u-strcoll.h
parent79ca645d222db2e158784642c3b464a47bea26f3 (diff)
parent3e0814cd9862b89c7a39672672937477bd87ddfb (diff)
Merge commit 'upstream/0.9.3'
Diffstat (limited to 'lib/unistr/u-strcoll.h')
-rw-r--r--lib/unistr/u-strcoll.h76
1 files changed, 41 insertions, 35 deletions
diff --git a/lib/unistr/u-strcoll.h b/lib/unistr/u-strcoll.h
index af404a0..9ec5c60 100644
--- a/lib/unistr/u-strcoll.h
+++ b/lib/unistr/u-strcoll.h
@@ -1,6 +1,6 @@
/* Compare UTF-8/UTF-16/UTF-32 strings using the collation rules of the current
locale.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -32,48 +32,54 @@ FUNC (const UNIT *s1, const UNIT *s2)
{
sl2 = U_STRCONV_TO_LOCALE (s2);
if (sl2 != NULL)
- {
- /* Compare sl1 and sl2. */
- errno = 0;
- result = strcoll (sl1, sl2);
- if (errno == 0)
- {
- /* strcoll succeeded. */
- free (sl1);
- free (sl2);
- }
- else
- {
- /* strcoll failed. */
- final_errno = errno;
- free (sl1);
- free (sl2);
- result = U_STRCMP (s1, s2);
- }
- }
+ {
+ /* Compare sl1 and sl2. */
+ errno = 0;
+ result = strcoll (sl1, sl2);
+ if (errno == 0)
+ {
+ /* strcoll succeeded. */
+ free (sl1);
+ free (sl2);
+ /* The conversion to locale encoding can do transliteration or
+ map some characters to question marks. Therefore sl1 and sl2
+ may be equal when s1 and s2 were in fact different. Return a
+ nonzero result in this case. */
+ if (result == 0)
+ result = U_STRCMP (s1, s2);
+ }
+ else
+ {
+ /* strcoll failed. */
+ final_errno = errno;
+ free (sl1);
+ free (sl2);
+ result = U_STRCMP (s1, s2);
+ }
+ }
else
- {
- /* s1 could be converted to locale encoding, s2 not. */
- final_errno = errno;
- free (sl1);
- result = -1;
- }
+ {
+ /* s1 could be converted to locale encoding, s2 not. */
+ final_errno = errno;
+ free (sl1);
+ result = -1;
+ }
}
else
{
final_errno = errno;
sl2 = U_STRCONV_TO_LOCALE (s2);
if (sl2 != NULL)
- {
- /* s2 could be converted to locale encoding, s1 not. */
- free (sl2);
- result = 1;
- }
+ {
+ /* s2 could be converted to locale encoding, s1 not. */
+ free (sl2);
+ result = 1;
+ }
else
- {
- /* Neither s1 nor s2 could be converted to locale encoding. */
- result = U_STRCMP (s1, s2);
- }
+ {
+ /* Neither s1 nor s2 could be converted to locale encoding. */
+ result = U_STRCMP (s1, s2);
+ }
}
errno = final_errno;