Mercurial > hg > octave-lojdl > gnulib-hg
changeset 8478:1627fd93e51e
Remove module 'iconvme'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 20 Mar 2007 00:35:56 +0000 |
parents | 0327e6475932 |
children | 19b8b337ecaa |
files | ChangeLog NEWS lib/iconvme.c lib/iconvme.h m4/iconvme.m4 modules/iconvme |
diffstat | 6 files changed, 12 insertions(+), 353 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-03-19 Bruno Haible <bruno@clisp.org> + + * modules/iconvme: Remove file. + * lib/iconvme.h: Remove file. + * lib/iconvme.c: Remove file. + * m4/iconvme.m4: Remove file. + 2007-03-19 Bruno Haible <bruno@clisp.org> * doc/relocatable-maint.texi: Break long shell script line.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,11 @@ Date Modules Changes +2007-03-19 iconvme The module is removed. Use module striconv instead: + iconv_string -> str_iconv + iconv_alloc -> str_cd_iconv (with reversed + arguments) + 2007-03-15 list The functions gl_list_create_empty and array-list gl_list_create now take an extra fourth argument. carray-list You can pass NULL.
deleted file mode 100644 --- a/lib/iconvme.c +++ /dev/null @@ -1,273 +0,0 @@ -/* Recode strings between character sets, using iconv. - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - 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. */ - -#include <config.h> - -/* Get prototype. */ -#include "iconvme.h" - -/* Get malloc. */ -#include <stdlib.h> - -/* Get strcmp, strdup. */ -#include <string.h> - -/* Get errno. */ -#include <errno.h> - -#ifdef _LIBC -# define HAVE_ICONV 1 -#endif - -#if HAVE_ICONV -/* Get iconv etc. */ -# include <iconv.h> -/* Get MB_LEN_MAX, CHAR_BIT. */ -# include <limits.h> -#endif - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -/* Convert a zero-terminated string STR from the FROM_CODSET code set - to the TO_CODESET code set. The returned string is allocated using - malloc, and must be dellocated by the caller using free. On - failure, NULL is returned and errno holds the error reason. Note - that if TO_CODESET uses \0 for anything but to terminate the - string, the caller of this function may have difficulties finding - out the length of the output string. */ -char * -iconv_string (const char *str, const char *from_codeset, - const char *to_codeset) -{ - char *dest = NULL; -#if HAVE_ICONV - iconv_t cd; -#endif - - if (strcmp (to_codeset, from_codeset) == 0) - return strdup (str); - -#if HAVE_ICONV - cd = iconv_open (to_codeset, from_codeset); - if (cd == (iconv_t) -1) - return NULL; - - dest = iconv_alloc (cd, str); - - if (dest == NULL) - { - int saved_errno = errno; - iconv_close (cd); - errno = saved_errno; - } - else - { - if (iconv_close (cd) < 0) - { - int saved_errno2 = errno; - /* If we didn't have a real error before, make sure we restore - the iconv_close error below. */ - free (dest); - dest = NULL; - errno = saved_errno2; - } - } -#else - errno = ENOSYS; -#endif - - return dest; -} - -/* Convert a zero-terminated string STR using iconv descriptor CD. - The returned string is allocated using malloc, and must be - dellocated by the caller using free. On failure, NULL is returned - and errno holds the error reason. Note that if the target - character set uses \0 for anything but to terminate the string, - the caller of this function may have difficulties finding - out the length of the output string. */ -#if HAVE_ICONV -char * -iconv_alloc (iconv_t cd, const char *str) -{ - char *dest; - char *p = (char *) str; - char *outp; - size_t inbytes_remaining = strlen (p); - /* Guess the maximum length the output string can have. */ - size_t outbuf_size = inbytes_remaining + 1; - size_t outbytes_remaining; - size_t err; - int have_error = 0; - - /* Use a worst-case output size guess, so long as that wouldn't be - too large for comfort. It's OK if the guess is wrong so long as - it's nonzero. */ - size_t approx_sqrt_SIZE_MAX = SIZE_MAX >> (sizeof (size_t) * CHAR_BIT / 2); - if (outbuf_size <= approx_sqrt_SIZE_MAX / MB_LEN_MAX) - outbuf_size *= MB_LEN_MAX; - outbytes_remaining = outbuf_size - 1; - - outp = dest = (char *) malloc (outbuf_size); - if (dest == NULL) - { - errno = ENOMEM; - return NULL; - } - - /* 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 - -again: - err = iconv (cd, &p, &inbytes_remaining, &outp, &outbytes_remaining); - - if (err == (size_t) -1) - { - switch (errno) - { - case EINVAL: - /* Incomplete text, do not report an error */ - break; - - case E2BIG: - { - size_t used = outp - dest; - size_t newsize = outbuf_size * 2; - char *newdest; - - if (newsize <= outbuf_size) - { - errno = ENOMEM; - have_error = 1; - goto out; - } - newdest = (char *) realloc (dest, newsize); - if (newdest == NULL) - { - errno = ENOMEM; - have_error = 1; - goto out; - } - dest = newdest; - outbuf_size = newsize; - - outp = dest + used; - outbytes_remaining = outbuf_size - used - 1; /* -1 for NUL */ - - goto again; - } - break; - - case EILSEQ: - have_error = 1; - break; - - default: - have_error = 1; - break; - } - } -# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) - /* Irix iconv() inserts a NUL byte if it cannot convert. */ - else if (err > 0) - { - errno = EILSEQ; - have_error = 1; - goto out; - } -# endif - -again2: - err = iconv (cd, NULL, NULL, &outp, &outbytes_remaining); - - if (err == (size_t) -1) - { - switch (errno) - { - case E2BIG: - { - size_t used = outp - dest; - size_t newsize = outbuf_size * 2; - char *newdest; - - if (newsize <= outbuf_size) - { - errno = ENOMEM; - have_error = 1; - goto out; - } - newdest = (char *) realloc (dest, newsize); - if (newdest == NULL) - { - errno = ENOMEM; - have_error = 1; - goto out; - } - dest = newdest; - outbuf_size = newsize; - - outp = dest + used; - outbytes_remaining = outbuf_size - used - 1; /* -1 for NUL */ - - goto again2; - } - break; - - default: - have_error = 1; - break; - } - } -# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) - /* Irix iconv() inserts a NUL byte if it cannot convert. */ - else if (err > 0) - { - errno = EILSEQ; - have_error = 1; - goto out; - } -# endif - - *outp++ = '\0'; - - /* Give away unused memory. */ - if (outp - dest < outbuf_size) - { - char *newdest = (char *) realloc (dest, outp - dest); - - if (newdest != NULL) - dest = newdest; - } - -out: - if (have_error) - { - int save_errno = errno; - free (dest); - errno = save_errno; - dest = NULL; - } - - return dest; -} -#endif
deleted file mode 100644 --- a/lib/iconvme.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Recode strings between character sets, using iconv. - Copyright (C) 2004 Free Software Foundation, Inc. - Written by Simon Josefsson. - - 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 ICONVME_H -# define ICONVME_H - -extern char *iconv_string (const char *string, const char *from_code, - const char *to_code); - -#if HAVE_ICONV -# include <iconv.h> -extern char *iconv_alloc (iconv_t cd, const char *string); -#endif - -#endif /* ICONVME_H */
deleted file mode 100644 --- a/m4/iconvme.m4 +++ /dev/null @@ -1,17 +0,0 @@ -# iconvme.m4 serial 1 -dnl Copyright (C) 2004 Free Software Foundation, Inc. -dnl This file is free software, distributed under the terms of the GNU -dnl General Public License. As a special exception to the GNU General -dnl Public License, this file may be distributed as part of a program -dnl that contains a configuration script generated by Autoconf, under -dnl the same distribution terms as the rest of that program. - -AC_DEFUN([gl_ICONVME], -[ - gl_PREREQ_ICONVME -]) - -# Prerequisites of lib/iconvme.c. -AC_DEFUN([gl_PREREQ_ICONVME], [ - AC_REQUIRE([AM_ICONV]) -])
deleted file mode 100644 --- a/modules/iconvme +++ /dev/null @@ -1,33 +0,0 @@ -Description: -Character set conversion of strings made easy, uses iconv. - -Files: -lib/iconvme.h -lib/iconvme.c -m4/iconvme.m4 - -Depends-on: -iconv -strdup - -configure.ac: -gl_ICONVME -if test $gl_cond_libtool = false; then - gl_ltlibdeps="$gl_ltlibdeps $LTLIBICONV" - gl_libdeps="$gl_libdeps $LIBICONV" -fi - -Makefile.am: -lib_SOURCES += iconvme.h iconvme.c -if GL_COND_LIBTOOL -lib_LDFLAGS += $(LTLIBICONV) -endif - -Include: -"iconvme.h" - -License: -LGPL - -Maintainer: -Simon Josefsson