aboutsummaryrefslogtreecommitdiff
path: root/bin/rfct.awk
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-05 21:04:01 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-05 21:04:01 +1300
commitab940f9cecad99ba19baf7447d7f684a2e2010dc (patch)
tree838e7a790a9921a2551c732606402d2e74b0d560 /bin/rfct.awk
parentI didn't know about :cntrl: (diff)
downloaddotfiles-ab940f9cecad99ba19baf7447d7f684a2e2010dc.tar.gz
dotfiles-ab940f9cecad99ba19baf7447d7f684a2e2010dc.zip
More idiomatic approach to rfct(1df)
Got rid of the literal ^L, too
Diffstat (limited to 'bin/rfct.awk')
-rw-r--r--bin/rfct.awk16
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/rfct.awk b/bin/rfct.awk
index ac8a2a87..256841a7 100644
--- a/bin/rfct.awk
+++ b/bin/rfct.awk
@@ -1,8 +1,16 @@
# Format an RFC in text format for terminal reading
# A record is a paragraph
-BEGIN { RS = "" }
+BEGIN {
+ RS = ""
+ ORS = "\n\n"
+}
-# Print the block followed by two newlines, as long as it has at least one
-# alphanumeric character and no pagebreak (^L, 0x0C) characters
-/[a-zA-Z0-9]/ && !/ / { printf "%s\n\n", $0 }
+{
+ # Strip out control characters, except tab and newline
+ gsub(/[^[:print:]\n\t]/, "")
+
+ # If there's anything left, print it
+ if (length)
+ print
+}