#!/usr/bin/perl # check.pl # simple perl script to check if the EXITFUNCTIONS are in the right place # by silver@ewtoo.org use strict; my ($current, $last); my $num = 0; if (!$ARGV[0]) { print "Usage: check.pl <filename>\n"; exit; } open(FILE, $ARGV[0]) || die "can't open $ARGV[0]: $!"; while(<FILE>) { chomp; $num++; $last = $current; $current = $_; $current =~ s/\t/ /g; if ($last =~ /^( *)EXITFUNCTION;/) { my $oin = $1; my $spaces = length($oin); my $nin = " " x ($spaces-2); my $ok = 0; $ok = 1 if ($current =~ /^${oin}return.*;/); $ok = 1 if ($current =~ /^$nin\}/); if ($ok == 0) { print "$ARGV[0]:$num: possibly incorrect location of EXITFUNCTION\n"; printf "%4s: $last\n", $num-1; printf "%4s: $current\n\n", $num; } } } close FILE;