File Coverage

File:config/auto/snprintf.pm
Coverage:95.7%

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

config/auto/snprintf.pm - Test for snprintf

=head1 DESCRIPTION

Tests if snprintf is present and if it's C99 compliant.

=cut
12
13package auto::snprintf;
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
20sub _init {
21
4
    my $self = shift;
22
4
    my %data;
23
4
    $data{description} = q{Test snprintf};
24
4
    $data{result} = q{};
25
4
    return \%data;
26}
27
28sub runstep {
29
1
    my ( $self, $conf ) = @_;
30
31
1
    my $res = _probe_for_snprintf($conf);
32
33
1
    $self->_evaluate_snprintf($conf, $res);
34
35
1
    return 1;
36}
37
38sub _probe_for_snprintf {
39
1
    my $conf = shift;
40
1
    $conf->cc_gen('config/auto/snprintf/test_c.in');
41
1
    $conf->cc_build();
42
1
    my $res = $conf->cc_run() or die "Can't run the snprintf testing program: $!";
43
1
    $conf->cc_clean();
44
1
    return $res;
45}
46
47sub _evaluate_snprintf {
48
4
    my ($self, $conf, $res) = @_;
49
4
    if ( $res =~ /snprintf/ ) {
50
4
        $conf->data->set( HAS_SNPRINTF => 1 );
51    }
52
4
    if ( $res =~ /^C99 snprintf/ ) {
53
2
        $conf->data->set( HAS_C99_SNPRINTF => 1 );
54    }
55    elsif ( $res =~ /^old snprintf/ ) {
56
1
        $conf->data->set( HAS_OLD_SNPRINTF => 1 );
57    }
58
4
    $conf->debug(" ($res) ");
59
4
    return 1;
60}
61
621;
63
64# Local Variables:
65# mode: cperl
66# cperl-indent-level: 4
67# fill-column: 100
68# End:
69# vim: expandtab shiftwidth=4: