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