From: Tels Date: Thu, 15 Mar 2007 18:06:32 +0000 (-0800) Subject: import Devel-Size 0.67 from CPAN X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b1e5ad85e1c05c8f9a3822664645476e0924ec3e;p=p5sagit%2FDevel-Size.git import Devel-Size 0.67 from CPAN git-cpan-module: Devel-Size git-cpan-version: 0.67 git-cpan-authorid: TELS git-cpan-file: authors/id/T/TE/TELS/devel/Devel-Size-0.67.tar.gz --- diff --git a/Build.PL b/Build.PL deleted file mode 100644 index 82352be..0000000 --- a/Build.PL +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/perl -w - -# Dear Distribution Packager. This use of require is intentional. -# Module::Install detects Build.PL usage and acts accordingly. -require 'Makefile.PL'; diff --git a/CHANGES b/CHANGES index 34f600a..fd6eb47 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,16 @@ Revision history for Perl extension Devel::Size. +0.67 2007-03-15 Tels 20 tests + * rip out Build.PL since it doesn't actually work + * fix bug #1653: All SVPV subtype may contain an RV instead of a PV + (Thanx a lot Jan, and sorry for the truly horrible long delay!) + * fix bug #24846: Does not correctly recurse into references in PVNV + (Thanx STEVIEO) + * add t/recurse.t that tests the two bugfixes in combination + +0.66 2007-03-02 Tels 15 tests + * fix the failing test (the code was right, but the test wrong) + 0.65 2007-02-24 Tels 15 tests * fix the test failings under 64 bit (bugs #21037, #18596, #21404) * fix wrong size for strings (bug #17586) diff --git a/MANIFEST b/MANIFEST index 158926e..b14984c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,8 +1,6 @@ -Build.PL CHANGES inc/Module/Install.pm inc/Module/Install/Base.pm -inc/Module/Install/Build.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm @@ -19,3 +17,4 @@ Size.xs t/basic.t t/pod.t t/pod_cov.t +t/recurse.t diff --git a/META.yml b/META.yml index c2aeb5d..bd3f555 100644 --- a/META.yml +++ b/META.yml @@ -1,10 +1,14 @@ +--- abstract: Perl extension for finding the memory usage of Perl variables author: Tels build_requires: Test::More: 0.42 distribution_type: module -generated_by: Module::Install version 0.64 +generated_by: Module::Install version 0.65 license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.3.html + version: 1.3 name: Devel-Size no_index: directory: @@ -15,4 +19,4 @@ recommends: Devel::Size::Report: 0.11 requires: DynaLoader: 0 -version: 0.66 +version: 0.67 diff --git a/SIGNATURE b/SIGNATURE index 198d061..f414cf1 100644 --- a/SIGNATURE +++ b/SIGNATURE @@ -14,34 +14,33 @@ not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 38dd40d4fe9a8a408648f2f2c1a2a3ac76bbac72 Build.PL -SHA1 4a8ab802f0246e9161adf3226bcea18eb3e2e1f1 CHANGES -SHA1 34c2335f7a87ba91a983fe877e916ea4481dd10e MANIFEST +SHA1 8209b79fe86e5a4a8698b8a3f13c6f05467bfbc8 CHANGES +SHA1 b41fb799702683e35ca968f55018175c8c6298e9 MANIFEST SHA1 134aae6f44102ce9b0f7fa7a3710e41a0cd23646 MANIFEST.SKIP -SHA1 f3d8cf6515bd782e6ea7717f5ad1dd15d9117ecd META.yml +SHA1 08fcfb52a30000bd80a37f0ee91d917706690884 META.yml SHA1 6ed187e4890948dacf792b44ab18fa143a580ace Makefile.PL -SHA1 498997a1a0785e1088db3fc85a47583cd1ad02cf Size.xs -SHA1 9b2f9d83bcf77860f53a0c07c90a4a59ad9f5df1 inc/Module/Install.pm -SHA1 abe32855d75ab13747cf65765af9947b7a8c3057 inc/Module/Install/Base.pm -SHA1 da9dfbb8ae4a8a8bac0ab9cd7ef7dc89e4cb5dbe inc/Module/Install/Build.pm -SHA1 95b81d1e91bd634467bf633571eff4420e9c04eb inc/Module/Install/Can.pm -SHA1 1fe98c63cf9d7271c8cb4183ba230f152df69e26 inc/Module/Install/Fetch.pm -SHA1 2249171a2b72cd73ff2c0a06597d29f86e5df456 inc/Module/Install/Makefile.pm -SHA1 381bb98ea3877bba49ae85e7a7ea130645fd3dbf inc/Module/Install/Metadata.pm -SHA1 0c2118868ef82ac517eb6d9c3bd93e6eb9bbf83e inc/Module/Install/Win32.pm -SHA1 e827d6d43771032fa3df35c0ad5e5698d0e54cda inc/Module/Install/WriteAll.pm -SHA1 0eb820ab28ffddd7b040083154129d99885e6093 lib/Devel/Size.pm -SHA1 78ea8a9d47029fbe04d3cf6c0bbcc80c493d8d35 t/basic.t +SHA1 3ddc18f9e90d5837031fcad6c6b62076512cc75a Size.xs +SHA1 ceac99579ef3914de1936417282842c07d907a6a inc/Module/Install.pm +SHA1 6c9471c92c28e247fb84f4ab7dc277f68b33ea95 inc/Module/Install/Base.pm +SHA1 b2cb1026330e8c4f8533c79569498ab15f189d86 inc/Module/Install/Can.pm +SHA1 78acbad45c4289c228ead2278fc213ddd66bcead inc/Module/Install/Fetch.pm +SHA1 642e5b27f4cbbbe440e5dc05c639f5fb79875fe3 inc/Module/Install/Makefile.pm +SHA1 80d024f3eccf1c825b02b5e59de236b0af7d4bfc inc/Module/Install/Metadata.pm +SHA1 fe6780ea5cfd67c79140699fbd4f0fe262255d57 inc/Module/Install/Win32.pm +SHA1 51d43bffcfd7ffdecb8c8e9f97f3896c31b2e1b2 inc/Module/Install/WriteAll.pm +SHA1 11650747f74e8a932e7c35a626cf36754104264e lib/Devel/Size.pm +SHA1 3b24073cb8b1a95aa924327aaa4463c24cbf3c47 t/basic.t SHA1 dc638392e64661dd07deeba11f67e35650a6384a t/pod.t SHA1 cab9b9f7a912f8a18e5301841da22dead08d00f3 t/pod_cov.t +SHA1 5bb930d42d5b99e7ca23283ad848dcdc6b9565bc t/recurse.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) -iQEVAwUBRehf63cLPEOTuEwVAQKH1Qf/TlFBa1qOaOais2sHR26hKeipcjoI3pE3 -8ndnBEG28naSwZbrIWLhmACoq+rVVWEQo+kxhTWuD2xOG4vSC818e8FeHilx9FIb -IO7yriUREphtgh/mTzBYthGJqvSBa5e2EDgaXmU98VI9IFTEyubHkJPipCKhPH+a -hvCKHobigcMP9NtU7E8UGuzHqKvYgEiTyZUJYx2Hv2g/DjwiDo8JnFHsy7U8rXBf -j5qKl7YnhGZpBx//emR1sVFlSAh+5lI8pzJzU1DqnZ2+JTfvXlVCdCtkEzhVWW93 -CaPNhYfmfovANcL3pWiBAS31lEKHZ+RPK5aakQ/H08QmYPmVm1BQ+Q== -=GuOo +iQEVAwUBRfmXY3cLPEOTuEwVAQJ9xAf6A1uUjeE5EPb3/7+DRpMfh5drJTwm8sFd +iJr7wPHejdY5UoF6lckTCa4gA4OPuiGfTdNf1Mmy2HEFzDbxMaK1m5nCiYb9fAWG +E7p5bFZizawI7QNHRULpWXOWAL+HH4yUL/F2LqENOVmy/PCwfjpm4VlTysvj+a1L +AlABEuHk3T2sRkUwCrx9/ADJ0o/ZiFki7Gxky0aLI1zffMKl5+k6psZ+zuIiuzre +gB4r6obpKIggrkVbLcftmdZQVUD/2YjH+38hziL2uAxY/iDQ6HsBRD4Ef480c5xW +Bp6Nko65UME/OiSOEE7hbJFDGf/EKv5OXB/UXEsdBJdO9Xyk6OivxQ== +=eNsE -----END PGP SIGNATURE----- diff --git a/Size.xs b/Size.xs index be6cf53..4fd7559 100644 --- a/Size.xs +++ b/Size.xs @@ -360,7 +360,7 @@ UV op_size(OP *baseop, HV *tracking_hash) { UV thing_size(SV *orig_thing, HV *tracking_hash) { SV *thing = orig_thing; UV total_size = sizeof(SV); - + switch (SvTYPE(thing)) { /* Is it undef? */ case SVt_NULL: @@ -394,12 +394,12 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { much has been allocated */ case SVt_PV: total_size += sizeof(XPV); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); break; /* A string with an integer part? */ case SVt_PVIV: total_size += sizeof(XPVIV); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); if(SvOOK(thing)) { total_size += SvIVX(thing); } @@ -407,23 +407,23 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { /* A string with a float part? */ case SVt_PVNV: total_size += sizeof(XPVNV); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); break; case SVt_PVMG: total_size += sizeof(XPVMG); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); total_size += magic_size(thing, tracking_hash); break; #if PERL_VERSION <= 8 case SVt_PVBM: total_size += sizeof(XPVBM); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); total_size += magic_size(thing, tracking_hash); break; #endif case SVt_PVLV: total_size += sizeof(XPVLV); - total_size += SvLEN(thing); + total_size += SvROK(thing) ? thing_size( SvRV(thing), tracking_hash) : SvLEN(thing); total_size += magic_size(thing, tracking_hash); break; /* How much space is dedicated to the array? Not counting the @@ -441,7 +441,7 @@ UV thing_size(SV *orig_thing, HV *tracking_hash) { total_size, sizeof(SV*), AvARRAY(thing), AvALLOC(thing), sizeof( thing )); */ /* under Perl 5.8.8 64bit threading, AvARRAY(thing) was a pointer while AvALLOC was 0, - resulting in grossly overstated sized for arrays */ + resulting in grossly overstated sized for arrays. Technically, this shouldn't happen... */ if (AvALLOC(thing) != 0) { total_size += (sizeof(SV *) * (AvARRAY(thing) - AvALLOC(thing))); } @@ -692,6 +692,14 @@ CODE: av_push(pending_array, SvRV(thing)); break; + /* fix for bug #24846 (Does not correctly recurse into references in a PVNV-type scalar) */ + case SVt_PVNV: + if (SvROK(thing)) + { + av_push(pending_array, SvRV(thing)); + } + break; + case SVt_PVAV: { /* Quick alias to cut down on casting */ diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm index 0330b0e..af6a59c 100644 --- a/inc/Module/Install.pm +++ b/inc/Module/Install.pm @@ -28,7 +28,7 @@ BEGIN { # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. - $VERSION = '0.64'; + $VERSION = '0.65'; } # Whether or not inc::Module::Install is actually loaded, the diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm index 30a24ca..b46a8ca 100644 --- a/inc/Module/Install/Base.pm +++ b/inc/Module/Install/Base.pm @@ -1,7 +1,7 @@ #line 1 package Module::Install::Base; -$VERSION = '0.64'; +$VERSION = '0.65'; # Suspend handler for "redefined" warnings BEGIN { diff --git a/inc/Module/Install/Build.pm b/inc/Module/Install/Build.pm deleted file mode 100644 index 2230386..0000000 --- a/inc/Module/Install/Build.pm +++ /dev/null @@ -1,69 +0,0 @@ -#line 1 -package Module::Install::Build; - -use strict; -use Module::Install::Base; - -use vars qw{$VERSION $ISCORE @ISA}; -BEGIN { - $VERSION = '0.64'; - $ISCORE = 1; - @ISA = qw{Module::Install::Base}; -} - -sub Build { $_[0] } - -sub write { - my $self = shift; - die "Build->write() takes no arguments\n" if @_; - - my %args; - my $build; - - $args{dist_name} = $self->name || $self->determine_NAME($self->{args}); - $args{license} = $self->license; - $args{test_files} = $self->tests; - $args{dist_version} = $self->version || $self->determine_VERSION($self->{args}); - $args{dist_abstract} = $self->abstract; - $args{dist_author} = $self->author; - $args{sign} = $self->sign; - $args{no_index} = $self->no_index; - - foreach my $key (qw(build_requires requires recommends conflicts)) { - my $val = eval "\$self->$key" or next; - $args{$key} = { map @$_, @$val }; - } - - %args = map {($_, $args{$_})} grep {defined($args{$_})} keys %args; - - require Module::Build; - $build = Module::Build->new(%args); - $build->add_to_cleanup(split /\s+/, $self->clean_files); - $build->create_build_script; -} - -sub ACTION_reset { - my ($self) = @_; - die "XXX - Can't get this working yet"; - require File::Path; - warn "Removing inc\n"; - rmpath('inc'); -} - -sub ACTION_dist { - my ($self) = @_; - die "XXX - Can't get this working yet"; -} - -# DrMath: is there an OO way to add actions to Module::Build?? -# ingy: yeah -# ingy: package MyBuilder; use w(Module::Build; @ISA = qw(w(Module::Build); sub ACTION_ingy -# {...} -# ingy: then my $build = new MyBuilder( ...parameters... ); -# $build->write_build_script; - -1; - -__END__ - -#line 180 diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm index 1c01e22..9bcf278 100644 --- a/inc/Module/Install/Can.pm +++ b/inc/Module/Install/Can.pm @@ -11,7 +11,7 @@ use ExtUtils::MakeMaker (); use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm index 24c0c02..0d2c39c 100644 --- a/inc/Module/Install/Fetch.pm +++ b/inc/Module/Install/Fetch.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm index 96c7e17..eb67033 100644 --- a/inc/Module/Install/Makefile.pm +++ b/inc/Module/Install/Makefile.pm @@ -7,7 +7,7 @@ use ExtUtils::MakeMaker (); use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } @@ -136,9 +136,13 @@ sub write { . "but we need version >= $perl_version"; } + $args->{INSTALLDIRS} = $self->installdirs; + my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args; - if ($self->admin->preop) { - $args{dist} = $self->admin->preop; + + my $user_preop = delete $args{dist}->{PREOP}; + if (my $preop = $self->admin->preop($user_preop)) { + $args{dist} = $preop; } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); @@ -205,4 +209,4 @@ sub postamble { __END__ -#line 334 +#line 338 diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm index 6c80832..b5658c9 100644 --- a/inc/Module/Install/Metadata.pm +++ b/inc/Module/Install/Metadata.pm @@ -6,14 +6,14 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } my @scalar_keys = qw{ name module_name abstract author version license - distribution_type perl_version tests + distribution_type perl_version tests installdirs }; my @tuple_keys = qw{ @@ -56,6 +56,11 @@ foreach my $key (@tuple_keys) { }; } +sub install_as_core { $_[0]->installdirs('perl') } +sub install_as_cpan { $_[0]->installdirs('site') } +sub install_as_site { $_[0]->installdirs('site') } +sub install_as_vendor { $_[0]->installdirs('vendor') } + sub sign { my $self = shift; return $self->{'values'}{'sign'} if defined wantarray and !@_; @@ -279,9 +284,11 @@ sub license_from { if ( $self->_slurp($file) =~ m/ - =head \d \s+ - (?:licen[cs]e|licensing|copyright|legal)\b - (.*?) + ( + =head \d \s+ + (?:licen[cs]e|licensing|copyright|legal)\b + .*? + ) (=head\\d.*|=cut.*|) \z /ixms @@ -298,6 +305,7 @@ sub license_from { 'LGPL' => 'lgpl', 'BSD' => 'bsd', 'Artistic' => 'artistic', + 'MIT' => 'MIT', ); while ( my ( $pattern, $license ) = splice( @phrases, 0, 2 ) ) { $pattern =~ s{\s+}{\\s+}g; diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm index 2ec7d66..42cb653 100644 --- a/inc/Module/Install/Win32.pm +++ b/inc/Module/Install/Win32.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm index 3546e61..d0908fb 100644 --- a/inc/Module/Install/WriteAll.pm +++ b/inc/Module/Install/WriteAll.pm @@ -6,7 +6,7 @@ use Module::Install::Base; use vars qw{$VERSION $ISCORE @ISA}; BEGIN { - $VERSION = '0.64'; + $VERSION = '0.65'; $ISCORE = 1; @ISA = qw{Module::Install::Base}; } diff --git a/lib/Devel/Size.pm b/lib/Devel/Size.pm index 6dfdf55..43b4098 100644 --- a/lib/Devel/Size.pm +++ b/lib/Devel/Size.pm @@ -16,7 +16,7 @@ require DynaLoader; @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); @EXPORT = qw( ); -$VERSION = '0.66'; +$VERSION = '0.67'; bootstrap Devel::Size $VERSION; @@ -241,8 +241,7 @@ Maintained now by Tels =head1 COPYRIGHT -Copyright (C) 2005 Dan Sugalski. -Copyright (C) 2007 Tels +Copyright (C) 2005 Dan Sugalski, Copyright (C) 2007 Tels This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/basic.t b/t/basic.t index 2b4c80f..42c3e22 100644 --- a/t/basic.t +++ b/t/basic.t @@ -23,7 +23,7 @@ can_ok ('Devel::Size', qw/ Devel::Size->import( qw(size total_size) ); die ("Uhoh, test uses outdated version of Devel::Size") - unless is ($Devel::Size::VERSION, '0.66', 'VERSION MATCHES'); + unless is ($Devel::Size::VERSION, '0.67', 'VERSION MATCHES'); ############################################################################# # some basic checks: diff --git a/t/recurse.t b/t/recurse.t new file mode 100644 index 0000000..af2eb39 --- /dev/null +++ b/t/recurse.t @@ -0,0 +1,62 @@ +#!/usr/bin/perl -w + +use Test::More; +use strict; + +my $tests; + +BEGIN + { + chdir 't' if -d 't'; + plan tests => 5; + + use lib '../lib'; + use lib '../blib/arch'; + use_ok('Devel::Size'); + } + +can_ok ('Devel::Size', qw/ + size + total_size + /); + +Devel::Size->import( qw(size total_size) ); + +die ("Uhoh, test uses outdated version of Devel::Size") + unless is ($Devel::Size::VERSION, '0.67', 'VERSION MATCHES'); + +############################################################################# +# #24846 (Does not correctly recurse into references in a PVNV-type scalar) + +my $size = 100; +my $hash = {}; + +my $empty_hash = total_size($hash); + +$hash->{a} = 0/1; +$hash->{a} = []; + +my $hash_size = total_size($hash); +my $element_size = total_size($hash->{a}); + +ok ($element_size < $hash_size, "element < hash with one element"); + +my $array_size = total_size([0..$size]) - total_size( [] ); + +$hash->{a} = [0..$size]; +my $full_hash = total_size($hash); + +#print "$full_hash\n"; +#print "$array_size\n"; +#print "$hash_size\n"; +#print "$element_size\n"; + +# the total size is: + +# the contents of the array (array size) +# the hash +# the PVNV in the hash +# the RV inside the PVNV + +is ($full_hash, $array_size + $hash_size, 'properly recurses into PVNV'); +