| Line | |
|---|
| 1 | #! /bin/sed -nf
|
|---|
| 2 | # Script to add @group...@end group tags to sed.texi.in
|
|---|
| 3 | # so that comments are not separated from the instructions
|
|---|
| 4 | # that they refer to.
|
|---|
| 5 |
|
|---|
| 6 | # Step 1: search for the conventional "@c start----" comment
|
|---|
| 7 | 1a\
|
|---|
| 8 | @c Do not edit this file!! It is automatically generated from sed-in.texi.
|
|---|
| 9 | p
|
|---|
| 10 | /^@c start-*$/! b
|
|---|
| 11 |
|
|---|
| 12 | # Step 2: loop until we find a @ command
|
|---|
| 13 | :a
|
|---|
| 14 | n
|
|---|
| 15 | p
|
|---|
| 16 | /^@/! ba
|
|---|
| 17 |
|
|---|
| 18 | # Step 3: process everything until a "@end" command
|
|---|
| 19 |
|
|---|
| 20 | # Step 3.1: Print the blank lines before the group. If we reach the "@end",
|
|---|
| 21 | # we go back to step 1.
|
|---|
| 22 | :b
|
|---|
| 23 | n
|
|---|
| 24 | /^@end/ {
|
|---|
| 25 | p
|
|---|
| 26 | b
|
|---|
| 27 | }
|
|---|
| 28 | /^[ ]*$/ {
|
|---|
| 29 | p
|
|---|
| 30 | bb
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | # Step 3.2: Add to hold space every line until an empty one or "@end"
|
|---|
| 34 | h
|
|---|
| 35 | :c
|
|---|
| 36 | n
|
|---|
| 37 | /^@end example/! {
|
|---|
| 38 | /^[ ]*$/! {
|
|---|
| 39 | H
|
|---|
| 40 | bc
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | # Step 3.3: Working in hold space, add @group...@end group if there are
|
|---|
| 45 | # at least two lines. Then print the lines we processed and
|
|---|
| 46 | # switch back to pattern space.
|
|---|
| 47 | x
|
|---|
| 48 | /\n/ {
|
|---|
| 49 | s/.*/@group\
|
|---|
| 50 | &\
|
|---|
| 51 | @end group/
|
|---|
| 52 | }
|
|---|
| 53 | p
|
|---|
| 54 |
|
|---|
| 55 | # Step 3.4: Switch back to pattern space, print the first blank line
|
|---|
| 56 | # and possibly go back to step 3.1
|
|---|
| 57 | x
|
|---|
| 58 | p
|
|---|
| 59 | /^@end/ !bb
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.