]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Improve msgmerge compendium handling.
authorBruno Haible <bruno@clisp.org>
Mon, 3 Sep 2001 14:07:41 +0000 (14:07 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 3 Sep 2001 14:07:41 +0000 (14:07 +0000)
src/ChangeLog
src/message.c

index dccec66fd3adebaee9e7a88ac1943c67e3482a8b..e3b4e8cab8cb92407bb40f11d26c8f3d28898290 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-01  Bruno Haible  <haible@clisp.cons.org>
+
+       * message.c (message_list_list_search): If the first match has an
+       empty translation but there is later in the list a non-empty
+       translation, return the latter one.  This fixes the msgmerge-8 test.
+
 2001-08-30  Bruno Haible  <haible@clisp.cons.org>
 
        Reorganize msgfmt checking options.
index d8aea28da0f3097c38ce1f5d2bdc95f809f1388a..3857e36bfd7d76085e9eceefeaaeab9abbaa7352 100644 (file)
@@ -638,8 +638,12 @@ message_list_list_search (mllp, msgid)
      message_list_list_ty *mllp;
      const char *msgid;
 {
+  message_ty *best_mp;
+  int best_weight; /* 0: not found, 1: found without msgstr, 2: translated */
   size_t j;
 
+  best_mp = NULL;
+  best_weight = 0;
   for (j = 0; j < mllp->nitems; ++j)
     {
       message_list_ty *mlp;
@@ -648,9 +652,16 @@ message_list_list_search (mllp, msgid)
       mlp = mllp->item[j];
       mp = message_list_search (mlp, msgid);
       if (mp)
-        return mp;
+       {
+         int weight = (mp->msgstr_len == 1 && mp->msgstr[0] == '\0' ? 1 : 2);
+         if (weight > best_weight)
+           {
+             best_mp = mp;
+             best_weight = weight;
+           }
+       }
     }
-  return NULL;
+  return best_mp;
 }