From 152c9a039c7e7956fe2402b4c7d739f363e06bbf Mon Sep 17 00:00:00 2001 From: Danilo Almeida Date: Fri, 5 Apr 2002 23:19:38 +0000 Subject: [PATCH] * def-check.pl: Better error checking. Handles variable argument functions more nicely. Support for KRB5_CALLCONV_WRONG, KRB5INT_BEGIN_DECLS, KRB5INT_END_DECLS. Works with krb5.hin, krb5.h, and k5-int.h (giving different information for the last one, of course). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14359 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/ChangeLog | 8 ++++++ src/util/def-check.pl | 57 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 8f903129c..3e4181a95 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,3 +1,11 @@ +2002-04-05 Danilo Almeida + + * def-check.pl: Better error checking. Handles variable argument + functions more nicely. Support for KRB5_CALLCONV_WRONG, + KRB5INT_BEGIN_DECLS, KRB5INT_END_DECLS. Works with krb5.hin, + krb5.h, and k5-int.h (giving different information for the last + one, of course). + 2001-10-25 Ezra Peisach * reconf: Require autoconf 2.13. Remove support for local autoconf diff --git a/src/util/def-check.pl b/src/util/def-check.pl index d74eb7399..09181f24b 100644 --- a/src/util/def-check.pl +++ b/src/util/def-check.pl @@ -13,7 +13,7 @@ my $h_filename = shift @ARGV || die "usage: $0 header-file [def-file]\n"; my $d_filename = shift @ARGV; my $h = open_always($h_filename); -my $d = open_always($d_filename); +my $d = open_always($d_filename) if $d_filename; sub open_always { @@ -23,13 +23,16 @@ sub open_always return $handle; } +my @convW = (); my @convC = (); my @convK = (); my @convD = (); +my @vararg = (); my $len1; my %conv; my $printit; +my $vararg; LINE: while (! $h->eof()) { @@ -43,6 +46,13 @@ while (! $h->eof()) { next LINE; } Top: + # drop KRB5INT_BEGIN_DECLS and KRB5INT_END_DECLS + if (/^ *KRB5INT_BEGIN_DECLS/) { + next LINE; + } + if (/^ *KRB5INT_END_DECLS/) { + next LINE; + } # drop preprocessor directives if (/^ *#/) { next LINE; @@ -119,9 +129,13 @@ while (! $h->eof()) { } s/[ \t]*$//; goto Notfunct unless /\(.*\)/; + # Get rid of KRB5_PROTOTYPE + s/KRB5_PROTOTYPE//; + s/KRB5_STDARG_P//; # here, is probably function decl # strip simple arg list - parens, no parens inside; discard, iterate. # the iteration should deal with function pointer args. + $vararg = /\.\.\./; Striparg: if (/ *\([^\(\)]*\)/) { s/ *\([^\(\)]*\)//g; @@ -129,20 +143,31 @@ while (! $h->eof()) { } # replace return type etc with one token indicating calling convention if (/CALLCONV/) { - if (/KRB5_CALLCONV_C/) { + if (/\bKRB5_CALLCONV_WRONG\b/) { + s/^.*KRB5_CALLCONV_WRONG *//; + die "Invalid function name: '$_'" if (!/^[A-Za-z0-9_]+$/); + push @convW, $_; + push @vararg, $_ if $vararg; + } elsif (/\bKRB5_CALLCONV_C\b/) { s/^.*KRB5_CALLCONV_C *//; + die "Invalid function name: '$_'" if (!/^[A-Za-z0-9_]+$/); push @convC, $_; - } elsif (/KRB5_CALLCONV/) { + push @vararg, $_ if $vararg; + } elsif (/\bKRB5_CALLCONV\b/) { s/^.*KRB5_CALLCONV *//; + die "Invalid function name: '$_'" if (!/^[A-Za-z0-9_]+$/); push @convK, $_; + push @vararg, $_ if $vararg; } else { - die; + die "Unrecognized calling convention while parsing: '$_'\n"; } goto Hadcallc; } # deal with no CALLCONV indicator s/^.* (\w+) *$/$1/; + die "Invalid function name: '$_'" if (!/^[A-Za-z0-9_]+$/); push @convD, $_; + push @vararg, $_ if $vararg; Hadcallc: goto Skipnotf; Notfunct: @@ -157,15 +182,23 @@ while (! $h->eof()) { print join("\n\t", "Using default calling convention:", sort(@convD)); print join("\n\t", "\nUsing KRB5_CALLCONV:", sort(@convK)); -print join("\n\t", "\nUsing KRB5_C_CALLCONV:", sort(@convC)); -print "\n"; +print join("\n\t", "\nUsing KRB5_CALLCONV_C:", sort(@convC)); +print join("\n\t", "\nUsing KRB5_CALLCONV_WRONG:", sort(@convW)); +print "\n","-"x70,"\n"; %conv = (); map { $conv{$_} = "default"; } @convD; -map { $conv{$_} = "KRB5"; } @convK; -map { $conv{$_} = "KRB5_C"; } @convC; +map { $conv{$_} = "KRB5_CALLCONV"; } @convK; +map { $conv{$_} = "KRB5_CALLCONV_C"; } @convC; +map { $conv{$_} = "KRB5_CALLCONV_WRONG"; } @convW; + +my %vararg = (); +map { $vararg{$_} = 1; } @vararg; -exit if !$d; +if (!$d) { + print "No .DEF file specified\n"; + exit; +} LINE2: while (! $d->eof()) { @@ -187,9 +220,11 @@ while (! $d->eof()) { s/[ \t]*//g; my($xconv); if (/!CALLCONV/) { - $xconv = "KRB5_C"; + $xconv = "KRB5_CALLCONV_WRONG"; + } elsif ($vararg{$_}) { + $xconv = "KRB5_CALLCONV_C"; } else { - $xconv = "KRB5"; + $xconv = "KRB5_CALLCONV"; } s/;.*$//; if (!defined($conv{$_})) { -- 2.26.2