From 8908af6ad9b86a7d9defbff6a079047295aee9a7 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 23 Nov 2024 11:29:23 -0500 Subject: [PATCH] DX_COPYRIGHT: Fix stripping of leading/trailing newlines. The pattern mishandled the case where the argument had zero leading or trailing newlines. Fix that up, and update the test case to cover it. --- m4/copyright.m4 | 4 ++-- tests/macros.at | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/m4/copyright.m4 b/m4/copyright.m4 index 64705ea..5376c4c 100644 --- a/m4/copyright.m4 +++ b/m4/copyright.m4 @@ -37,8 +37,8 @@ # from the blurb, and each line may optionally begin with a # character. m4_define([DX_COPYRIGHT], [m4_if([$#], [0], [[$0]], [m4_wrap( [_DX_COPYRIGHT([$1], m4_bpatsubst([$2], [\`[ -]+\(\([^x]\|x\)*\)[ -]+\'], [[ +]*\(\([^x]\|x\)*\)[ +]*\'], [[ \1]]))])])]) m4_define([_DX_COPYRIGHT], diff --git a/tests/macros.at b/tests/macros.at index 977e908..938e61f 100644 --- a/tests/macros.at +++ b/tests/macros.at @@ -804,8 +804,12 @@ Copyright (C) 1999 Foo Bar ])]]) TEST_AUTORECONF -AT_CHECK([sed -n '/BLURB BEGIN/,/BLURB END/p' configure], [0], -[[# TEST BLURB BEGIN +AT_CHECK([sed -n ' + /BLURB BEGIN/{x;p;x} + h; /BLURB BEGIN/,/BLURB END/p + /BLURB END/{n;p}' configure], [0], +# +# TEST BLURB BEGIN # # Copyright (C) 1999 Foo Bar # Copyright 2000-2001 Bar Foo @@ -814,7 +818,8 @@ AT_CHECK([sed -n '/BLURB BEGIN/,/BLURB END/p' configure], [0], # This is free software! # # TEST BLURB END -]]) +# +) AT_CHECK([$SHELL configure --version >stdout && sed -n '/Foo/,$p' stdout], [0], [[Copyright (C) 1999 Foo Bar Copyright 2001 Bar Foo @@ -833,10 +838,11 @@ m4@&t@_define([AT@&t@_PACKAGE_STRING]) m4@&t@_define([Copyright]) m4@&t@_define([Foo]) m4@&t@_include([copyright.m4]) -DX_COPYRIGHT([GPLv2+], [ +DX_COPYRIGHT([GPLv2+], # TEST BLURB BEGIN # Copyright (C) 1999, 2003 Foo Bar +[ Copyright 2004, 2005-2006 Bar Foo @@ -848,17 +854,23 @@ AT@&t@_INIT ]]) AT_CHECK([$AUTOTEST -I "$top_srcdir/m4" testsuite.at >testsuite], [0]) -AT_CHECK([sed -n '/BLURB BEGIN/,/BLURB END/p' testsuite], [0], -[[# TEST BLURB BEGIN +AT_CHECK([sed -n ' + /BLURB BEGIN/{x;p;x} + h; /BLURB BEGIN/,/BLURB END/p + /BLURB END/{n;p}' testsuite], [0], +# +# TEST BLURB BEGIN # # Copyright (C) 1999, 2003 Foo Bar +# # Copyright 2004, 2005-2006 Bar Foo # # # This is free software! # # TEST BLURB END -]]) +# +) AT_CHECK([$SHELL testsuite --version >stdout && sed -n '/Foo/,$p' stdout], [0], [[Copyright (C) 2003 Foo Bar Copyright 2006 Bar Foo -- 2.11.4.GIT