from one encoding to another.
+2003-10-21 Bruno Haible <bruno@clisp.org>
+
+ * message.h (message_list_msgids_changed): New declaration.
+ * message.c (message_list_msgids_changed): New function.
+ * msgl-iconv.c (iconv_message_list): Update the message list's hash
+ table if it happens to contain non-ASCII msgids.
+
2003-10-19 Bruno Haible <bruno@clisp.org>
* message.h (format_type): New enum value 'format_qt'.
}
+bool
+message_list_msgids_changed (message_list_ty *mlp)
+{
+ if (mlp->use_hashtable)
+ {
+ unsigned long int size = mlp->htable.size;
+ size_t j;
+
+ delete_hash (&mlp->htable);
+ init_hash (&mlp->htable, size);
+
+ for (j = 0; j < mlp->nitems; j++)
+ {
+ message_ty *mp = mlp->item[j];
+
+ if (insert_entry (&mlp->htable, mp->msgid, strlen (mp->msgid) + 1,
+ mp))
+ /* A message list has duplicates, although it was allocated with
+ the assertion that it wouldn't have duplicates, and before the
+ msgids changed it indeed didn't have duplicates. */
+ {
+ delete_hash (&mlp->htable);
+ mlp->use_hashtable = false;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
message_ty *
message_list_search (message_list_ty *mlp, const char *msgid)
{
extern void
message_list_remove_if_not (message_list_ty *mlp,
message_predicate_ty *predicate);
+/* Recompute the hash table of a message list after the msgids changed. */
+extern bool
+ message_list_msgids_changed (message_list_ty *mlp);
extern message_ty *
message_list_search (message_list_ty *mlp, const char *msgid);
extern message_ty *
{
#if HAVE_ICONV
iconv_t cd;
+ bool msgids_changed;
/* Avoid glibc-2.1 bug with EUC-KR. */
# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
and iconv() does not support this conversion."),
canon_from_code, canon_to_code, basename (program_name));
+ msgids_changed = false;
for (j = 0; j < mlp->nitems; j++)
{
message_ty *mp = mlp->item[j];
+ if (!is_ascii_string (mp->msgid))
+ msgids_changed = true;
convert_string_list (cd, mp->comment);
convert_string_list (cd, mp->comment_dot);
convert_msgid (cd, mp);
}
iconv_close (cd);
+
+ if (msgids_changed)
+ if (message_list_msgids_changed (mlp))
+ error (EXIT_FAILURE, 0, _("\
+Conversion from \"%s\" to \"%s\" introduces duplicates: \
+some different msgids become equal."),
+ canon_from_code, canon_to_code);
#else
error (EXIT_FAILURE, 0, _("\
Cannot convert from \"%s\" to \"%s\". %s relies on iconv(). \
+2003-10-21 Bruno Haible <bruno@clisp.org>
+
+ * msgmerge-25: New file.
+ * Makefile.am (TESTS): Add it.
+
2003-10-19 Bruno Haible <bruno@clisp.org>
* format-qt-1: New file.
* xgettext-3: Update for changed domain name.
-See ChangeLog.0 for earlier changes.
+See ChangeLog.0 for earlier changes.
\ No newline at end of file
msgmerge-7 msgmerge-8 msgmerge-9 msgmerge-10 msgmerge-11 msgmerge-12 \
msgmerge-13 msgmerge-14 msgmerge-15 msgmerge-16 msgmerge-17 \
msgmerge-18 msgmerge-19 msgmerge-20 msgmerge-21 msgmerge-22 \
- msgmerge-23 msgmerge-24 \
+ msgmerge-23 msgmerge-24 msgmerge-25 \
msgunfmt-1 msgunfmt-2 msgunfmt-3 msgunfmt-4 \
msguniq-1 msguniq-2 msguniq-3 msguniq-4 \
xgettext-1 xgettext-2 xgettext-3 xgettext-4 xgettext-5 xgettext-6 \
--- /dev/null
+#! /bin/sh
+
+# Test non-ASCII msgids when the PO file and the POT file are in different
+# encodings.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles mm-test25.po"
+cat <<\EOF > mm-test25.po
+msgid ""
+msgstr ""
+"Project-Id-Version: hello-cplusplus-qt 0\n"
+"Report-Msgid-Bugs-To: bug-gnu-gettext@gnu.org\n"
+"POT-Creation-Date: 2003-10-20 10:14+0200\n"
+"PO-Revision-Date: 2003-10-20 10:13+0200\n"
+"Last-Translator: Bruno Haible <bruno@clisp.org>\n"
+"Language-Team: Polish <pl@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-2\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
+"|| n%100>=20) ? 1 : 2);\n"
+
+#: hello.cc:45
+msgid "Written by François Pinard."
+msgstr "Program napisa³ François Pinard."
+
+#: hello.cc:52
+msgid "error %1."
+msgstr "b³±d %1."
+EOF
+
+tmpfiles="$tmpfiles mm-test25.pot"
+cat <<EOF > mm-test25.pot
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Yoyodyne, Inc.
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: bug-gnu-gettext@gnu.org\n"
+"POT-Creation-Date: 2003-10-20 10:14+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: hello.cc:45
+msgid "Written by François Pinard."
+msgstr ""
+
+#: hello.cc:52
+msgid "error %1."
+msgstr ""
+EOF
+
+tmpfiles="$tmpfiles mm-test25.new.po"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q mm-test25.po mm-test25.pot -o mm-test25.new.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles mm-test25.ok"
+cat <<\EOF > mm-test25.ok
+msgid ""
+msgstr ""
+"Project-Id-Version: hello-cplusplus-qt 0\n"
+"Report-Msgid-Bugs-To: bug-gnu-gettext@gnu.org\n"
+"POT-Creation-Date: 2003-10-20 10:14+0200\n"
+"PO-Revision-Date: 2003-10-20 10:13+0200\n"
+"Last-Translator: Bruno Haible <bruno@clisp.org>\n"
+"Language-Team: Polish <pl@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
+"|| n%100>=20) ? 1 : 2);\n"
+
+#: hello.cc:45
+msgid "Written by François Pinard."
+msgstr "Program napisał François Pinard."
+
+#: hello.cc:52
+msgid "error %1."
+msgstr "błąd %1."
+EOF
+
+: ${DIFF=diff}
+${DIFF} mm-test25.ok mm-test25.new.po
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result