+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,
# 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.
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
#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"
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);
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]);
+ }
+ }
}
}
}
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));
&& 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;