From 1a1741dd9da04c2a6e5b15fda129cd5d8b69ee03 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 24 Jan 2007 03:00:11 +0000 Subject: [PATCH] Optimize the recognition of "UTF-8" strings. --- ChangeLog | 6 ++++++ lib/striconveh.c | 9 +++++---- modules/striconveh | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6bae0f0c..54f93e4b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-01-23 Bruno Haible + * lib/striconveh.c: Include c-strcaseeq.h. + (mem_iconveh, str_iconveh): Use STRCASEEQ instead of c_strcasecmp. + * modules/striconveh (Depends-on): Add c-strcaseeq. + +2007-01-23 Bruno Haible + * MODULES.html.sh (String handling): Add streq, c-strcaseeq. * modules/c-strcaseeq: New file. diff --git a/lib/striconveh.c b/lib/striconveh.c index 7feb76816..c1ef0b1fd 100644 --- a/lib/striconveh.c +++ b/lib/striconveh.c @@ -35,6 +35,7 @@ #include "strdup.h" #include "c-strcase.h" +#include "c-strcaseeq.h" #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) @@ -929,7 +930,7 @@ mem_iconveh (const char *src, size_t srclen, if (cd == (iconv_t)(-1)) return -1; - if (c_strcasecmp (from_codeset, "UTF-8") == 0) + if (STRCASEEQ (from_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) cd1 = (iconv_t)(-1); else { @@ -943,7 +944,7 @@ mem_iconveh (const char *src, size_t srclen, } } - if (c_strcasecmp (to_codeset, "UTF-8") == 0) + if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) cd2 = (iconv_t)(-1); else { @@ -1062,7 +1063,7 @@ str_iconveh (const char *src, if (cd == (iconv_t)(-1)) return NULL; - if (c_strcasecmp (from_codeset, "UTF-8") == 0) + if (STRCASEEQ (from_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) cd1 = (iconv_t)(-1); else { @@ -1076,7 +1077,7 @@ str_iconveh (const char *src, } } - if (c_strcasecmp (to_codeset, "UTF-8") == 0) + if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)) cd2 = (iconv_t)(-1); else { diff --git a/modules/striconveh b/modules/striconveh index e3649e082..0aeca22a5 100644 --- a/modules/striconveh +++ b/modules/striconveh @@ -14,6 +14,7 @@ unistr/u8-prev unistr/u8-mbtouc strdup c-strcase +c-strcaseeq configure.ac: if test $gl_cond_libtool = false; then -- 2.11.0