| File: | config/auto/neg_0.pm |
| Coverage: | 98.1% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2009, Parrot Foundation. | ||||
| 2 | # $Id: neg_0.pm 37147 2009-03-07 00:30:12Z jkeenan $ | ||||
| 3 | |||||
| 4 - 14 | =head1 NAME config/auto/neg_0.pm - can print negative zero =head1 DESCRIPTION Determines whether print -0.0 can print "-0" or just prints "0" This needs workarounds on older win32 (msvcrt.dll) and openbsd. =cut | ||||
| 15 | |||||
| 16 | package auto::neg_0; | ||||
| 17 | |||||
| 18 | 81 81 81 | use strict; | |||
| 19 | 81 81 81 | use warnings; | |||
| 20 | |||||
| 21 | |||||
| 22 | 81 81 81 | use base qw(Parrot::Configure::Step); | |||
| 23 | |||||
| 24 | 81 81 81 | use Parrot::Configure::Utils ':auto'; | |||
| 25 | |||||
| 26 | sub _init { | ||||
| 27 | 83 | my $self = shift; | |||
| 28 | 83 | my %data; | |||
| 29 | 83 | $data{description} = q{Determine whether negative zero can be printed}; | |||
| 30 | 83 | $data{result} = q{}; | |||
| 31 | 83 | return \%data; | |||
| 32 | } | ||||
| 33 | |||||
| 34 | sub runstep { | ||||
| 35 | 81 | my ( $self, $conf ) = @_; | |||
| 36 | 81 | my ( $verbose ) = $conf->options->get('verbose'); | |||
| 37 | 81 | $conf->cc_gen('config/auto/neg_0/test_c.in'); | |||
| 38 | 81 81 | eval { $conf->cc_build( q{} ); }; | |||
| 39 | 81 | my $has_neg_0 = 0; | |||
| 40 | 81 | if ( !$@ ) { | |||
| 41 | 81 | my $test = $conf->cc_run(); | |||
| 42 | 81 | $has_neg_0 = $self->_evaluate_cc_run( | |||
| 43 | $conf, | ||||
| 44 | $test, | ||||
| 45 | $has_neg_0, | ||||
| 46 | $verbose, | ||||
| 47 | ); | ||||
| 48 | } | ||||
| 49 | 81 | $conf->cc_clean(); | |||
| 50 | 81 | $conf->data->set( has_negative_zero => $has_neg_0 ); | |||
| 51 | |||||
| 52 | 81 | return 1; | |||
| 53 | } | ||||
| 54 | |||||
| 55 | sub _evaluate_cc_run { | ||||
| 56 | 85 | my $self = shift; | |||
| 57 | 85 | my ($conf, $test, $has_neg_0, $verbose) = @_; | |||
| 58 | 85 | $has_neg_0 = ($test =~ m/^-0/ ? 1 : 0); | |||
| 59 | 85 | $self->set_result( $has_neg_0 ? 'yes' : 'no' ); | |||
| 60 | 85 | print $has_neg_0 ? ' (yes) ' : ' (no) ' if $verbose; | |||
| 61 | 85 | return $has_neg_0; | |||
| 62 | } | ||||
| 63 | |||||
| 64 | 1; | ||||
| 65 | |||||
| 66 | # Local Variables: | ||||
| 67 | # mode: cperl | ||||
| 68 | # cperl-indent-level: 4 | ||||
| 69 | # fill-column: 100 | ||||
| 70 | # End: | ||||
| 71 | # vim: expandtab shiftwidth=4: | ||||