File Coverage

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

linestmtbrancondsubcode
1# Copyright (C) 2001-2003, Parrot Foundation.
2# $Id: isreg.pm 37201 2009-03-08 12:07:48Z fperrad $
3
4 - 12
=head1 NAME

config/auto/isreg - S_ISREG

=head1 DESCRIPTION

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

=cut
13
14package auto::isreg;
15
16
81
81
81
use strict;
17
81
81
81
use warnings;
18
19
81
81
81
use base qw(Parrot::Configure::Step);
20
21
81
81
81
use Parrot::Configure::Utils ':auto';
22
23
24sub _init {
25
83
    my $self = shift;
26
83
    my %data;
27
83
    $data{description} = q{Does your C library have a working S_ISREG};
28
83
    $data{result} = q{};
29
83
    return \%data;
30}
31
32sub runstep {
33
81
    my ( $self, $conf ) = @_;
34
35
81
    my $errormsg = _first_probe_for_isreg($conf);
36
37
81
    if (! $errormsg) {
38
81
        $errormsg = _second_probe_for_isreg($conf);
39    }
40
81
    $conf->cc_clean();
41
81
    $self->_evaluate_isreg($conf, $errormsg);
42
81
    return 1;
43}
44
45sub _first_probe_for_isreg {
46
81
    my $conf = shift;
47
81
    my $errormsg;
48
81
    $conf->cc_gen('config/auto/isreg/test_c.in');
49
81
81
    eval { $conf->cc_build(); };
50
81
    $errormsg = 1 if $@;
51
81
    return $errormsg;
52}
53
54sub _second_probe_for_isreg {
55
81
    my $conf = shift;
56
81
    my $ccrunfailure;
57
81
    $ccrunfailure++ if ( $conf->cc_run() !~ /ok/ );
58
81
    return $ccrunfailure;
59}
60
61sub _evaluate_isreg {
62
83
    my ($self, $conf, $anyerror) = @_;
63
83
    my $test;
64
83
    $test = (! defined $anyerror) ? 1 : 0;
65
83
    $conf->data->set( isreg => $test );
66
83
    print( $test ? " (Yep) " : " (no) " ) if $conf->options->get('verbose');
67
83
    $self->set_result( $test ? 'yes' : 'no' );
68
83
    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: