diff options
Diffstat (limited to 'sys/miscfs/devfs/reproto.sh')
-rw-r--r-- | sys/miscfs/devfs/reproto.sh | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/sys/miscfs/devfs/reproto.sh b/sys/miscfs/devfs/reproto.sh index 277f68a..e994e0c 100644 --- a/sys/miscfs/devfs/reproto.sh +++ b/sys/miscfs/devfs/reproto.sh @@ -1,6 +1,42 @@ #!/bin/sh -echo "/* THIS FILE PRODUCED AUTOMATICALLY */" >devfs_proto.h -grep -h '/\*proto\*/' *.c |awk '{print $0 ";"}' >>devfs_proto.h -echo "/* THIS FILE PRODUCED AUTOMATICALLY */" >>devfs_proto.h -echo "/* DO NOT EDIT (see reproto.sh) */" >>devfs_proto.h +# +# This used to be a shell script, but had to become more sophisticated +# to allow for KNF function definitions. So rewrote in perl, but wrapped +# as a shell script. +# +exec /usr/bin/perl << *EOF* +open(PROTO, ">devfs_proto.h") || die "Cannot open devfs_proto.h\n"; +print PROTO "/* THIS FILE HAS BEEN PRODUCED AUTOMATICALLY */\n"; + +while (\$file = <*.c>) { + if(open(F, \$file) == 0) { + warn "Cannot open \$file.\n"; + next; + } + + while(<F>) { + chop; + if (m|/\*proto\*/|) { + \$collecting = 1; + \$idx = 0; + } elsif (\$collecting) { + if (/^{/) { + \$text[\$idx - 1] .= ';'; + for (\$i = 0; \$i < \$idx; \$i++) { + print PROTO "\$text[\$i]"; + print PROTO \$i == 0? "\t": "\n"; + } + \$collecting = 0; + next; + } + \$text[\$idx++] = \$_; + } + } + close F; +} + +print PROTO "/* THIS FILE PRODUCED AUTOMATICALLY */\n" . + "/* DO NOT EDIT (see reproto.sh) */\n"; + +*EOF* |