File Coverage

File:config/auto/isreg.pm
Coverage:95.3%

linestmtbrancondsubcode
1# Copyright (C) 2001-2003, Parrot Foundation.
2
3 - 11
=head1 NAME

config/auto/isreg - S_ISREG

=head1 DESCRIPTION

Determines if the C library has a working C<S_ISREG>.

=cut
12
13package auto::isreg;
14
15
2
2
2
use strict;
16
2
2
2
use warnings;
17
18
2
2
2
use base qw(Parrot::Configure::Step);
19
20
2
2
2
use Parrot::Configure::Utils ':auto';
21
22
23sub _init {
24
4
    my $self = shift;
25
4
    my %data;
26
4
    $data{description} = q{Does your C library have a working S_ISREG};
27
4
    $data{result} = q{};
28
4
    return \%data;
29}
30
31sub runstep {
32
2
    my ( $self, $conf ) = @_;
33
34
2
    my $errormsg = _first_probe_for_isreg($conf);
35
36
2
    if (! $errormsg) {
37
2
        $errormsg = _second_probe_for_isreg($conf);
38    }
39
2
    $conf->cc_clean();
40
2
    $self->_evaluate_isreg($conf, $errormsg);
41
2
    return 1;
42}
43
44sub _first_probe_for_isreg {
45
2
    my $conf = shift;
46
2
    my $errormsg;
47
2
    $conf->cc_gen('config/auto/isreg/test_c.in');
48
2
2
    eval { $conf->cc_build(); };
49
2
    $errormsg = 1 if $@;
50
2
    return $errormsg;
51}
52
53sub _second_probe_for_isreg {
54
2
    my $conf = shift;
55
2
    my $ccrunfailure;
56
2
    $ccrunfailure++ if ( $conf->cc_run() !~ /ok/ );
57
2
    return $ccrunfailure;
58}
59
60sub _evaluate_isreg {
61
4
    my ($self, $conf, $anyerror) = @_;
62
4
    my $test;
63
4
    $test = (! defined $anyerror) ? 1 : 0;
64
4
    $conf->data->set( isreg => $test );
65
4
    my $test_str = $test ? " (Yep) " : " (no) ";
66
4
    $conf->debug($test_str);
67
4
    $self->set_result( $test ? 'yes' : 'no' );
68
4
    return 1;
69}
70
711;
72
73# Local Variables:
74# mode: cperl
75# cperl-indent-level: 4
76# fill-column: 100
77# End:
78# vim: expandtab shiftwidth=4: