]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: In language Perl, avoid a crash.
authorBruno Haible <bruno@clisp.org>
Wed, 15 Mar 2023 21:47:47 +0000 (22:47 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 15 Mar 2023 22:26:11 +0000 (23:26 +0100)
* gettext-tools/src/xg-arglist-parser.c (arglist_parser_clone): Clone the
msgid_pos correctly.
* gettext-tools/tests/xgettext-perl-10: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

gettext-tools/src/xg-arglist-parser.c
gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-perl-10 [new file with mode: 0755]

index d9795eb2d12834876ea28e1f121fb610a55b15e9..c41e92116daa30c7fd1438e91a6a58d346815b3c 100644 (file)
@@ -1,6 +1,6 @@
 /* Resolving ambiguity of argument lists: Progressive parsing of an
    argument list, keeping track of all possibilities.
-   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -130,7 +130,7 @@ arglist_parser_clone (struct arglist_parser *ap)
       ccp->msgctxt_pos = cp->msgctxt_pos;
       ccp->msgid = (cp->msgid != NULL ? mixed_string_clone (cp->msgid) : NULL);
       ccp->msgid_context = cp->msgid_context;
-      ccp->msgid_pos = cp->msgctxt_pos;
+      ccp->msgid_pos = cp->msgid_pos;
       ccp->msgid_comment = add_reference (cp->msgid_comment);
       ccp->msgid_comment_is_utf8 = cp->msgid_comment_is_utf8;
       ccp->msgid_plural =
index 6b30f9a00e11673768dc18797a5e0be1f35a625c..4670cad9df0dd20d56e47488407defc3f63ce6e7 100644 (file)
@@ -130,7 +130,7 @@ TESTS = gettext-1 gettext-2 \
        xgettext-objc-1 xgettext-objc-2 \
        xgettext-perl-1 xgettext-perl-2 xgettext-perl-3 xgettext-perl-4 \
        xgettext-perl-5 xgettext-perl-6 xgettext-perl-7 xgettext-perl-8 \
-       xgettext-perl-9 \
+       xgettext-perl-9 xgettext-perl-10 \
        xgettext-perl-stackovfl-1 xgettext-perl-stackovfl-2 \
        xgettext-perl-stackovfl-3 xgettext-perl-stackovfl-4 \
        xgettext-php-1 xgettext-php-2 xgettext-php-3 xgettext-php-4 \
diff --git a/gettext-tools/tests/xgettext-perl-10 b/gettext-tools/tests/xgettext-perl-10
new file mode 100755 (executable)
index 0000000..d4f21ed
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test of Perl support: ngettext invocation that used to trigger a crash.
+
+cat <<\EOF > xg-pl-10.pl
+ngettext p=>("
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header -n -d xg-pl-10.tmp xg-pl-10.pl || Exit 1
+LC_ALL=C tr -d '\r' < xg-pl-10.tmp.po > xg-pl-10.po || Exit 1
+
+cat <<\EOF > xg-pl-10.ok
+#: xg-pl-10.pl:1
+msgid "p"
+msgid_plural "\n"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-pl-10.ok xg-pl-10.po
+result=$?
+
+exit $result