diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rwxr-xr-x | autogen.sh | 2 | ||||
-rw-r--r-- | gettext-runtime/src/Makefile.am | 2 | ||||
-rw-r--r-- | gettext-tools/src/ChangeLog | 8 | ||||
-rw-r--r-- | gettext-tools/src/msgl-iconv.c | 12 | ||||
-rw-r--r-- | gettext-tools/src/recode-sr-latin.c | 11 | ||||
-rw-r--r-- | gnulib-local/ChangeLog | 13 | ||||
-rw-r--r-- | gnulib-local/Makefile.am | 3 | ||||
-rw-r--r-- | gnulib-local/lib/iconvstring.c | 239 | ||||
-rw-r--r-- | gnulib-local/lib/iconvstring.h | 51 | ||||
-rw-r--r-- | gnulib-local/lib/propername.c | 62 | ||||
-rw-r--r-- | gnulib-local/modules/gettext-tools-misc | 2 | ||||
-rw-r--r-- | gnulib-local/modules/iconvstring | 25 | ||||
-rw-r--r-- | gnulib-local/modules/propername | 2 |
14 files changed, 52 insertions, 385 deletions
@@ -1,3 +1,8 @@ +2006-09-06 Bruno Haible <bruno@clisp.org> + + * autogen.sh (GNULIB_MODULES_FOR_SRC): Add xstriconv, remove + iconvstring. + 2006-08-26 Bruno Haible <bruno@clisp.org> * m4/woe32-dll.m4: Update comments. @@ -110,7 +110,6 @@ if test -n "$GNULIB_TOOL"; then gettext-h hash iconv - iconvstring javacomp javaexec linebreak @@ -131,6 +130,7 @@ if test -n "$GNULIB_TOOL"; then stpcpy stpncpy strcspn + xstriconv strpbrk strtol strtoul diff --git a/gettext-runtime/src/Makefile.am b/gettext-runtime/src/Makefile.am index 289d360..5657efa 100644 --- a/gettext-runtime/src/Makefile.am +++ b/gettext-runtime/src/Makefile.am @@ -38,7 +38,7 @@ ngettext_SOURCES = ngettext.c envsubst_SOURCES = envsubst.c # Link dependencies. -# Need @LTLIBICONV@ because iconvstring.c uses iconv(). +# Need @LTLIBICONV@ because striconv.c uses iconv(). LDADD = ../gnulib-lib/libgrt.a @LTLIBINTL@ @LTLIBICONV@ # Specify installation directory, for --enable-relocatable. diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 586edfa..5191d8f 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2006-09-06 Bruno Haible <bruno@clisp.org> + + * msgl-iconv.c: Include xstriconv.h instead of iconvstring.h. + (convert_string, convert_msgstr, iconvable_string, iconvable_msgstr): + Use xmem_cd_iconv instead of iconv_string. + * recode-sr-latin.c: Include xstriconv.h instead of iconvstring.h. + (process): Use xmem_cd_iconv instead of iconv_string. + 2006-09-04 Bruno Haible <bruno@clisp.org> * Makefile.am (msginit_SOURCES): Add ../../gettext-runtime/intl/lock.c. diff --git a/gettext-tools/src/msgl-iconv.c b/gettext-tools/src/msgl-iconv.c index 957fe4f..61afda8 100644 --- a/gettext-tools/src/msgl-iconv.c +++ b/gettext-tools/src/msgl-iconv.c @@ -37,7 +37,7 @@ #include "basename.h" #include "message.h" #include "po-charset.h" -#include "iconvstring.h" +#include "xstriconv.h" #include "msgl-ascii.h" #include "xalloc.h" #include "xallocsa.h" @@ -82,7 +82,7 @@ convert_string (iconv_t cd, const char *string, char *result = NULL; size_t resultlen; - if (iconv_string (cd, string, string + len, &result, &resultlen) == 0) + if (xmem_cd_iconv (string, len, cd, &result, &resultlen) == 0) /* Verify the result has exactly one NUL byte, at the end. */ if (resultlen > 0 && result[resultlen - 1] == '\0' && strlen (result) == resultlen - 1) @@ -125,8 +125,7 @@ convert_msgstr (iconv_t cd, message_ty *mp, if (!(mp->msgstr_len > 0 && mp->msgstr[mp->msgstr_len - 1] == '\0')) abort (); - if (iconv_string (cd, mp->msgstr, mp->msgstr + mp->msgstr_len, - &result, &resultlen) == 0) + if (xmem_cd_iconv (mp->msgstr, mp->msgstr_len, cd, &result, &resultlen) == 0) /* Verify the result has a NUL byte at the end. */ if (resultlen > 0 && result[resultlen - 1] == '\0') /* Verify the result has the same number of NUL bytes. */ @@ -349,7 +348,7 @@ iconvable_string (iconv_t cd, const char *string) char *result = NULL; size_t resultlen; - if (iconv_string (cd, string, string + len, &result, &resultlen) == 0) + if (xmem_cd_iconv (string, len, cd, &result, &resultlen) == 0) { /* Test if the result has exactly one NUL byte, at the end. */ bool ok = (resultlen > 0 && result[resultlen - 1] == '\0' @@ -395,8 +394,7 @@ iconvable_msgstr (iconv_t cd, message_ty *mp) if (!(mp->msgstr_len > 0 && mp->msgstr[mp->msgstr_len - 1] == '\0')) abort (); - if (iconv_string (cd, mp->msgstr, mp->msgstr + mp->msgstr_len, - &result, &resultlen) == 0) + if (xmem_cd_iconv (mp->msgstr, mp->msgstr_len, cd, &result, &resultlen) == 0) { bool ok = false; diff --git a/gettext-tools/src/recode-sr-latin.c b/gettext-tools/src/recode-sr-latin.c index a74bd90..c2a69c0 100644 --- a/gettext-tools/src/recode-sr-latin.c +++ b/gettext-tools/src/recode-sr-latin.c @@ -40,7 +40,7 @@ #include "exit.h" #include "localcharset.h" #include "c-strcase.h" -#include "iconvstring.h" +#include "xstriconv.h" #include "filters.h" #include "propername.h" #include "gettext.h" @@ -326,8 +326,8 @@ This version was built without iconv()."), /* Convert it to UTF-8. */ if (need_code_conversion) { - if (iconv_string (conv_to_utf8, line, line + line_len, - &utf8_line, &utf8_line_len) != 0) + if (xmem_cd_iconv (line, line_len, conv_to_utf8, + &utf8_line, &utf8_line_len) != 0) error (EXIT_FAILURE, errno, _("input is not valid in \"%s\" encoding"), locale_code); @@ -343,9 +343,8 @@ This version was built without iconv()."), /* Convert it back to the original encoding. */ if (need_code_conversion) { - if (iconv_string (conv_from_utf8, - filtered_line, filtered_line + filtered_line_len, - &backconv_line, &backconv_line_len) != 0) + if (xmem_cd_iconv (filtered_line, filtered_line_len, conv_from_utf8, + &backconv_line, &backconv_line_len) != 0) error (EXIT_FAILURE, errno, _("error while converting from \"%s\" encoding to \"%s\" encoding"), "UTF-8", locale_code); diff --git a/gnulib-local/ChangeLog b/gnulib-local/ChangeLog index 675a5a9..0ba4b96 100644 --- a/gnulib-local/ChangeLog +++ b/gnulib-local/ChangeLog @@ -1,3 +1,16 @@ +2006-09-06 Bruno Haible <bruno@clisp.org> + + * modules/iconvstring: Remove file. + * lib/iconvstring.h: Remove file. + * lib/iconvstring.c: Remove file. + * Makefile.am (EXTRA_DIST): Remove modules/iconvstring, + lib/iconvstring.h, lib/iconvstring.c. + + * lib/propername.c: Include xstriconv.h instead of iconvstring.h. + (convert_name): Remove function. + (proper_name_utf8): Use xstr_iconv instead of convert_name. + * modules/propername: Depend on xstriconv instead of iconvstring. + 2006-08-30 Bruno Haible <bruno@clisp.org> * lib/xerror.h: Don't include error.h. diff --git a/gnulib-local/Makefile.am b/gnulib-local/Makefile.am index 97200e3..4574854 100644 --- a/gnulib-local/Makefile.am +++ b/gnulib-local/Makefile.am @@ -55,8 +55,6 @@ lib/getopt_.h.diff \ lib/gettext.h \ lib/hash.c \ lib/hash.h \ -lib/iconvstring.c \ -lib/iconvstring.h \ lib/javacomp.c.diff \ lib/linebreak.c.diff \ lib/obstack.h.diff \ @@ -113,7 +111,6 @@ modules/getndelim2 \ modules/gettext-runtime-misc \ modules/gettext-tools-misc \ modules/hash \ -modules/iconvstring \ modules/java \ modules/javacomp.diff \ modules/pathmax.diff \ diff --git a/gnulib-local/lib/iconvstring.c b/gnulib-local/lib/iconvstring.c deleted file mode 100644 index b09f9e9..0000000 --- a/gnulib-local/lib/iconvstring.c +++ /dev/null @@ -1,239 +0,0 @@ -/* Charset conversion. - Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc. - Written by Bruno Haible <haible@clisp.cons.org>, 2001. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -/* Specification. */ -#include "iconvstring.h" - -#include <errno.h> -#include <stdlib.h> - -#if HAVE_ICONV -# include <iconv.h> -#endif - -#include "xalloc.h" - - -#if HAVE_ICONV - -/* POSIX does not specify clearly what happens when a character in the - source encoding is valid but cannot be represented in the destination - encoding. - GNU libc and libiconv stop the conversion in this case, with errno = EINVAL. - Irix iconv() inserts a NUL byte in this case. NetBSD iconv() inserts - a '?' byte. For other implementations, we don't know. Normally the - number of failed conversions is available as the iconv() result. - The problem with these implementations is that when iconv() fails, for - example with errno = E2BIG or = EINVAL, the number of failed conversions - gets lost. As a workaround, we need to process the input string slowly, - byte after byte. */ -# if !(defined __GLIBC__ || defined _LIBICONV_VERSION) -# define UNSAFE_ICONV -# endif - -/* Converts an entire string from one encoding to another, using iconv. - Return value: 0 if successful, otherwise -1 and errno set. */ -int -iconv_string (iconv_t cd, const char *start, const char *end, - char **resultp, size_t *lengthp) -{ -#define tmpbufsize 4096 - size_t length; - char *result; -# ifdef UNSAFE_ICONV - int expect_einval = 0; -# endif - - /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ -# if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) - /* Set to the initial state. */ - iconv (cd, NULL, NULL, NULL, NULL); -# endif - - /* Determine the length we need. */ - { - size_t count = 0; - char tmpbuf[tmpbufsize]; - const char *inptr = start; - size_t insize = end - start; - - while (insize > 0) - { - char *outptr = tmpbuf; - size_t outsize = tmpbufsize; - size_t res = iconv (cd, - (ICONV_CONST char **) &inptr, &insize, - &outptr, &outsize); - - if (res == (size_t)(-1)) - { - if (errno == E2BIG) - ; - else if (errno == EINVAL) - { -# ifdef UNSAFE_ICONV - expect_einval = 1; -# endif - break; - } - else - return -1; - } -# ifdef UNSAFE_ICONV - else if (res > 0) - return -1; -# endif - count += outptr - tmpbuf; - } - /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ -# if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) - { - char *outptr = tmpbuf; - size_t outsize = tmpbufsize; - size_t res = iconv (cd, NULL, NULL, &outptr, &outsize); - - if (res == (size_t)(-1)) - return -1; - count += outptr - tmpbuf; - } -# endif - length = count; - } - - *lengthp = length; - *resultp = result = xrealloc (*resultp, length); - if (length == 0) - return 0; - - /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ -# if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) - /* Return to the initial state. */ - iconv (cd, NULL, NULL, NULL, NULL); -# endif - - /* Do the conversion for real. */ - { - const char *inptr = start; - char *outptr = result; - size_t outsize = length; - -# ifdef UNSAFE_ICONV - if (expect_einval) - { - /* Process the characters one by one, so as to not lose the - number of conversion failures. */ - const char *inptr_end = end; - - while (inptr < inptr_end) - { - size_t insize_max = inptr_end - inptr; - size_t insize_avail; - size_t res; - - for (insize_avail = 1; ; insize_avail++) - { - /* Here 1 <= insize_avail <= insize_max. */ - size_t insize = insize_avail; - - res = iconv (cd, - (ICONV_CONST char **) &inptr, &insize, - &outptr, &outsize); - if (res == (size_t)(-1)) - { - if (errno == EINVAL) - { - if (insize_avail < insize_max) - continue; - else - break; - } - else - /* E2BIG and other errors shouldn't happen in this - round any more. */ - return -1; - } - else - break; - } - if (res == (size_t)(-1)) - /* errno = EINVAL. Ignore the trailing incomplete character. */ - break; - else if (res > 0) - return -1; - } - } - else -# endif - { - size_t insize = end - start; - - while (insize > 0) - { - size_t res = iconv (cd, - (ICONV_CONST char **) &inptr, &insize, - &outptr, &outsize); - - if (res == (size_t)(-1)) - { - if (errno == EINVAL) - { -# ifdef UNSAFE_ICONV - /* EINVAL should already have occurred in the first - round. */ - abort (); -# endif - /* Ignore the trailing incomplete character. */ - break; - } - else - /* E2BIG and other errors shouldn't happen in this round - any more. */ - return -1; - } -# ifdef UNSAFE_ICONV - else if (res > 0) - return -1; -# endif - } - } - /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ -# if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) - { - size_t res = iconv (cd, NULL, NULL, &outptr, &outsize); - - if (res == (size_t)(-1)) - return -1; - } -# endif - if (outsize != 0) - abort (); - } - - return 0; -#undef tmpbufsize -} - -#endif diff --git a/gnulib-local/lib/iconvstring.h b/gnulib-local/lib/iconvstring.h deleted file mode 100644 index 4ab5f96..0000000 --- a/gnulib-local/lib/iconvstring.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Charset conversion. - Copyright (C) 2001-2003, 2006 Free Software Foundation, Inc. - Written by Bruno Haible <haible@clisp.cons.org>, 2001. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _ICONVSTRING_H -#define _ICONVSTRING_H - -#include <stddef.h> -#if HAVE_ICONV -#include <iconv.h> -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -#if HAVE_ICONV - -/* Convert an entire string from one encoding to another, using iconv. - *RESULTP should initially contain NULL or malloced memory block. - Return value: 0 if successful, otherwise -1 and errno set. - If successful, the resulting string is stored in *RESULTP and its length - in *LENGTHP. */ -extern int iconv_string (iconv_t cd, const char *start, const char *end, - char **resultp, size_t *lengthp); - -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* _ICONVSTRING_H */ diff --git a/gnulib-local/lib/propername.c b/gnulib-local/lib/propername.c index f66d828..56c4bc7 100644 --- a/gnulib-local/lib/propername.c +++ b/gnulib-local/lib/propername.c @@ -32,7 +32,7 @@ #include "localcharset.h" #include "c-strcase.h" -#include "iconvstring.h" +#include "xstriconv.h" #include "c-strstr.h" #include "strstr.h" #include "xalloc.h" @@ -66,38 +66,6 @@ proper_name (const char *name) return name; } -#if HAVE_ICONV - -static char * -convert_name (const char *locale_code, const char *name_utf8) -{ - /* Open conversion descriptor. */ - iconv_t conv_from_utf8 = iconv_open (locale_code, "UTF-8"); - - if (conv_from_utf8 != (iconv_t)(-1)) - { - char *name_converted = NULL; - size_t length; - - /* Convert the name to the locale encoding. */ - if (iconv_string (conv_from_utf8, - name_utf8, name_utf8 + strlen (name_utf8) + 1, - &name_converted, &length) == 0) - /* Verify that the converted string is terminated. */ - if (!(length > 0 && name_converted[length - 1] == '\0')) - abort (); - - /* Free the conversion descriptor. */ - iconv_close (conv_from_utf8); - - return name_converted; - } - else - return NULL; -} - -#endif - /* Return the localization of a name whose original writing is not ASCII. NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal escape sequences. NAME_ASCII is a fallback written only with ASCII @@ -120,29 +88,23 @@ proper_name_utf8 (const char *name_ascii, const char *name_utf8) if (c_strcasecmp (locale_code, "UTF-8") != 0) { #if HAVE_ICONV - /* Avoid glibc-2.1 bug with EUC-KR. */ -# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION - if (strcmp (locale_code, "EUC-KR") != 0) -# endif - { - name_converted = alloc_name_converted = - convert_name (locale_code, name_utf8); + name_converted = alloc_name_converted = + xstr_iconv (name_utf8, "UTF-8", locale_code); # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \ || _LIBICONV_VERSION >= 0x0105 - { - size_t len = strlen (locale_code); - char *locale_code_translit = (char *) xmalloc (len + 10 + 1); - memcpy (locale_code_translit, locale_code, len); - memcpy (locale_code_translit + len, "//TRANSLIT", 10 + 1); + { + size_t len = strlen (locale_code); + char *locale_code_translit = (char *) xmalloc (len + 10 + 1); + memcpy (locale_code_translit, locale_code, len); + memcpy (locale_code_translit + len, "//TRANSLIT", 10 + 1); - name_converted_translit = alloc_name_converted_translit = - convert_name (locale_code_translit, name_utf8); + name_converted_translit = alloc_name_converted_translit = + xstr_iconv (name_utf8, "UTF-8", locale_code_translit); - free (locale_code_translit); - } + free (locale_code_translit); + } # endif - } #endif } else diff --git a/gnulib-local/modules/gettext-tools-misc b/gnulib-local/modules/gettext-tools-misc index e62a93a..9395bbb 100644 --- a/gnulib-local/modules/gettext-tools-misc +++ b/gnulib-local/modules/gettext-tools-misc @@ -21,7 +21,7 @@ AM_CPPFLAGS += -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 lib_LTLIBRARIES = libgettextlib.la # Need @LTLIBINTL@ because many source files use gettext(). -# Need @LTLIBICONV@ because linebreak.c and iconvstring.c use iconv(). +# Need @LTLIBICONV@ because linebreak.c and striconv.c use iconv(). lib_LDFLAGS = \ -release @VERSION@ \ @LTLIBINTL@ @LTLIBICONV@ -lc @LTNOUNDEF@ diff --git a/gnulib-local/modules/iconvstring b/gnulib-local/modules/iconvstring deleted file mode 100644 index 7905b84..0000000 --- a/gnulib-local/modules/iconvstring +++ /dev/null @@ -1,25 +0,0 @@ -Description: -Charset conversion. - -Files: -lib/iconvstring.h -lib/iconvstring.c - -Depends-on: -iconv -xalloc - -configure.ac: - -Makefile.am: -lib_SOURCES += iconvstring.h iconvstring.c - -Include: -"iconvstring.h" - -License: -GPL - -Maintainer: -Bruno Haible - diff --git a/gnulib-local/modules/propername b/gnulib-local/modules/propername index f4a4293..4ab93eb 100644 --- a/gnulib-local/modules/propername +++ b/gnulib-local/modules/propername @@ -9,7 +9,7 @@ Depends-on: iconv localcharset c-strcase -iconvstring +xstriconv c-strstr strstr xalloc |