aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/index/num.collapse
diff options
context:
space:
mode:
authorwkj <devnull@localhost>2004-05-17 03:22:35 +0000
committerwkj <devnull@localhost>2004-05-17 03:22:35 +0000
commitaa83d77271f0d2be72067058f78abd1780f3b69e (patch)
tree14a24e73abb43ad0b7340a1623e077a733b0be33 /src/cmd/index/num.collapse
parenta7eb134e8717c2ea831066891314cf74fa4a6ad3 (diff)
downloadplan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.tar.gz
plan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.tar.bz2
plan9port-aa83d77271f0d2be72067058f78abd1780f3b69e.zip
More troff bits; if you want them elsewhere, feel free to repo copy them.
Diffstat (limited to 'src/cmd/index/num.collapse')
-rw-r--r--src/cmd/index/num.collapse21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cmd/index/num.collapse b/src/cmd/index/num.collapse
new file mode 100644
index 00000000..47203f52
--- /dev/null
+++ b/src/cmd/index/num.collapse
@@ -0,0 +1,21 @@
+awk ' # num.collapse
+# Input: lines of form: string (tab) num1 [(space) num2]
+# Output: lines of form: string (tab) fancy.num.list
+#
+# fancy.num.list contains items, separated by ", ", of form: num or num-num
+# Sequence of input lines with same value of string is combined
+# into a single output line. Each input line contributes either
+# num or num-num to output line.
+
+BEGIN { FS = OFS = "\t" }
+
+ { sub(/ /, "\\(en", $2) } # use - if there is no en dash
+
+$1 != p { p = $1
+ if (NR > 1) printf "\n"
+ printf "%s\t%s", $1, $2
+ next
+ }
+ { printf ", %s", $2 }
+END { if (NR > 0) printf "\n" }
+' $*