]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New library module 'iconvstring'.
authorBruno Haible <bruno@clisp.org>
Wed, 29 Mar 2006 11:26:37 +0000 (11:26 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:04 +0000 (12:13 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/Makefile.am
gettext-tools/lib/Makefile.msvc
gettext-tools/lib/Makefile.vms
gettext-tools/src/ChangeLog
gettext-tools/src/msgl-iconv.c

index 59ab2fa893cc4bc5a85eb4a3ba5f64ac8b2e392a..740a1b94803cb316f8558b8cfac517b17b4ae85d 100644 (file)
@@ -1,3 +1,13 @@
+2006-03-28  Bruno Haible  <bruno@clisp.org>
+
+       * iconvstring.h: New file.
+       * iconvstring.c: New file, mostly extracted from ../src/msgl-iconv.c.
+       * Makefile.am (libgettextlib_la_SOURCES): Add them.
+       * Makefile.msvc (OBJECTS): Add iconvstring.obj.
+       (iconvstring.obj): New rule.
+       * Makefile.vms (OBJECTS): Add iconvstring.obj.
+       (iconvstring.obj): New rule.
+
 2006-03-12  Bruno Haible  <bruno@clisp.org>
 
        * javaexec.sh.in: Update for changed javaexec.m4.
index c34c6a258bcd5d9fbcedcb4b714f69c5ae426708..8fa7373567babd6b08d53b2f899af0be2558106b 100644 (file)
@@ -56,6 +56,7 @@ libgettextlib_la_SOURCES = \
   fwriteerror.h fwriteerror.c \
   gcd.h gcd.c \
   hash.h hash.c \
+  iconvstring.h iconvstring.c \
   javacomp.h javacomp.c \
   javaexec.h javaexec.c \
   linebreak.h linebreak.c lbrkprop.h utf8-ucs4.h utf16-ucs4.h \
index d5d49977badafda4918cf1334838764b83548ed2..a4525ed54f5bf2009a9fdecf4a46ad07ae4fe079 100644 (file)
@@ -102,6 +102,7 @@ OBJECTS = \
   fwriteerror.obj \
   gcd.obj \
   hash.obj \
+  iconvstring.obj \
   javacomp.obj \
   javaexec.obj \
   linebreak.obj \
@@ -207,6 +208,9 @@ gcd.obj : gcd.c
 hash.obj : hash.c
        $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c hash.c
 
+iconvstring.obj : iconvstring.c
+       $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c iconvstring.c
+
 javacomp.obj : javacomp.c
        $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c javacomp.c
 
index 07557a14107cf041516de14cb1dc1eb757eb02b0..41d6a2562d8ff4efb5b4c5d97cc45e9daf4564ce 100644 (file)
@@ -60,6 +60,7 @@ OBJECTS = \
   fwriteerror.obj, \
   gcd.obj, \
   hash.obj, \
+  iconvstring.obj, \
   javacomp.obj, \
   javaexec.obj, \
   linebreak.obj, \
@@ -169,6 +170,9 @@ gcd.obj : gcd.c
 hash.obj : hash.c
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) hash.c
 
+iconvstring.obj : iconvstring.c
+       $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) iconvstring.c
+
 javacomp.obj : javacomp.c,alloca.h
        $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) javacomp.c
 
index 3530975c34bf0f029126dc9f6757c173c9149ac4..e3c3ffd0612f8d2c1363cf0a35ac83ca75ce1ffa 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-28  Bruno Haible  <bruno@clisp.org>
+
+       * msgl-iconv.c: Include iconvstring.h. Don't include <errno.h>.
+       (iconv_string): Remove function, moved to ../lib/.
+
 2006-03-19  Bruno Haible  <bruno@clisp.org>
 
        * xgettext.h (struct callshape): New field 'xcomments'.
@@ -9,6 +14,7 @@
        (arglist_parser_done): After calling remember_a_message, attach the
        specified extracted comments.
        * x-perl.c (extract_variable): Update.
+       Suggested by Behdad Esfahbod <behdad@cs.toronto.edu>.
 
 2006-03-19  Bruno Haible  <bruno@clisp.org>
 
index 123ef4925cc6554f975abf89f49ccb98526da337..163cdf1c5b02fff57cc5cf1fe60bfdc3f0ac1290 100644 (file)
@@ -1,5 +1,5 @@
 /* Message list charset and locale charset handling.
-   Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-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
@@ -25,7 +25,6 @@
 /* Specification.  */
 #include "msgl-iconv.h"
 
-#include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
@@ -38,6 +37,7 @@
 #include "basename.h"
 #include "message.h"
 #include "po-charset.h"
+#include "iconvstring.h"
 #include "msgl-ascii.h"
 #include "xalloc.h"
 #include "xallocsa.h"
 
 #if HAVE_ICONV
 
-/* Converts an entire string from one encoding to another, using iconv.
-   Return value: 0 if successful, otherwise -1 and errno set.  */
-static 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;
-
-  /* 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)
-             break;
-           else
-             return -1;
-         }
-# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
-       /* Irix iconv() inserts a NUL byte if it cannot convert.  */
-       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;
-    size_t insize = end - start;
-    char *outptr = result;
-    size_t outsize = length;
-
-    while (insize > 0)
-      {
-       size_t res = iconv (cd,
-                           (ICONV_CONST char **) &inptr, &insize,
-                           &outptr, &outsize);
-
-       if (res == (size_t)(-1))
-         {
-           if (errno == EINVAL)
-             break;
-           else
-             return -1;
-         }
-# if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
-       /* Irix iconv() inserts a NUL byte if it cannot convert.  */
-       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
-}
-
 static void conversion_error (const struct conversion_context* context)
 #if defined __GNUC__ && ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2)
      __attribute__ ((noreturn))