perl 5.0 alpha 2
[p5sagit/p5-mst-13.2.git] / protos
1 #!/usr/bin/perl
2
3 $/ = "\n{\n";
4
5 while (<>) {
6     chop; next unless chop($_) eq "{";
7     s/[^\0]*\n\n//;
8     $* = 1;
9     s/^#.*\n//g;
10     $* = 0;
11     tr/\n/ /;
12     s#\*/#\200#g;
13     s#/\*[^\200]*\200##g;
14     /\b\w+\(/ || next;
15     $funtype = $`;
16     $name = $&;
17     $_ = $';
18     /\)\s*/ || next;
19     $args = $`;
20     $types = $';
21     $args =~ tr/ \t//d;
22     @args = split(/,/,$args);
23     @types = split(/;\s*/, $types);
24     %type = ();
25     foreach $type (@types) {
26         $type =~ /.*\b(\w+)/;
27         $type{$1} = $type;
28     }
29     foreach $arg (@args) {
30         $arg = $type{$arg} || $arg;
31         $arg =~ s/register //;
32     }
33     $funtype =~ s/\* $/*/;
34     $funtype =~ s/^ *//;
35     chop $name;
36     if (@args) {
37         print $funtype, $name, " P((", join(', ', @args), "));\n";
38     }
39     else {
40         print $funtype, $name, " P((void));\n";
41     }
42 }