]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Make the msgcat-2 test work.
authorBruno Haible <bruno@clisp.org>
Thu, 1 Nov 2001 11:08:16 +0000 (11:08 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 20:47:42 +0000 (22:47 +0200)
src/ChangeLog
src/Makefile.am
src/message.h
src/msgl-cat.c
src/msgl-equal.c
src/msgl-equal.h

index 95ecd76cd67ccaddc8297609b2565f5de83f9cd4..3ba32e8a31aa4f1c616af81ec252fe4c384f80a0 100644 (file)
@@ -1,3 +1,15 @@
+2001-11-01  Bruno Haible  <haible@clisp.cons.org>
+
+       * msgl-equal.h (string_list_equal): New declaration.
+       * msgl-equal.c (string_list_equal): Export function.
+       * message.h (struct altstr): New fields 'comment', 'comment_dot'.
+       * msgl-cat.c: Include msgl-equal.h.
+       (catenate_msgdomain_list): If all alternative comments are equal,
+       use one copy of them, instead of concatenating them. Likewise for dot
+       comments.
+       * Makefile.am (libgettextsrc_la_SOURCES): Add msgl-equal.c.
+       (msgmerge_SOURCES): Remove msgl-equal.c.
+
 2001-10-31  Bruno Haible  <haible@clisp.cons.org>
 
        * Makefile.am (noinst_HEADERS): Add read-java.h, write-java.h,
index 188dfd80dddf80dc737999d1cce6c6ab31129acc..1c01150b79b35a93289db19c8c04ffcad0062837 100644 (file)
@@ -71,8 +71,8 @@ format-ycp.c
 
 # libgettextsrc contains all code that is needed by at least two programs.
 libgettextsrc_la_SOURCES = \
-$(COMMON_SOURCE) read-po.c write-po.c msgl-ascii.c msgl-iconv.c msgl-cat.c \
-msgl-english.c file-list.c msgl-charset.c po-time.c \
+$(COMMON_SOURCE) read-po.c write-po.c msgl-ascii.c msgl-iconv.c msgl-equal.c \
+msgl-cat.c msgl-english.c file-list.c msgl-charset.c po-time.c \
 $(FORMAT_SOURCE)
 
 # Source dependencies.
@@ -80,7 +80,7 @@ gettext_SOURCES = gettext.c
 ngettext_SOURCES = ngettext.c
 msgcmp_SOURCES = msgcmp.c
 msgfmt_SOURCES = msgfmt.c write-mo.c write-java.c plural.c plural-eval.c
-msgmerge_SOURCES = msgmerge.c msgl-equal.c
+msgmerge_SOURCES = msgmerge.c
 msgunfmt_SOURCES = msgunfmt.c read-mo.c read-java.c
 xgettext_SOURCES = xgettext.c x-c.c x-po.c x-java.l x-ycp.c x-rst.c
 msgattrib_SOURCES = msgattrib.c
index 432cd17ee190476ff3af3bcf2f2caa6b6636081f..8634507de49cd75fa67167819541f80fef762007 100644 (file)
@@ -125,6 +125,8 @@ struct message_ty
       const char *msgstr;
       size_t msgstr_len;
       const char *msgstr_end;
+      string_list_ty *comment;
+      string_list_ty *comment_dot;
       char *id;
     }
     *alternative;
index 44622e834d9a1490c4a43ee5c61ef0ad18797131..7d8f950fa6b84dd3e84a508538953898c5fd64fc 100644 (file)
@@ -33,6 +33,7 @@
 #include "read-po.h"
 #include "po-charset.h"
 #include "msgl-ascii.h"
+#include "msgl-equal.h"
 #include "msgl-iconv.h"
 #include "xmalloc.h"
 #include "strstr.h"
@@ -530,22 +531,11 @@ To select a different output encoding, use the --to-code option.\n\
                  tmp->alternative[i].msgstr_len = mp->msgstr_len;
                  tmp->alternative[i].msgstr_end =
                    tmp->alternative[i].msgstr + tmp->alternative[i].msgstr_len;
+                 tmp->alternative[i].comment = mp->comment;
+                 tmp->alternative[i].comment_dot = mp->comment_dot;
                  tmp->alternative[i].id = id;
                  tmp->alternative_count = i + 1;
 
