From: Jerry D. Hedden Date: Tue, 27 Feb 2007 10:33:36 +0000 (-0800) Subject: Re: [PATCH] Re: Math::BigInt and Win32API::File whines a lot during make test... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c14b581ad7a052ea913f8477ee9d8939b2b252e;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] Re: Math::BigInt and Win32API::File whines a lot during make test... From: "Jerry D. Hedden" Message-ID: <738238.57355.qm@web30201.mail.mud.yahoo.com> (Silences warnings about math lib(s), avoids using Math::BigInt when using 64-bit ints and changes "new" to "->new()") p4raw-id: //depot/perl@30425 --- diff --git a/ext/Win32API/File/File.pm b/ext/Win32API/File/File.pm index 9bca304..1742cbe 100644 --- a/ext/Win32API/File/File.pm +++ b/ext/Win32API/File/File.pm @@ -15,19 +15,17 @@ $VERSION= '0.1001_01'; use base qw( Exporter DynaLoader Tie::Handle IO::File ); # Math::BigInt optimizations courtesy of Tels +my $_64BITINT; BEGIN { - require Math::BigInt; - if (defined($Math::BigInt::VERSION) && $Math::BigInt::VERSION >= 1.60) { - Math::BigInt->import(lib => 'GMP'); - } -} + $_64BITINT = defined($Config{use64bitint}) && + ($Config{use64bitint} eq 'define'); -my $_64BITINT = defined $Config{use64bitint} && - $Config{use64bitint} eq 'define'; + require Math::BigInt unless $_64BITINT; +} -my $THIRTY_TWO = $_64BITINT ? 32 : new Math::BigInt 32; +my $THIRTY_TWO = $_64BITINT ? 32 : Math::BigInt->new(32); -my $FFFFFFFF = $_64BITINT ? 0xFFFFFFFF : new Math::BigInt 0xFFFFFFFF; +my $FFFFFFFF = $_64BITINT ? 0xFFFFFFFF : Math::BigInt->new(0xFFFFFFFF); @EXPORT= qw(); %EXPORT_TAGS= ( @@ -237,7 +235,7 @@ sub set { Win32API::File::_fileLastError($_[1]); return $_[0] } package Win32API::File; -my $_error = new Win32API::File::_error; +my $_error = Win32API::File::_error->new(); sub fileLastError { croak 'Usage: ',__PACKAGE__,'::fileLastError( [$setWin32ErrCode] )' if @_ > 1; @@ -367,7 +365,7 @@ sub getFileSize { my $low_size = GetFileSize($handle, $high_size); - my $retval = $_64BITINT ? $high_size : new Math::BigInt $high_size; + my $retval = $_64BITINT ? $high_size : Math::BigInt->new($high_size); $retval <<= $THIRTY_TWO; $retval += $low_size; @@ -395,8 +393,10 @@ sub setFilePointer { my $retval = SetFilePointer($handle, $pos_low, $pos_high, $from_where); if (defined $pos_high && $pos_high != 0) { - $retval = new Math::BigInt $retval unless $_64BITINT; - $pos_high = new Math::BigInt $pos_high unless $_64BITINT; + if (! $_64BITINT) { + $retval = Math::BigInt->new($retval); + $pos_high = Math::BigInt->new($pos_high); + } $retval += $pos_high << $THIRTY_TWO; } @@ -840,7 +840,7 @@ WARNING: this is new code, use at your own risk. This version of C can be used like an C object: - my $file = new Win32API::File "+> foo"; + my $file = Win32API::File->new("+> foo"); binmode $file; print $file "hello there\n"; seek $file, 0, 0;