868b2b66 (kx 2024-12-20 16:11:07 +0300 1) # Sed script that inserts the file called HEADER before the header entry.
868b2b66 (kx 2024-12-20 16:11:07 +0300 2) #
868b2b66 (kx 2024-12-20 16:11:07 +0300 3) # Copyright (C) 2001 Free Software Foundation, Inc.
868b2b66 (kx 2024-12-20 16:11:07 +0300 4) # Written by Bruno Haible <bruno@clisp.org>, 2001.
868b2b66 (kx 2024-12-20 16:11:07 +0300 5) # This file is free software; the Free Software Foundation gives
868b2b66 (kx 2024-12-20 16:11:07 +0300 6) # unlimited permission to use, copy, distribute, and modify it.
868b2b66 (kx 2024-12-20 16:11:07 +0300 7) #
868b2b66 (kx 2024-12-20 16:11:07 +0300 8) # At each occurrence of a line starting with "msgid ", we execute the following
868b2b66 (kx 2024-12-20 16:11:07 +0300 9) # commands. At the first occurrence, insert the file. At the following
868b2b66 (kx 2024-12-20 16:11:07 +0300 10) # occurrences, do nothing. The distinction between the first and the following
868b2b66 (kx 2024-12-20 16:11:07 +0300 11) # occurrences is achieved by looking at the hold space.
868b2b66 (kx 2024-12-20 16:11:07 +0300 12) /^msgid /{
868b2b66 (kx 2024-12-20 16:11:07 +0300 13) x
868b2b66 (kx 2024-12-20 16:11:07 +0300 14) # Test if the hold space is empty.
868b2b66 (kx 2024-12-20 16:11:07 +0300 15) s/m/m/
868b2b66 (kx 2024-12-20 16:11:07 +0300 16) ta
868b2b66 (kx 2024-12-20 16:11:07 +0300 17) # Yes it was empty. First occurrence. Read the file.
868b2b66 (kx 2024-12-20 16:11:07 +0300 18) r HEADER
868b2b66 (kx 2024-12-20 16:11:07 +0300 19) # Output the file's contents by reading the next line. But don't lose the
868b2b66 (kx 2024-12-20 16:11:07 +0300 20) # current line while doing this.
868b2b66 (kx 2024-12-20 16:11:07 +0300 21) g
868b2b66 (kx 2024-12-20 16:11:07 +0300 22) N
868b2b66 (kx 2024-12-20 16:11:07 +0300 23) bb
868b2b66 (kx 2024-12-20 16:11:07 +0300 24) :a
868b2b66 (kx 2024-12-20 16:11:07 +0300 25) # The hold space was nonempty. Following occurrences. Do nothing.
868b2b66 (kx 2024-12-20 16:11:07 +0300 26) x
868b2b66 (kx 2024-12-20 16:11:07 +0300 27) :b
868b2b66 (kx 2024-12-20 16:11:07 +0300 28) }