]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make the fuzzy search results platform independent.
authorBruno Haible <bruno@clisp.org>
Mon, 13 Mar 2006 12:36:58 +0000 (12:36 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:02 +0000 (12:13 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/message.c

index dfe393b68eec3f1cae8c47b24009c3b106850bf0..005fb6eb14b859ec39a4da7500148761f967460a 100644 (file)
@@ -1,3 +1,7 @@
+2006-03-11  Bruno Haible  <bruno@clisp.org>
+
+       * message.c (fuzzy_search_goal_function): Use 'volatile double'.
+
 2006-03-11  Bruno Haible  <bruno@clisp.org>
 
        Speed up msgmerge with large compendia.
index 120b795b270a838c890d41c1a18859be065a9361..bc6350e2895776a11b080508ceb00807ac828216 100644 (file)
@@ -499,16 +499,20 @@ double
 fuzzy_search_goal_function (const message_ty *mp,
                            const char *msgctxt, const char *msgid)
 {
-  return
-    fstrcmp (msgid, mp->msgid)
-    /* A translation for a context is a good proposal also for
-       another.  But give mp a small advantage if mp is valid
-       regardless of any context or has the same context as the
-       one being looked up.  */
-    + ((mp->msgctxt == NULL
-       || (msgctxt != NULL && strcmp (msgctxt, mp->msgctxt) == 0))
-       ? 0.00001
-       : 0);
+  /* The use of 'volatile' guarantees that excess precision bits are dropped
+     before the addition and before the following comparison at the caller's
+     site.  It is necessary on x86 systems where double-floats are not IEEE
+     compliant by default, to avoid that msgmerge results become platform and
+     compiler option dependent.  'volatile' is a portable alternative to gcc's
+     -ffloat-store option.  */
+  volatile double weight = fstrcmp (msgid, mp->msgid);
+  /* A translation for a context is a good proposal also for another.  But
+     give mp a small advantage if mp is valid regardless of any context or
+     has the same context as the one being looked up.  */
+  if (mp->msgctxt == NULL
+      || (msgctxt != NULL && strcmp (msgctxt, mp->msgctxt) == 0))
+    weight += 0.00001;
+  return weight;
 }