]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Sync up loadmsgcat.c with glibc
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 3 Jul 2014 08:14:40 +0000 (17:14 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 3 Jul 2014 08:15:25 +0000 (17:15 +0900)
* loadmsgcat.c: Include assert.h.
(_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.

gettext-runtime/intl/ChangeLog
gettext-runtime/intl/loadmsgcat.c

index 7af5404ebd7630c74f14473931516b067973384b..b78669707ec9d9f7b65a8be9071ad860c26206e9 100644 (file)
@@ -1,3 +1,14 @@
+2014-07-03  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       intl: Sync up loadmsgcat.c with glibc
+       * loadmsgcat.c: Include assert.h.
+       (_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.
+
 2014-06-17  Daiki Ueno  <ueno@gnu.org>
 
        intl: Add back ChangeLog to gettext-runtime distribution
index 63351523ce20503587779841a1fb59fe85b1a1b5..826a5edae3fc4743bc5c110ba936d6c9694025fc 100644 (file)
@@ -25,6 +25,7 @@
 # include <config.h>
 #endif
 
+#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -786,7 +787,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 +854,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 +1283,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 +1330,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)