]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Update to newest glibc version.
authorBruno Haible <bruno@clisp.org>
Fri, 16 Jun 2000 17:56:56 +0000 (17:56 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 16 Jun 2000 17:56:56 +0000 (17:56 +0000)
intl/ChangeLog
intl/bindtextdom.c
intl/dcigettext.c
intl/tst-gettext.c

index eee63872e2489c8f16f23be7ac162070bc2eb9e2..d8ddb5241ee0fab59816588731965d31e6f55d76 100644 (file)
@@ -1,3 +1,28 @@
+2000-05-21  Ulrich Drepper  <drepper@redhat.com>
+
+       * dcigettext.c: Fix typo in comment.
+
+2000-05-08  Andreas Jaeger  <aj@suse.de>
+
+       * bindtextdom.c (set_binding_values): Add prototype.
+
+2000-05-06  Bruno Haible  <haible@clisp.cons.org>
+
+       * tst-gettext.c (main): Disable possibly existing LC_CTYPE and
+       OUTPUT_CHARSET environment variables.
+
+2000-05-05  Bruno Haible  <haible@clisp.cons.org>
+
+       * dcigettext.c (alignof): New macro.
+       (_nl_find_msg): Use it instead of __alignof__. Pass correct output
+       buffer length to __gconv/iconv. If malloc (freemem_size) fails, set
+       freemem_size to 0.
+
+2000-05-05  Bruno Haible  <haible@clisp.cons.org>
+
+       * dcigettext.c (dcigettext): Fix interpretation of tsearch
+       return value.
+
 2000-05-06  Ulrich Drepper  <drepper@redhat.com>
 
        * dcigettext.c (DCIGETTEXT): Always define local variable `index'.
index 3d49344aaf8410c40b21fdb61ac379d4fa32ed41..4ea368da00acdaa4996d228a1816bdf80c410d99 100644 (file)
@@ -84,6 +84,10 @@ __libc_rwlock_define (extern, _nl_state_lock)
 # define BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset__
 #endif
 
+/* Prototypes for local functions.  */
+static void set_binding_values (const char *domainname, const char **dirnamep,
+                               const char **codesetp);
+     
 /* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
    to be used for the DOMAINNAME message catalog.
    If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
index 75f17072a259e10f1fa1190a13e206ffad496491..27398c1ca75ac1c8834258437dac5b5180363ca6 100644 (file)
@@ -110,6 +110,14 @@ void free ();
 # define __libc_rwlock_unlock(NAME)
 #endif
 
+/* Alignment of types.  */
+#if defined __GNUC__ && __GNUC__ >= 2
+# define alignof(TYPE) __alignof__ (TYPE)
+#else
+# define alignof(TYPE) \
+    ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
+#endif
+
 /* @@ end of prolog @@ */
 
 #ifdef _LIBC
@@ -607,7 +615,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
                      /* Insert the entry in the search tree.  */
                      foundp = (struct known_translation_t **)
                        tsearch (newp, &root, transcmp);
-                     if (__builtin_expect (&newp != foundp, 0))
+                     if (foundp == NULL
+                         || __builtin_expect (*foundp != newp, 0))
                        /* The insert failed.  */
                        free (newp);
                    }
@@ -724,8 +733,8 @@ _nl_find_msg (domain_file, msgid, index)
  found:
   /* The translation was found at index ACT.  If we have to convert the
      string to use a different character set, this is the time.  */
-  result = (char *) domain->data
-          + W (domain->must_swap, domain->trans_tab[act].offset);
+  result = ((char *) domain->data
+           + W (domain->must_swap, domain->trans_tab[act].offset));
 
 #if defined _LIBC || HAVE_ICONV
   if (
@@ -742,7 +751,7 @@ _nl_find_msg (domain_file, msgid, index)
         appropriate table with the same structure as the table
         of translations in the file, where we can put the pointers
         to the converted strings in.
-        The is a slight complication with the INDEX: We don't know
+        There is a slight complication with the INDEX: We don't know
         a priori which entries are plural entries. Therefore at any
         moment we can only translate the variants 0 .. INDEX.  */
 
@@ -784,20 +793,24 @@ _nl_find_msg (domain_file, msgid, index)
            resultlen = p - result;
          }
 
-         inbuf = result;
-         outbuf = freemem + 4;
-
          __libc_lock_lock (lock);
 
+         inbuf = result;
+         outbuf = freemem + sizeof (nls_uint32);
+
          while (1)
            {
 # ifdef _LIBC
              size_t non_reversible;
              int res;
 
+             if (freemem_size < 4)
+               goto resize_freemem;
+
              res = __gconv (domain->conv,
                             &inbuf, inbuf + resultlen,
-                            &outbuf, outbuf + freemem_size,
+                            &outbuf,
+                            outbuf + freemem_size - sizeof (nls_uint32),
                             &non_reversible);
 
              if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT)
@@ -815,8 +828,12 @@ _nl_find_msg (domain_file, msgid, index)
              const char *inptr = (const char *) inbuf;
              size_t inleft = resultlen;
              char *outptr = (char *) outbuf;
-             size_t outleft = freemem_size;
+             size_t outleft;
+
+             if (freemem_size < 4)
+               goto resize_freemem;
 
+             outleft = freemem_size - 4;
              if (iconv (domain->conv, &inptr, &inleft, &outptr, &outleft)
                  != (size_t) (-1))
                {
@@ -831,6 +848,7 @@ _nl_find_msg (domain_file, msgid, index)
 #  endif
 # endif
 
+           resize_freemem:
              /* We must resize the buffer.  */
              freemem_size = 2 * freemem_size;
              if (freemem_size < 4064)
@@ -838,11 +856,12 @@ _nl_find_msg (domain_file, msgid, index)
              freemem = (char *) malloc (freemem_size);
              if (__builtin_expect (freemem == NULL, 0))
                {
+                 freemem_size = 0;
                  __libc_lock_unlock (lock);
                  goto converted;
                }
 
-             outbuf = freemem + 4;
+             outbuf = freemem + sizeof (nls_uint32);
            }
 
          /* We have now in our buffer a converted string.  Put this
@@ -852,15 +871,15 @@ _nl_find_msg (domain_file, msgid, index)
          /* Shrink freemem, but keep it aligned.  */
          freemem_size -= outbuf - freemem;
          freemem = outbuf;
-         freemem += freemem_size & (__alignof__ (nls_uint32) - 1);
-         freemem_size = freemem_size & ~ (__alignof__ (nls_uint32) - 1);
+         freemem += freemem_size & (alignof (nls_uint32) - 1);
+         freemem_size = freemem_size & ~ (alignof (nls_uint32) - 1);
 
          __libc_lock_unlock (lock);
        }
 
       /* Now domain->conv_tab[act] contains the translation of at least
         the variants 0 .. INDEX.  */
-      result = domain->conv_tab[act] + 4;
+      result = domain->conv_tab[act] + sizeof (nls_uint32);
     }
 
  converted:
index 9ce11903aac1865ced56681509cbdfdc9f0e5013..b897d715826e7c69421b8d6714db96eaf1e7f904 100644 (file)
@@ -68,7 +68,9 @@ main (int argc, char *argv[])
   setenv ("LANGUAGE", "existing-locale", 1);
   setenv ("LC_ALL", "non-existing-locale", 1);
   setenv ("LC_MESSAGES", "non-existing-locale", 1);
+  setenv ("LC_CTYPE", "non-existing-locale", 1);
   setenv ("LANG", "non-existing-locale", 1);
+  unsetenv ("OUTPUT_CHARSET");
   /* This is the name of the existing domain with a catalog for the
      LC_MESSAGES category.  */
   textdomain ("existing-domain");