9832fd
commit ac64195ccd4f320659fd0058bc7524c6fd0b37b4
9832fd
Author: DJ Delorie <dj@redhat.com>
9832fd
Date:   Wed Mar 20 23:56:59 2019 -0400
9832fd
9832fd
    iconv, localedef: avoid floating point rounding differences [BZ #24372]
9832fd
    
9832fd
    Two cases of "int * 1.4" may result in imprecise results, which
9832fd
    in at least one case resulted in i686 and x86-64 producing
9832fd
    different locale files.  This replaced that floating point multiply
9832fd
    with integer operations.  While the hash table margin is increased
9832fd
    from 40% to 50%, testing shows only 2% increase in overall size
9832fd
    of the locale archive.
9832fd
    
9832fd
    https://bugzilla.redhat.com/show_bug.cgi?id=1311954
9832fd
9832fd
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
9832fd
index 0201450..1e6066c 100644
9832fd
--- a/iconv/iconvconfig.c
9832fd
+++ b/iconv/iconvconfig.c
9832fd
@@ -1079,9 +1079,9 @@ write_output (void)
9832fd
 
9832fd
   /* Create the hashing table.  We know how many strings we have.
9832fd
      Creating a perfect hash table is not reasonable here.  Therefore
9832fd
-     we use open hashing and a table size which is the next prime 40%
9832fd
+     we use open hashing and a table size which is the next prime 50%
9832fd
      larger than the number of strings.  */
9832fd
-  hash_size = next_prime (nnames * 1.4);
9832fd
+  hash_size = next_prime (nnames + nnames >> 1);
9832fd
   hash_table = (struct hash_entry *) xcalloc (hash_size,
9832fd
 					      sizeof (struct hash_entry));
9832fd
   /* Fill the hash table.  */
9832fd
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
9832fd
index bb4e2c5..19b23c2 100644
9832fd
--- a/locale/programs/ld-collate.c
9832fd
+++ b/locale/programs/ld-collate.c
9832fd
@@ -2401,8 +2401,8 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
9832fd
 
9832fd
       runp = runp->next;
9832fd
     }
9832fd
-  /* Add 40% and find the next prime number.  */
9832fd
-  elem_size = next_prime (elem_size * 1.4);
9832fd
+  /* Add 50% and find the next prime number.  */
9832fd
+  elem_size = next_prime (elem_size + elem_size >> 1);
9832fd
 
9832fd
   /* Allocate the table.  Each entry consists of two words: the hash
9832fd
      value and an index in a secondary table which provides the index