root / po / insert-header.sin @ 896
History | View | Annotate | Download (672 Bytes)
| 1 | 1 | hiro | # Sed script that inserts the file called HEADER before the header entry. |
|---|---|---|---|
| 2 | 1 | hiro | # |
| 3 | 1 | hiro | # At each occurrence of a line starting with "msgid ", we execute the following |
| 4 | 1 | hiro | # commands. At the first occurrence, insert the file. At the following |
| 5 | 1 | hiro | # occurrences, do nothing. The distinction between the first and the following |
| 6 | 1 | hiro | # occurrences is achieved by looking at the hold space. |
| 7 | 1 | hiro | /^msgid /{
|
| 8 | 1 | hiro | x |
| 9 | 1 | hiro | # Test if the hold space is empty. |
| 10 | 1 | hiro | s/m/m/ |
| 11 | 1 | hiro | ta |
| 12 | 1 | hiro | # Yes it was empty. First occurrence. Read the file. |
| 13 | 1 | hiro | r HEADER |
| 14 | 1 | hiro | # Output the file's contents by reading the next line. But don't lose the |
| 15 | 1 | hiro | # current line while doing this. |
| 16 | 1 | hiro | g |
| 17 | 1 | hiro | N |
| 18 | 1 | hiro | bb |
| 19 | 1 | hiro | :a |
| 20 | 1 | hiro | # The hold space was nonempty. Following occurrences. Do nothing. |
| 21 | 1 | hiro | x |
| 22 | 1 | hiro | :b |
| 23 | 1 | hiro | } |