-                 if (mp->comment)
-                   {
-                     message_comment_append (tmp, id);
-                     for (i = 0; i < mp->comment->nitems; i++)
-                       message_comment_append (tmp, mp->comment->item[i]);
-                   }
-                 if (mp->comment_dot)
-                   {
-                     message_comment_dot_append (tmp, id);
-                     for (i = 0; i < mp->comment_dot->nitems; i++)
-                       message_comment_dot_append (tmp,
-                                                   mp->comment_dot->item[i]);
-                   }
                  for (i = 0; i < mp->filepos_count; i++)
                    message_comment_filepos (tmp, mp->filepos[i].file_name,
                                             mp->filepos[i].line_number);
@@ -655,6 +645,61 @@ To select a different output encoding, use the --to-code option.\n\
 
                  tmp->is_fuzzy = true;
                }
+
+             /* Test whether all alternative comments are equal.  */
+             for (i = 0; i < tmp->alternative_count; i++)
+               if (tmp->alternative[i].comment == NULL
+                   || !string_list_equal (tmp->alternative[i].comment,
+                                          first->comment))
+                 break;
+
+             if (i == tmp->alternative_count)
+               /* All alternatives are equal.  */
+               tmp->comment = first->comment;
+             else
+               /* Concatenate the alternative comments into a single one,
+                  separated by markers.  */
+               for (i = 0; i < tmp->alternative_count; i++)
+                 {
+                   string_list_ty *slp = tmp->alternative[i].comment;
+
+                   if (slp != NULL)
+                     {
+                       size_t l;
+
+                       message_comment_append (tmp, tmp->alternative[i].id);
+                       for (l = 0; l < slp->nitems; l++)
+                         message_comment_append (tmp, slp->item[i]);
+                     }
+                 }
+
+             /* Test whether all alternative dot comments are equal.  */
+             for (i = 0; i < tmp->alternative_count; i++)
+               if (tmp->alternative[i].comment_dot == NULL
+                   || !string_list_equal (tmp->alternative[i].comment_dot,
+                                          first->comment_dot))
+                 break;
+
+             if (i == tmp->alternative_count)
+               /* All alternatives are equal.  */
+               tmp->comment_dot = first->comment_dot;
+             else
+               /* Concatenate the alternative dot comments into a single one,
+                  separated by markers.  */
+               for (i = 0; i < tmp->alternative_count; i++)
+                 {
+                   string_list_ty *slp = tmp->alternative[i].comment_dot;
+
+                   if (slp != NULL)
+                     {
+                       size_t l;
+
+                       message_comment_dot_append (tmp,
+                                                   tmp->alternative[i].id);
+                       for (l = 0; l < slp->nitems; l++)
+                         message_comment_dot_append (tmp, slp->item[i]);
+                     }
+                 }
            }
        }
     }
index 4c827ec51c1cf07570a20749ea51285fc52088cf..f66b561a1158ecd07425c179f9e6e71cf1883fcb 100644 (file)
@@ -29,8 +29,6 @@
    function argument counts despite of K&R C function definition syntax.  */
 static inline bool pos_equal PARAMS ((const lex_pos_ty *pos1,
                                      const lex_pos_ty *pos2));
-static inline bool string_list_equal PARAMS ((const string_list_ty *slp1,
-                                             const string_list_ty *slp2));
 static inline bool msgdomain_equal PARAMS ((const msgdomain_ty *mdp1,
                                            const msgdomain_ty *mdp2));
 
@@ -45,7 +43,7 @@ pos_equal (pos1, pos2)
          && pos1->line_number == pos2->line_number);
 }
 
-static inline bool
+bool
 string_list_equal (slp1, slp2)
      const string_list_ty *slp1;
      const string_list_ty *slp2;
index 9953f9746635d6088bcf35bd6a0567b4591ff95a..c707289c0858c93f0c7bd82638170c5fcdc466a7 100644 (file)
 
 #include <stdbool.h>
 
+extern bool
+       string_list_equal PARAMS ((const string_list_ty *slp1,
+                                 const string_list_ty *slp2));
+
 /* Test whether the written representation of two messages / message lists
    would be the same.  */