aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/index/rotate
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/rotate
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/rotate')
-rw-r--r--src/cmd/index/rotate31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cmd/index/rotate b/src/cmd/index/rotate
new file mode 100644
index 00000000..76c0274c
--- /dev/null
+++ b/src/cmd/index/rotate
@@ -0,0 +1,31 @@
+awk ' # rotate
+# Input line: string (tab) ["b"|"e"|"a"] (tab) number
+# Output several lines:
+# string (tab) ["b"|"e"|"a"] (tab) number
+# rotated string (tab) ["b"|"e"|"a"] (tab) number
+# rotated string (tab) ["b"|"e"|"a"] (tab) number
+# ...
+#
+# In the output strings, tildes are replaced by spaces
+
+BEGIN { FS = OFS = "\t" }
+
+/ %key / { # if explicit sort.key is provided, do not rotate
+ print $0
+ next
+ }
+
+ {
+ t1 = $1 #t1 will be $1 with tildes changed to spaces
+ gsub(/%~/, "QQ5QQ", t1) #hide real tildes
+ gsub(/~/, " ", t1) #change tildes to spaces
+ gsub(/QQ5QQ/, "%~", t1) #restore real tildes
+ print t1, $2, $3
+ i = 1
+ while ((j = index(substr($1, i+1), " ")) > 0) {
+ i += j
+ printf("%s, %s\t%s\t%s\n", \
+ substr(t1, i+1), substr(t1, 1, i-1), $2, $3)
+ }
+ }
+' $*