From: Bruno Haible Date: Mon, 13 Mar 2006 12:36:58 +0000 (+0000) Subject: Make the fuzzy search results platform independent. X-Git-Tag: v0.15~295 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca1573e748ec0455e0f063b16dcbb3524eed978;p=thirdparty%2Fgettext.git Make the fuzzy search results platform independent. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index dfe393b68..005fb6eb1 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,7 @@ +2006-03-11 Bruno Haible + + * message.c (fuzzy_search_goal_function): Use 'volatile double'. + 2006-03-11 Bruno Haible Speed up msgmerge with large compendia. diff --git a/gettext-tools/src/message.c b/gettext-tools/src/message.c index 120b795b2..bc6350e28 100644 --- a/gettext-tools/src/message.c +++ b/gettext-tools/src/message.c @@ -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; }