| cvt - 9base - revived minimalist port of Plan 9 userland to Unix | |
| git clone git://git.suckless.org/9base | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| cvt (938B) | |
| --- | |
| 1 | |
| 2 awk ' | |
| 3 | |
| 4 /^{/ { | |
| 5 if (prev != "") { | |
| 6 # comments can be trouble (e.g. ffree()) | |
| 7 if ( (c = match(prev, /\/\*.*\*\/$/)) != 0 ) { | |
| 8 comment = substr(prev, c) | |
| 9 sub(/\/\*.*\*\/$/, "", prev) | |
| 10 } else comment = "" | |
| 11 | |
| 12 x = prev | |
| 13 | |
| 14 # isolate argument list | |
| 15 sub(/^[^(]*\(/, "", x) | |
| 16 sub(/\)[^)]*$/, "", x) | |
| 17 | |
| 18 # find the names in it | |
| 19 n = split(x, args) | |
| 20 arglist = "" | |
| 21 for (i = 2; i <= n; i += 2) | |
| 22 arglist = arglist args[i] | |
| 23 gsub(/\(\*f\)\(Tchar\)/, "f", arglist) # special … | |
| 24 gsub(/\[[0-9]+\]/, "", arglist) # for… | |
| 25 gsub(/[*()\[\]]/, "", arglist) # discard … | |
| 26 gsub(/,/, ", ", arglist) # space nicely | |
| 27 sub(/\(.*\)/, "(" arglist ")", prev) # reconstruct | |
| 28 print prev comment | |
| 29 | |
| 30 # argument declarations | |
| 31 gsub(/,/, ";", x) | |
| 32 gsub(/\(\*f\)\(Tchar\)/, "(*f)()", x) # special c… | |
| 33 if (x != "") | |
| 34 print "\t" x ";" | |
| 35 } | |
| 36 prev = $0 | |
| 37 next | |
| 38 } | |
| 39 | |
| 40 { print prev | |
| 41 prev = $0 | |
| 42 } | |
| 43 | |
| 44 END { print prev } | |
| 45 ' $* |