]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Perl: Add unit test for bug.
authorBruno Haible <bruno@clisp.org>
Mon, 7 Jul 2025 07:16:01 +0000 (09:16 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 7 Jul 2025 07:16:01 +0000 (09:16 +0200)
* gettext-tools/tests/xgettext-perl-11: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.

gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-perl-11 [new file with mode: 0755]

index 71429d6551d4a90d01d1972d677e2e103eea3147..c7146594b730dd6e8394ce7cda06dbfb851d25af 100644 (file)
@@ -148,7 +148,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-10 \
+       xgettext-perl-9 xgettext-perl-10 xgettext-perl-11 \
        xgettext-perl-stackovfl-1 xgettext-perl-stackovfl-2 \
        xgettext-perl-stackovfl-3 xgettext-perl-stackovfl-4 \
        xgettext-perl-stackovfl-5 \
diff --git a/gettext-tools/tests/xgettext-perl-11 b/gettext-tools/tests/xgettext-perl-11
new file mode 100755 (executable)
index 0000000..4690c8d
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test Perl support: long comments.
+
+cat <<\EOF > xg-pl-11.pl
+#!/usr/bin/perl
+# This is a comment line that is longer than 1024 bytes, which is the size of the stack-allocated space in a 'struct string_buffer'. For shorter comment lines, a different code path is used than for longer comment lines. In the commit that started to use 'struct string_buffer', namely commit 63709a20897369ca8d2cebf8a7d1f9f51ae9e359, there was a mistake. The effect was a bug with two visible effects: 1) When executed with valgrind, this unit test produced "Invalid read of size 1" errors. 2) Building the po4a package as a Nix package on Alpine Linux produced a crash of xgettext (because Nix adds a very long list of -I options to the first line of many perl scripts). For the other xgettext backends, there is no problem. I checked this by running "make check" with valgrind enabled (through the CHECKER variable in the Makefile) after temporarily changing the stack-allocated size from 1024 bytes to 10 bytes. _______________________________________________________________________________________________________________
+
+=cut
+
+package Locale::Po4a::Dia;
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --add-comments --omit-header --no-location --keyword=_ \
+  -d xg-pl-11.tmp xg-pl-11.pl || Exit 1