diff --git a/cf/make-proto.pl b/cf/make-proto.pl index 0cff8f673..d478944c9 100644 --- a/cf/make-proto.pl +++ b/cf/make-proto.pl @@ -7,13 +7,18 @@ require 'getopts.pl'; $brace = 0; $line = ""; $debug = 0; +$oproto = 1; -do Getopts('o:p:d') || die "foo"; +do Getopts('o:p:dqP:') || die "foo"; if($opt_d) { $debug = 1; } +if($opt_q) { + $oproto = 0; +} + while(<>) { print $brace, " ", $_ if($debug); if(/^\#if 0/) { @@ -50,28 +55,43 @@ while(<>) { $attr = ""; } # remove outer () - s/\s*\(/@/; - s/\)\s?$/@/; + s/\s*\(//; # remove , within () while(s/\(([^()]*),(.*)\)/($1\$$2)/g){} + s/\<\s*void\s*\>/<>/; + # remove parameter names + if($opt_P eq "remove") { + s/(\s*)([a-zA-Z0-9_]+)([,>])/$3/g; + s/\(\*(\s*)([a-zA-Z0-9_]+)\)/(*)/g; + } elsif($opt_P eq "comment") { + s/([a-zA-Z0-9_]+)([,>])/\/\*$1\*\/$2/g; + s/\(\*([a-zA-Z0-9_]+)\)/(*\/\*$1\*\/)/g; + } + s/\<\>//; + # add newlines before parameters s/,\s*/,\n\t/g; # fix removed , s/\$/,/g; # match function name - /([a-zA-Z0-9_]+)\s*@/; + /([a-zA-Z0-9_]+)\s*\/$RP/; # insert newline before function name - s/(.*)\s([a-zA-Z0-9_]+ __P)/$1\n$2/; + s/(.*)\s([a-zA-Z0-9_]+ \Q$LP\E)/$1\n$2/; if($attr ne "") { $_ .= "\n $attr"; } @@ -121,7 +141,9 @@ $public_h_header = "/* This is a generated file */ #ifndef $block #define $block -#ifdef __STDC__ +"; +if ($oproto) { +$public_h_header .= "#ifdef __STDC__ #include #ifndef __P #define __P(x) x @@ -133,12 +155,15 @@ $public_h_header = "/* This is a generated file */ #endif "; +} $private_h_header = "/* This is a generated file */ #ifndef $private #define $private -#ifdef __STDC__ +"; +if($oproto) { +$private_h_header .= "#ifdef __STDC__ #include #ifndef __P #define __P(x) x @@ -150,7 +175,7 @@ $private_h_header = "/* This is a generated file */ #endif "; - +} foreach(sort keys %funcs){ if(/^(main)$/) { next } if(/^_/) {