mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 15:39:11 +00:00
msgcat: Signal error when the same msgid is used with and without msgid_plural.
Suggested by Mikko Rantalainen <mikko.rantalainen@peda.net> in <https://lists.gnu.org/archive/html/bug-gettext/2019-09/msg00020.html>. * gettext-tools/src/msgl-cat.c (catenate_msgdomain_list): Signal an error when the same msgid is used with and without msgid_plural. * gettext-tools/src/msgcat.c (main): Exit with failure code if there was an error. * gettext-tools/src/msgcomm.c (main): Likewise. * gettext-tools/src/msguniq.c (main): Likewise. * gettext-tools/tests/msgcat-21: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it.
This commit is contained in:
parent
6209647e09
commit
e219e828ed
@ -350,7 +350,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\
|
||||
/* Write the PO file. */
|
||||
msgdomain_list_print (result, output_file, output_syntax, force_po, false);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -342,7 +342,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\
|
||||
/* Write the PO file. */
|
||||
msgdomain_list_print (result, output_file, output_syntax, force_po, false);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -297,7 +297,18 @@ catenate_msgdomain_list (string_list_ty *file_list,
|
||||
size_t i;
|
||||
|
||||
tmp = message_list_search (total_mlp, mp->msgctxt, mp->msgid);
|
||||
if (tmp == NULL)
|
||||
if (tmp != NULL)
|
||||
{
|
||||
if ((tmp->msgid_plural != NULL) != (mp->msgid_plural != NULL))
|
||||
{
|
||||
char *errormsg =
|
||||
xasprintf (_("msgid '%s' is used without plural and with plural."),
|
||||
mp->msgid);
|
||||
multiline_error (xstrdup (""),
|
||||
xasprintf ("%s\n", errormsg));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = message_alloc (mp->msgctxt, mp->msgid, mp->msgid_plural,
|
||||
NULL, 0, &mp->pos);
|
||||
|
||||
@ -310,7 +310,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\
|
||||
/* Write the PO file. */
|
||||
msgdomain_list_print (result, output_file, output_syntax, force_po, false);
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
exit (error_message_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ TESTS = gettext-1 gettext-2 \
|
||||
msgattrib-properties-1 \
|
||||
msgcat-1 msgcat-2 msgcat-3 msgcat-4 msgcat-5 msgcat-6 msgcat-7 \
|
||||
msgcat-8 msgcat-9 msgcat-10 msgcat-11 msgcat-12 msgcat-13 msgcat-14 \
|
||||
msgcat-15 msgcat-16 msgcat-17 msgcat-18 msgcat-19 msgcat-20 \
|
||||
msgcat-15 msgcat-16 msgcat-17 msgcat-18 msgcat-19 msgcat-20 msgcat-21 \
|
||||
msgcat-properties-1 msgcat-properties-2 \
|
||||
msgcat-stringtable-1 \
|
||||
msgcmp-1 msgcmp-2 msgcmp-3 msgcmp-4 \
|
||||
|
||||
40
gettext-tools/tests/msgcat-21
Executable file
40
gettext-tools/tests/msgcat-21
Executable file
@ -0,0 +1,40 @@
|
||||
#! /bin/sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
|
||||
|
||||
# Verify that msgcat complains when the same msgid occurs with and without
|
||||
# msgid_plural.
|
||||
|
||||
cat <<\EOF > mcat-test21.in1
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "File"
|
||||
msgstr "Soumettre"
|
||||
EOF
|
||||
|
||||
cat <<\EOF > mcat-test21.in2
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
msgid "File"
|
||||
msgid_plural "Files"
|
||||
msgstr[0] "fichier"
|
||||
msgstr[1] "fichiers"
|
||||
EOF
|
||||
|
||||
rm -f mcat-test21.out1
|
||||
: ${MSGCAT=msgcat}
|
||||
${MSGCAT} -o mcat-test21.out1 mcat-test21.in1 mcat-test21.in2 2>/dev/null
|
||||
test $? = 1 || { Exit 1; }
|
||||
|
||||
rm -f mcat-test21.out2
|
||||
: ${MSGCAT=msgcat}
|
||||
${MSGCAT} -o mcat-test21.out2 mcat-test21.in2 mcat-test21.in1 2>/dev/null
|
||||
test $? = 1 || { Exit 1; }
|
||||
|
||||
Exit 0
|
||||
Loading…
x
Reference in New Issue
Block a user