]> git.saurik.com Git - apple/xnu.git/blame - bsd/miscfs/devfs/reproto.sh
xnu-123.5.tar.gz
[apple/xnu.git] / bsd / miscfs / devfs / reproto.sh
CommitLineData
1c79356b
A
1#!/bin/sh
2#
3# This used to be a shell script, but had to become more sophisticated
4# to allow for KNF function definitions. So rewrote in perl, but wrapped
5# as a shell script.
6#
7exec /usr/bin/perl << *EOF*
8open(PROTO, ">devfs_proto.h") || die "Cannot open devfs_proto.h\n";
9
10print PROTO "/* THIS FILE HAS BEEN PRODUCED AUTOMATICALLY */\n";
11
12while (\$file = <*.c>) {
13 if(open(F, \$file) == 0) {
14 warn "Cannot open \$file.\n";
15 next;
16 }
17
18 while(<F>) {
19 chop;
20 if (m|/\*proto\*/|) {
21 \$collecting = 1;
22 \$idx = 0;
23 } elsif (\$collecting) {
24 if (/^{/) {
25 \$text[\$idx - 1] .= ';';
26 for (\$i = 0; \$i < \$idx; \$i++) {
27 print PROTO "\$text[\$i]";
28 print PROTO \$i == 0? "\t": "\n";
29 }
30 \$collecting = 0;
31 next;
32 }
33 \$text[\$idx++] = \$_;
34 }
35 }
36 close F;
37}
38
39print PROTO "/* THIS FILE PRODUCED AUTOMATICALLY */\n" .
40 "/* DO NOT EDIT (see reproto.sh) */\n";
41
42*EOF*