+2001-10-17 Danilo Almeida <dalmeida@mit.edu>
+
+ * def-check.pl: Provide a little bit of usage info. More
+ error-checking.
+
2001-10-17 Ken Raeburn <raeburn@mit.edu>
* def-check.pl: New file. Not currently used by any automatic
-#!/usr/athena/bin/perl
+#!/usr/athena/bin/perl -w
+
+# Code initially generated by s2p
+# Code modified to use strict and IO::File
+
eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}'
- if $running_under_some_shell;
+ if 0; # line above evaluated when running under some shell (i.e., not perl)
+
+use strict;
+use IO::File;
+
+my $h_filename = shift @ARGV || die "usage: $0 header-file [def-file]\n";
+my $d_filename = shift @ARGV;
-@convC = ();
-@convK = ();
-@convD = ();
+my $h = open_always($h_filename);
+my $d = open_always($d_filename);
-open H, "<$ARGV[0]" || die "aaaa! $!";
-open D, "<$ARGV[1]";
+sub open_always
+{
+ my $file = shift || die;
+ my $handle = new IO::File "<$file";
+ die "Could not open $file\n" if !$handle;
+ return $handle;
+}
+
+my @convC = ();
+my @convK = ();
+my @convD = ();
+
+my $len1;
+my %conv;
+my $printit;
LINE:
-while (! eof H) {
- $_ = <H>;
+while (! $h->eof()) {
+ $_ = $h->getline();
chop;
# get calling convention info for function decls
# what about function pointer typedefs?
if (/\/\*$/) {
$_ .= "\n";
$len1 = length;
- $_ .= <H>;
+ $_ .= $h->getline();
chop if $len1 < length;
goto Cloop1 if /\/\*./;
}
if (/{/) {
$_ .= "\n";
$len1 = length;
- $_ .= <H>;
+ $_ .= $h->getline();
chop if $len1 < length;
goto Struct1;
}
unless (/;/) {
$_ .= "\n";
$len1 = length;
- $_ .= <H>;
+ $_ .= $h->getline();
chop if $len1 < length;
s/\n/ /g;
s/[ \t]+/ /g;
s/^.*KRB5_CALLCONV *//;
push @convK, $_;
} else {
- die horribly;
+ die;
}
goto Hadcallc;
}
map { $conv{$_} = "KRB5"; } @convK;
map { $conv{$_} = "KRB5_C"; } @convC;
+exit if !$d;
+
LINE2:
-while (! eof D) {
- $_ = <D>;
+while (! $d->eof()) {
+ $_ = $d->getline();
chop;
#
if (/^;/) {
s/;.*$//;
if (!defined($conv{$_})) {
print "No calling convention specified for $_!\n";
- } elsif ($conv{$_} != $xconv) {
+ } elsif (! ($conv{$_} eq $xconv)) {
print "Function $_ should have calling convention '$xconv', but has '$conv{$_}' instead.\n";
} else {
# print "Function $_ is okay.\n";