diff options
Diffstat (limited to 'bin/unf.awk')
-rw-r--r-- | bin/unf.awk | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/unf.awk b/bin/unf.awk new file mode 100644 index 00000000..22a10aa8 --- /dev/null +++ b/bin/unf.awk @@ -0,0 +1,34 @@ +# Unfold header lines in an internet message, don't touch the body + +# Function to write and empty the buffer +function wrbuf() { + if (length(buf)) + print buf + buf = "" +} + +# Flag to stop processing once we hit the first blank line +!length { + wrbuf() + body = 1 +} +body { + print + next +} + +# Write any buffer contents once we hit a line not starting with a space +/^[^ \t]/ { + wrbuf() +} + +# Append the current line to the buffer +{ + sub(/^[ \t]+/, " ") + buf = buf $0 +} + +# Write the buffer out again when we hit the end +END { + wrbuf() +} |