From: Bruno Haible Date: Mon, 7 Jul 2025 07:16:01 +0000 (+0200) Subject: xgettext: Perl: Add unit test for bug. X-Git-Tag: v0.26~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=673ca474f5dfbceeb877ddaeb3dadc650df5ea4e;p=thirdparty%2Fgettext.git xgettext: Perl: Add unit test for bug. * gettext-tools/tests/xgettext-perl-11: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it. --- diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 71429d655..c7146594b 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -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 index 000000000..4690c8d43 --- /dev/null +++ b/gettext-tools/tests/xgettext-perl-11 @@ -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