summaryrefslogtreecommitdiff
path: root/tools/ck-inits-clears
blob: 065488e79b9c6f9f45ea82640835c559819abdeb (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
#!/usr/bin/env perl

# Check that a cast is performed for the last argument of
# mpfr_inits, mpfr_inits2 and mpfr_clears.

use strict;
use warnings;
use File::Find;
use Cwd;

my $err = 0;
find(\&wanted, -d 'src' || getcwd() !~ m,/tools$, ? '.' : '..');
exit $err;

sub wanted
  {
    /\.c$/ && ! /^\.#/ or return;
    my $ctr = 0;
    open FILE, '<', $_ or die;
    while (<FILE>)
      {
        /^ +mpfr_(init|clear)s/ && ! /\(mpfr_ptr\) *(0|NULL)/ or next;
        /, *$/ and $_ .= <FILE>, redo;
        $ctr++ or print "Error found in $File::Find::name\n";
        print;
        $err = 1;
      }
    close FILE or die;
  }