bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gettext] [PATCH] Sync up loadmsgcat.c with glibc


From: Siddhesh Poyarekar
Subject: [bug-gettext] [PATCH] Sync up loadmsgcat.c with glibc
Date: Thu, 3 Jul 2014 09:10:36 +0530
User-agent: Mutt/1.5.22.1-rc1 (2013-10-16)

[Lets see if signing on to the mailing list helps]

Hi,

I am trying to sync up loadmsgcat.c between gettext and glibc.  The
glibc bits have gone in[1][2] already and these are bits from the glibc
version that can go into gettext as improvements.  Do they look OK for
gettext?

Thanks,
Siddhesh

[1] 
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=3247f28556d1de7f9837f6e9ee8c63fa56b93c13
[2] https://sourceware.org/ml/libc-alpha/2014-07/msg00067.html


        * gettext-runtime/intl/loadmsgcat.c: Include assert.h.
        [_LIBC]: Define PRI_MACROS_BROKEN unconditionally.
        (_nl_load_domain): Add semicolon to end of line.
        (_nl_load_domain)[HAVE_MMAP]: Use MAP_FAILED and assert that
        it is (void *) -1.
        (_nl_load_domain)[_LIBC]: Call __libc_rwlock_init instead of
        gl_rwlock_init.
        (_nl_unload_domain): Cast convd->encoding to non-const.


diff --git a/gettext-runtime/intl/loadmsgcat.c 
b/gettext-runtime/intl/loadmsgcat.c
index 6335152..570f476 100644
--- a/gettext-runtime/intl/loadmsgcat.c
+++ b/gettext-runtime/intl/loadmsgcat.c
@@ -25,6 +25,7 @@
 # include <config.h>
 #endif
 
+#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -100,9 +101,7 @@ char *alloca ();
 #endif
 
 #ifdef _LIBC
-# ifndef PRI_MACROS_BROKEN
-#  define PRI_MACROS_BROKEN 0
-# endif
+# define PRI_MACROS_BROKEN 0
 #endif
 
 /* Provide fallback values for macros that ought to be defined in <inttypes.h>.
@@ -786,7 +785,7 @@ internal_function
 _nl_load_domain (struct loaded_l10nfile *domain_file,
                 struct binding *domainbinding)
 {
-  __libc_lock_define_initialized_recursive (static, lock)
+  __libc_lock_define_initialized_recursive (static, lock);
   int fd = -1;
   size_t size;
 #ifdef _LIBC
@@ -853,13 +852,15 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
   data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
                                         MAP_PRIVATE, fd, 0);
 
-  if (__builtin_expect (data != (struct mo_file_header *) -1, 1))
+  if (__builtin_expect (data != MAP_FAILED, 1))
     {
       /* mmap() call was successful.  */
       close (fd);
       fd = -1;
       use_mmap = 1;
     }
+
+  assert (MAP_FAILED == (void *) -1);
 #endif
 
   /* If the data is not yet available (i.e. mmap'ed) we try to load
@@ -1280,7 +1281,11 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
   /* No caches of converted translations so far.  */
   domain->conversions = NULL;
   domain->nconversions = 0;
+#ifdef _LIBC
+  __libc_rwlock_init (domain->conversions_lock);
+#else
   gl_rwlock_init (domain->conversions_lock);
+#endif
 
   /* Get the header entry and look for a plural specification.  */
 #ifdef IN_LIBGLOCALE
@@ -1323,7 +1328,7 @@ _nl_unload_domain (struct loaded_domain *domain)
     {
       struct converted_domain *convd = &domain->conversions[i];
 
-      free (convd->encoding);
+      free ((char *) convd->encoding);
       if (convd->conv_tab != NULL && convd->conv_tab != (char **) -1)
        free (convd->conv_tab);
       if (convd->conv != (__gconv_t) -1)

Attachment: pgpsnCOJ4bBst.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]