diff options
author | rsc <devnull@localhost> | 2004-05-15 23:24:00 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-05-15 23:24:00 +0000 |
commit | 5cedca1b69d020c32466f70843a11767773d7e3b (patch) | |
tree | a15a3d84e92aa262543b0010763a5e6920c9ba24 /src/cmd/troff/cvt | |
parent | 76e6aca867e3e48ea04fbcf7284c45369a69829e (diff) | |
download | plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.tar.gz plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.tar.bz2 plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.zip |
Let's try this. It's BUGGERED.
Diffstat (limited to 'src/cmd/troff/cvt')
-rw-r--r-- | src/cmd/troff/cvt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cmd/troff/cvt b/src/cmd/troff/cvt new file mode 100644 index 00000000..3426d626 --- /dev/null +++ b/src/cmd/troff/cvt @@ -0,0 +1,45 @@ + +awk ' + +/^{/ { + if (prev != "") { + # comments can be trouble (e.g. ffree()) + if ( (c = match(prev, /\/\*.*\*\/$/)) != 0 ) { + comment = substr(prev, c) + sub(/\/\*.*\*\/$/, "", prev) + } else comment = "" + + x = prev + + # isolate argument list + sub(/^[^(]*\(/, "", x) + sub(/\)[^)]*$/, "", x) + + # find the names in it + n = split(x, args) + arglist = "" + for (i = 2; i <= n; i += 2) + arglist = arglist args[i] + gsub(/\(\*f\)\(Tchar\)/, "f", arglist) # special case for n4.c + gsub(/\[[0-9]+\]/, "", arglist) # for n8.c + gsub(/[*()\[\]]/, "", arglist) # discard noise characters *()[] + gsub(/,/, ", ", arglist) # space nicely + sub(/\(.*\)/, "(" arglist ")", prev) # reconstruct + print prev comment + + # argument declarations + gsub(/,/, ";", x) + gsub(/\(\*f\)\(Tchar\)/, "(*f)()", x) # special case for n4.c + if (x != "") + print "\t" x ";" + } + prev = $0 + next +} + +{ print prev + prev = $0 +} + +END { print prev } +' $* |