More troff bits; if you want them elsewhere, feel free to repo copy them.
This commit is contained in:
parent
a7eb134e87
commit
aa83d77271
22 changed files with 670 additions and 1 deletions
31
src/cmd/index/rotate
Normal file
31
src/cmd/index/rotate
Normal file
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
' $*
|
||||
Loading…
Add table
Add a link
Reference in a new issue