From 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:21:29 +0200 Subject: Adding upstream version 1:0.1.9998svn3589+dfsg. Signed-off-by: Daniel Baumann --- src/sed/doc/groupify.sed | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 src/sed/doc/groupify.sed (limited to 'src/sed/doc/groupify.sed') diff --git a/src/sed/doc/groupify.sed b/src/sed/doc/groupify.sed new file mode 100755 index 0000000..2430710 --- /dev/null +++ b/src/sed/doc/groupify.sed @@ -0,0 +1,59 @@ +#! /bin/sed -nf +# Script to add @group...@end group tags to sed.texi.in +# so that comments are not separated from the instructions +# that they refer to. + +# Step 1: search for the conventional "@c start----" comment +1a\ +@c Do not edit this file!! It is automatically generated from sed-in.texi. +p +/^@c start-*$/! b + +# Step 2: loop until we find a @ command +:a +n +p +/^@/! ba + +# Step 3: process everything until a "@end" command + +# Step 3.1: Print the blank lines before the group. If we reach the "@end", +# we go back to step 1. +:b +n +/^@end/ { + p + b +} +/^[ ]*$/ { + p + bb +} + +# Step 3.2: Add to hold space every line until an empty one or "@end" +h +:c +n +/^@end example/! { + /^[ ]*$/! { + H + bc + } +} + +# Step 3.3: Working in hold space, add @group...@end group if there are +# at least two lines. Then print the lines we processed and +# switch back to pattern space. +x +/\n/ { + s/.*/@group\ +&\ +@end group/ +} +p + +# Step 3.4: Switch back to pattern space, print the first blank line +# and possibly go back to step 3.1 +x +p +/^@end/ !bb -- cgit v1.2.3