From: Jelmer Vernooij Date: Sun, 6 Jan 2008 03:29:25 +0000 (-0600) Subject: r26675: mkproto: Add --all argument, fix some perl warnings. X-Git-Tag: samba-4.0.0alpha3~558 X-Git-Url: http://git.samba.org/samba.git/?p=ira%2Fwip.git;a=commitdiff_plain;h=a175ee6594046c44572e3314ab7c3b61dcd7422f;hp=2df0f7016e27705c3799b2f6bb20fcc17b103c36 r26675: mkproto: Add --all argument, fix some perl warnings. --- diff --git a/source/script/mkproto.pl b/source/script/mkproto.pl index f1c2cf9d0e8..3ed845e2bb5 100755 --- a/source/script/mkproto.pl +++ b/source/script/mkproto.pl @@ -17,14 +17,15 @@ use File::Path; my $public_file = undef; my $private_file = undef; +my $all_file = undef; my $public_define = undef; my $private_define = undef; my $_public = ""; my $_private = ""; my $public_data = \$_public; my $private_data = \$_private; -my $builddir = undef; -my $srcdir = undef; +my $builddir = "."; +my $srcdir = "."; sub public($) { @@ -55,6 +56,7 @@ sub usage() GetOptions( 'public=s' => sub { my ($f,$v) = @_; $public_file = $v; }, + 'all=s' => sub { my ($f,$v) = @_; $public_file = $v; $private_file = $v; }, 'private=s' => sub { my ($f,$v) = @_; $private_file = $v; }, 'define=s' => sub { my ($f,$v) = @_; @@ -93,9 +95,9 @@ if ((defined($private_file) and defined($public_file) and ($private_file eq $pub sub file_load($) { - my($filename) = shift; + my($filename) = @_; local(*INPUTFILE); - open(INPUTFILE, $filename) || return undef; + open(INPUTFILE, $filename) or return undef; my($saved_delim) = $/; undef $/; my($data) = ; @@ -231,7 +233,7 @@ sub process_file($$$) print_header(\&public, $public_define); -if ($public_file ne $private_file) { +if (defined($private_file) and defined($public_file) and $public_file ne $private_file) { print_header(\&private, $private_define); private("/* this file contains prototypes for functions that " . @@ -251,7 +253,7 @@ public("#ifndef _WARN_UNUSED_RESULT_\n#define _WARN_UNUSED_RESULT_\n#endif\n\n") process_file(\&public, \&private, $_) foreach (@ARGV); print_footer(\&public, $public_define); -if ($public_file ne $private_file) { +if (defined($private_file) and $public_file ne $private_file) { print_footer(\&private, $private_define); } @@ -263,15 +265,12 @@ if (not defined($private_file) and defined($public_file)) { print STDOUT $$private_data; } -my $old_public_data = file_load($public_file); -my $old_private_data = file_load($private_file); - mkpath(dirname($public_file), 0, 0755); open(PUBLIC, ">$public_file") or die("Can't open `$public_file': $!"); print PUBLIC "$$public_data"; close(PUBLIC); -if ($public_file ne $private_file) { +if (defined($private_file) and $public_file ne $private_file) { mkpath(dirname($private_file), 0, 0755); open(PRIVATE, ">$private_file") or die("Can't open `$private_file': $!"); print PRIVATE "$$private_data";