Index: parrot-svn/lib/Parrot/Configure/Step/List.pm =================================================================== --- parrot-svn.orig/lib/Parrot/Configure/Step/List.pm 2009-01-02 12:48:36.000000000 +0000 +++ parrot-svn/lib/Parrot/Configure/Step/List.pm 2009-02-11 18:48:35.444625000 +0000 @@ -50,6 +50,7 @@ auto::memalign auto::signal auto::socklen_t + auto::neg_0 auto::env auto::gmp auto::readline Index: parrot-svn/t/op/arithmetics.t =================================================================== --- parrot-svn.orig/t/op/arithmetics.t 2009-02-11 17:37:36.913375000 +0000 +++ parrot-svn/t/op/arithmetics.t 2009-02-11 18:31:19.100875000 +0000 @@ -33,29 +33,23 @@ pasm_output_is( <<'CODE', <_evaluate_negative_zero($conf, $d_negative_zero); + my ( $verbose ) = $conf->options->get('verbose'); + $conf->cc_gen('config/auto/neg_0/test_c.in'); + eval { $conf->cc_build( q{} ); }; + my $has_neg_0 = 0; + if ( !$@ ) { + my $test = $conf->cc_run(); + $has_neg_0 = $self->_evaluate_cc_run($conf, $test, $has_neg_0, $verbose); + } + $conf->cc_clean(); + $conf->data->set( has_negative_zero => $has_neg_0 ); return 1; } -sub _probe_for_negative_zero { - my $conf = shift; - return $conf->data->get('has_negative_zero') - || - $conf->data->get_p5('d_negative_zero'); -} - -sub _evaluate_negative_zero { - my ($self, $conf, $d_negative_zero) = @_; - my $has_negative_zero = $d_negative_zero ? 1 : 0; - $self->set_result( $has_negative_zero ? 'yes' : 'no' ); - $conf->data->set( has_negative_zero => $has_negative_zero ); +sub _evaluate_cc_run { + my $self = shift; + my ($conf, $test, $has_neg_0, $verbose) = @_; + if ( $test =~ m/^-0/ ) { + $has_neg_0 = 1; + $self->set_result( $has_neg_0 ? 'yes' : 'no' ); + $conf->data->set( has_negative_zero => $has_neg_0 ); + print " (yes) " if $verbose; + } + return $has_neg_0; } 1; Index: parrot-svn/t/steps/auto_neg_0-01.t =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ parrot-svn/t/steps/auto_neg_0-01.t 2009-02-11 19:46:30.382125000 +0000 @@ -0,0 +1,106 @@ +#! perl +# Copyright (C) 2009, The Perl Foundation. +# $Id: auto_socklen_t-01.t 30640 2008-08-29 23:09:28Z jkeenan $ +# auto_neg_0-01.t + +use strict; +use warnings; +use Test::More tests => 16; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::auto::socklen_t'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( + test_step_thru_runstep + rerun_defaults_for_testing + test_step_constructor_and_description +); +use IO::CaptureOutput qw| capture |; + +########### regular ########### + +my ($args, $step_list_ref) = process_options( + { + argv => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +my $pkg = q{auto::neg_0}; + +$conf->add_steps($pkg); + +my $serialized = $conf->pcfreeze(); + +$conf->options->set( %{$args} ); +my $step = test_step_constructor_and_description($conf); +my $ret = $step->runstep($conf); +ok( $ret, "runstep() returned true value" ); +ok(defined($step->result()), "A result has been defiined"); + +$conf->replenish($serialized); + +##### _evaluate_neg_0_t() ##### + +($args, $step_list_ref) = process_options( + { + argv => [ ], + mode => q{configure}, + } +); +$conf->options->set( %{$args} ); +$step = test_step_constructor_and_description($conf); + +my $d_neg_zero; + +$d_neg_zero = q{-0}; +ok($step->_evaluate_cc_run($conf, $d_neg_zero), + "_evaluate_cc_run() completed satisfactorily"); +is($step->result(), q{yes}, "Got expected result"); +is($conf->data->get('has_negative_zero'), 1, + "has_negative_zero set as expected"); + +$d_neg_zero = q{0}; +ok($step->_evaluate_cc_run($conf, $d_neg_zero), + "_evaluate_cc_run() completed satisfactorily"); +is($step->result(), q{no}, "Got expected result"); +is($conf->data->get('has_negative_zero'), 0, + "has_negative_zero set as expected"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +auto_neg_0-01.t - test auto::neg_0 + +=head1 SYNOPSIS + + % prove t/steps/auto_neg_0-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test auto::neg_0. + +=head1 AUTHOR + +Reini Urban + +=head1 SEE ALSO + +config::auto::neg_0, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Index: parrot-svn/MANIFEST =================================================================== --- parrot-svn.orig/MANIFEST 2009-02-11 11:09:51.000000000 +0000 +++ parrot-svn/MANIFEST 2009-02-11 19:20:21.725875000 +0000 @@ -273,6 +273,8 @@ config/auto/memalign/test_c.in [] config/auto/msvc.pm [] config/auto/msvc/test_c.in [] +config/auto/neg_0.pm [] +config/auto/neg_0/test_c.in [] config/auto/opengl.pm [] config/auto/opengl/opengl_c.in [] config/auto/ops.pm [] @@ -3247,6 +3249,7 @@ t/steps/auto_macports-02.t [] t/steps/auto_memalign-01.t [] t/steps/auto_msvc-01.t [] +t/steps/auto_neg_0-01.t [] t/steps/auto_opengl-01.t [] t/steps/auto_ops-01.t [] t/steps/auto_pcre-01.t [] Index: parrot-svn/config/auto/neg_0/test_c.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ parrot-svn/config/auto/neg_0/test_c.in 2009-02-11 18:18:18.038375000 +0000 @@ -0,0 +1,8 @@ +#include + +int +main(int argc, char* argv[]) +{ + printf("%.0f", -0.0); + return 0; +} Index: parrot-svn/config/gen/config_h/feature_h.in =================================================================== --- parrot-svn.orig/config/gen/config_h/feature_h.in 2008-12-06 00:10:10.000000000 +0000 +++ parrot-svn/config/gen/config_h/feature_h.in 2009-02-11 18:58:27.663375000 +0000 @@ -154,6 +154,15 @@ print OUT <<'END_PRINT'; +/* from config/auto/neg_0 */ +END_PRINT +if (@has_negative_zero@) { + print OUT <<'END_PRINT'; +#define PARROT_HAS_NEGATIVE_ZERO 1 +END_PRINT +} + +print OUT <<'END_PRINT'; #endif /* PARROT_FEATURE_H_GUARD */ END_PRINT Index: parrot-svn/src/ops/io.ops =================================================================== --- parrot-svn.orig/src/ops/io.ops 2009-02-03 20:00:26.000000000 +0000 +++ parrot-svn/src/ops/io.ops 2009-02-11 19:10:47.085250000 +0000 @@ -152,7 +152,17 @@ } inline op print(in NUM) :base_io { +#ifdef PARROT_HAS_NEGATIVE_ZERO Parrot_io_printf(interp, FLOATVAL_FMT, $1); +#else + /* Workaround for older msvcrt and openbsd. TT #313 */ + if ($1 == -0.0) { + Parrot_io_printf(interp, "-0"); + } + else { + Parrot_io_printf(interp, FLOATVAL_FMT, $1); + } +#endif } op print(in STR) :base_io { @@ -185,7 +195,17 @@ } inline op say(in NUM) :base_io { +#ifdef PARROT_HAS_NEGATIVE_ZERO Parrot_io_printf(interp, FLOATVAL_FMT "\n", $1); +#else + /* Workaround for older msvcrt and openbsd. TT #313 */ + if ($1 == -0.0) { + Parrot_io_printf(interp, "-0\n"); + } + else { + Parrot_io_printf(interp, FLOATVAL_FMT "\n", $1); + } +#endif } op say(in STR) :base_io {