summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-05-24 23:00:42 +0200
committerBruno Haible <bruno@clisp.org>2010-05-24 23:00:42 +0200
commitd270926f2e82e654f9cabd4a895c283edb5c2183 (patch)
treee39d978bf29647a6d1c05d17d782b234da861665 /lib
parent5a0f3aa0ee6303d63d3d784a41b3687c558a19f5 (diff)
downloadgnulib-d270926f2e82e654f9cabd4a895c283edb5c2183.tar.gz
Don't use conversion with transliteration in u{8,16,32}_strcoll.
Diffstat (limited to 'lib')
-rw-r--r--lib/unistr/u-strcoll.h19
-rw-r--r--lib/unistr/u16-strcoll.c2
-rw-r--r--lib/unistr/u32-strcoll.c2
-rw-r--r--lib/unistr/u8-strcoll.c2
4 files changed, 15 insertions, 10 deletions
diff --git a/lib/unistr/u-strcoll.h b/lib/unistr/u-strcoll.h
index 9ec5c60170..62addbaf1a 100644
--- a/lib/unistr/u-strcoll.h
+++ b/lib/unistr/u-strcoll.h
@@ -23,14 +23,19 @@ FUNC (const UNIT *s1, const UNIT *s2)
When it fails, it sets errno, but also returns a meaningful return value,
for the sake of callers which ignore errno. */
int final_errno = errno;
+ const char *encoding = locale_charset ();
char *sl1;
char *sl2;
int result;
- sl1 = U_STRCONV_TO_LOCALE (s1);
+ /* Pass iconveh_error here, not iconveh_question_mark. Otherwise the
+ conversion to locale encoding can do transliteration or map some
+ characters to question marks, leading to results that depend on the
+ iconv() implementation and are not obvious. */
+ sl1 = U_STRCONV_TO_ENCODING (s1, encoding, iconveh_error);
if (sl1 != NULL)
{
- sl2 = U_STRCONV_TO_LOCALE (s2);
+ sl2 = U_STRCONV_TO_ENCODING (s2, encoding, iconveh_error);
if (sl2 != NULL)
{
/* Compare sl1 and sl2. */
@@ -41,10 +46,10 @@ FUNC (const UNIT *s1, const UNIT *s2)
/* 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. */
+ /* The conversion to locale encoding can drop Unicode TAG
+ characters. 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);
}
@@ -68,7 +73,7 @@ FUNC (const UNIT *s1, const UNIT *s2)
else
{
final_errno = errno;
- sl2 = U_STRCONV_TO_LOCALE (s2);
+ sl2 = U_STRCONV_TO_ENCODING (s2, encoding, iconveh_error);
if (sl2 != NULL)
{
/* s2 could be converted to locale encoding, s1 not. */
diff --git a/lib/unistr/u16-strcoll.c b/lib/unistr/u16-strcoll.c
index 5a504bf4d9..b75ba34a3d 100644
--- a/lib/unistr/u16-strcoll.c
+++ b/lib/unistr/u16-strcoll.c
@@ -29,5 +29,5 @@
#define FUNC u16_strcoll
#define UNIT uint16_t
#define U_STRCMP u16_strcmp
-#define U_STRCONV_TO_LOCALE u16_strconv_to_locale
+#define U_STRCONV_TO_ENCODING u16_strconv_to_encoding
#include "u-strcoll.h"
diff --git a/lib/unistr/u32-strcoll.c b/lib/unistr/u32-strcoll.c
index 9748855342..95bab07575 100644
--- a/lib/unistr/u32-strcoll.c
+++ b/lib/unistr/u32-strcoll.c
@@ -29,5 +29,5 @@
#define FUNC u32_strcoll
#define UNIT uint32_t
#define U_STRCMP u32_strcmp
-#define U_STRCONV_TO_LOCALE u32_strconv_to_locale
+#define U_STRCONV_TO_ENCODING u32_strconv_to_encoding
#include "u-strcoll.h"
diff --git a/lib/unistr/u8-strcoll.c b/lib/unistr/u8-strcoll.c
index 9ffa135e68..b4d01061cf 100644
--- a/lib/unistr/u8-strcoll.c
+++ b/lib/unistr/u8-strcoll.c
@@ -29,5 +29,5 @@
#define FUNC u8_strcoll
#define UNIT uint8_t
#define U_STRCMP u8_strcmp
-#define U_STRCONV_TO_LOCALE u8_strconv_to_locale
+#define U_STRCONV_TO_ENCODING u8_strconv_to_encoding
#include "u-strcoll.h"