From 1bd5a8ac1a4fea1d0becc6d07c41bdd615753f28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Nov 2003 02:44:23 +0000 Subject: final bit of tidyup and speedup (This used to be commit 1c980e6c4e89b24aa8fedf0b6684cd73f34b6c25) --- source4/script/mkproto.pl | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'source4/script/mkproto.pl') diff --git a/source4/script/mkproto.pl b/source4/script/mkproto.pl index de8a8c3a19..c5cb374047 100644 --- a/source4/script/mkproto.pl +++ b/source4/script/mkproto.pl @@ -10,7 +10,6 @@ if ($ARGV[0] eq '-h') { $header_name = shift @ARGV; } - sub print_header { print "#ifndef $header_name\n"; print "#define $header_name\n\n"; @@ -52,46 +51,28 @@ sub handle_loadparm { sub process_file($) { my $filename = shift; - my $line; - my $inheader; - my $gotstart; open(FH, "< $filename") || die "Failed to open $filename"; - $inheader = 0; - $gotstart = 0; - print "\n/* The following definitions come from $filename */\n\n"; - while ($line = ) { - # this ignores most lines + while (my $line = ) { + # these are ordered for maximum speed next if ($line =~ /^\s/); - $gotstart = 0; - - if ($line =~ /^static|^extern/o || - $line !~ /^[a-zA-Z]/o || - $line =~ /[;]/o) { - next; - } - + next unless ($line =~ /\(/); + + next if ($line =~ /^\/|[;]/); + if ($line =~ /^FN_/) { handle_loadparm($line); } - next unless ($line =~ /\(/); - - if ( $line =~ / - ^void|^BOOL|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^unsigned|^long| - ^NTSTATUS|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR|^XFILE|^FILE|^DIR| - ^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME - /xo) { - $gotstart = 1; - } - - - # goto next line if we don't have a start - next unless $gotstart; + next unless ( $line =~ / + ^void|^BOOL|^int|^struct|^char|^const|^\w+_[tT]\s|^uint|^unsigned|^long| + ^NTSTATUS|^ADS_STATUS|^enum\s.*\(|^DATA_BLOB|^WERROR|^XFILE|^FILE|^DIR| + ^double|^TDB_CONTEXT|^TDB_DATA|^TALLOC_CTX|^NTTIME + /xo); if ( $line =~ /\(.*\)\s*$/o ) { chomp $line; @@ -110,6 +91,8 @@ sub process_file($) print "$line\n"; } } + + close(FH); } sub process_files { -- cgit