summaryrefslogtreecommitdiff
path: root/regress/style/check_stderr.pl
blob: 831c5200b1ed13165b4ee94e577d9945b67c33ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
#
# $FML$
#

use strict;
use Carp;

$| = 1;

my $in_curproc  = 0;
my $in_function = 0;
my $in_debug    = 0;
my $cur_function_name;

while (<>) {
    if (/^sub\s+(\S+)/) { 
	_reset();
	$in_function = 1;
	$cur_function_name = $1;
	next;
    }

    if (/if.*\$0 eq __FILE__/) {
	_reset();
    }

    if (/if \(0\) \{/) {
	_reset();
    }

    if ($in_function) {
	if (/if.*\$debug/) { 
	    $in_debug = 1;
	}
	elsif (/^\s*$/) { 
	    $in_debug = 0;
	}

	if (/print\s+STDERR/o) {
	    if ($in_debug) {
		print STDERR "ok $ARGV $cur_function_name\n" if 0;
	    }
	    else {
		print STDERR "?? $ARGV $cur_function_name $_";
	    }
	}
    }
}


sub _reset
{
    $in_curproc  = 0;
    $in_function = 0;
    $in_debug    = 0;
    undef $cur_function_name;
}