├── weaver.ini ├── .gitignore ├── TODO ├── t ├── 05-exception_xs.t ├── 12-direct_pp.t ├── 01-eval.t ├── 11-direct_xs.t ├── 06-exception_pp.t ├── 00-basic.t ├── 02-localise.t └── 10-test_without_vm_pure_pp.t ├── lib └── B │ └── Hooks │ ├── EndOfScope │ ├── PP │ │ ├── HintHash.pm │ │ └── FieldHash.pm │ ├── XS.pm │ └── PP.pm │ └── EndOfScope.pm ├── inc └── MakeMakerSubs.pm ├── dist.ini ├── README.pod ├── Changes ├── CONTRIBUTING └── LICENSE /weaver.ini: -------------------------------------------------------------------------------- 1 | [@Default] 2 | 3 | [Contributors] 4 | 5 | [-Transformer] 6 | transformer = List 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.ackrc 2 | /.build/ 3 | !/.gitignore 4 | /.latest 5 | /B-Hooks-EndOfScope-*/ 6 | /B-Hooks-EndOfScope-*.tar.gz 7 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - release the liquid horror swap 2 | 3 | - update Makefile.PL even more by using [DynamicPrereqs] -include_sub, -condition options 4 | 5 | - merge https://github.com/bobtfish/b-hooks-endofscope/pull/2 6 | 7 | - time to re-add [Test::Version] with a bumped :version? 8 | 9 | -------------------------------------------------------------------------------- /t/05-exception_xs.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use B::Hooks::EndOfScope; 6 | 7 | plan skip_all => 'Skiping XS test in PP mode' 8 | unless $INC{'B/Hooks/EndOfScope/XS.pm'}; 9 | 10 | eval q[ 11 | sub foo { 12 | BEGIN { 13 | on_scope_end { die 'bar' }; 14 | } 15 | } 16 | ]; 17 | 18 | like($@, qr/^bar/); 19 | 20 | pass('no segfault'); 21 | 22 | done_testing; 23 | -------------------------------------------------------------------------------- /t/12-direct_pp.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use B::Hooks::EndOfScope::PP; 6 | 7 | BEGIN { 8 | ok(exists &on_scope_end, 'on_scope_end imported'); 9 | is(prototype('on_scope_end'), '&', '.. and has the right prototype'); 10 | } 11 | 12 | our $i; 13 | 14 | sub foo { 15 | BEGIN { 16 | on_scope_end { $i = 42 }; 17 | }; 18 | 19 | is($i, 42, 'value still set at runtime'); 20 | } 21 | 22 | BEGIN { 23 | is($i, 42, 'value set at compiletime') 24 | } 25 | 26 | foo(); 27 | 28 | done_testing; 29 | -------------------------------------------------------------------------------- /t/01-eval.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use B::Hooks::EndOfScope; 6 | 7 | # FIXME!!!!! this is dreadful. This test is written so loosely that we still 8 | # pass all tests if we comment out the above use_ok line and replace it with: 9 | # sub on_scope_end(&) { shift->() } 10 | 11 | our $called; 12 | 13 | sub foo { 14 | BEGIN { on_scope_end { $called = 1 } } 15 | 16 | # uncomment this to make the test pass 17 | eval '42'; 18 | } 19 | 20 | BEGIN { 21 | ok($called, 'callback invoked'); 22 | } 23 | 24 | done_testing; 25 | -------------------------------------------------------------------------------- /t/11-direct_xs.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | BEGIN { 6 | eval { require B::Hooks::EndOfScope::XS } 7 | or plan skip_all => "XS functionality not available"; 8 | 9 | B::Hooks::EndOfScope::XS->import(); 10 | } 11 | 12 | BEGIN { 13 | ok(exists &on_scope_end, 'on_scope_end imported'); 14 | is(prototype('on_scope_end'), '&', '.. and has the right prototype'); 15 | } 16 | 17 | our $i; 18 | 19 | sub foo { 20 | BEGIN { 21 | on_scope_end { $i = 42 }; 22 | }; 23 | 24 | is($i, 42, 'value still set at runtime'); 25 | } 26 | 27 | BEGIN { 28 | is($i, 42, 'value set at compiletime') 29 | } 30 | 31 | foo(); 32 | 33 | done_testing; 34 | -------------------------------------------------------------------------------- /t/06-exception_pp.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use B::Hooks::EndOfScope; 6 | 7 | plan skip_all => 'Skipping PP fallback test in XS mode' 8 | unless $INC{'B/Hooks/EndOfScope/PP.pm'}; 9 | 10 | my $w; 11 | local $SIG{__WARN__} = sub { 12 | $w = $_[0] if $_[0] =~ qr/\QException "bar"/ 13 | }; 14 | 15 | eval q[ 16 | sub foo { 17 | BEGIN { 18 | on_scope_end { die 'Exception "bar"' }; 19 | } 20 | } 21 | ]; 22 | 23 | like ( 24 | $w, 25 | qr/scope-end callback raised an exception, which can not be propagated when .+? operates in pure-perl mode/, 26 | 'Warning on lost callback exception correctly emited' 27 | ); 28 | 29 | done_testing; 30 | -------------------------------------------------------------------------------- /t/00-basic.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | BEGIN { use_ok('B::Hooks::EndOfScope') } 6 | 7 | # FIXME!!!!! this is dreadful. This test is written so loosely that we still 8 | # pass all tests if we comment out the above use_ok line and replace it with: 9 | # sub on_scope_end(&) { shift->() } 10 | 11 | 12 | BEGIN { 13 | ok(exists &on_scope_end, 'on_scope_end imported'); 14 | is(prototype('on_scope_end'), '&', '.. and has the right prototype'); 15 | } 16 | 17 | our ($i, $called); 18 | 19 | BEGIN { $i = 0 } 20 | 21 | sub foo { 22 | BEGIN { 23 | on_scope_end { $called = 1; $i = 42 }; 24 | on_scope_end { $i = 1 }; 25 | }; 26 | 27 | is($i, 1, 'value still set at runtime'); 28 | } 29 | 30 | BEGIN { 31 | ok($called, 'first callback invoked'); 32 | is($i, 1, '.. but the second is invoked later') 33 | } 34 | 35 | foo(); 36 | 37 | done_testing; 38 | -------------------------------------------------------------------------------- /t/02-localise.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More 0.89; 5 | 6 | use B::Hooks::EndOfScope; 7 | 8 | { 9 | my $fired; 10 | 11 | { 12 | BEGIN { on_scope_end { $fired++ } } 13 | 14 | BEGIN { ok(!$fired) } 15 | 16 | BEGIN { local %^H } 17 | 18 | BEGIN { ok(!$fired) } 19 | } 20 | 21 | BEGIN { ok($fired) } 22 | } 23 | 24 | { 25 | my $fired; 26 | 27 | { 28 | BEGIN { on_scope_end { $fired++ } } 29 | BEGIN { ok(!$fired) } 30 | 31 | BEGIN { 32 | local %^H; 33 | 34 | my $fired2; 35 | { 36 | BEGIN { on_scope_end { $fired2++ } } 37 | BEGIN { ok(!$fired2) } 38 | BEGIN { local %^H } 39 | BEGIN { ok(!$fired2) } 40 | } 41 | BEGIN { ok($fired2) } 42 | } 43 | 44 | BEGIN { ok(!$fired) } 45 | } 46 | 47 | BEGIN { ok($fired) } 48 | } 49 | 50 | done_testing; 51 | -------------------------------------------------------------------------------- /lib/B/Hooks/EndOfScope/PP/HintHash.pm: -------------------------------------------------------------------------------- 1 | # Implementation of a pure-perl on_scope_end for perl 5.8.X 2 | # (relies on lack of compile/runtime duality of %^H before 5.10 3 | # which makes guard object operation possible) 4 | 5 | package # hide from the pauses 6 | B::Hooks::EndOfScope::PP::HintHash; 7 | 8 | use strict; 9 | use warnings; 10 | 11 | our $VERSION = '0.15'; 12 | 13 | use Scalar::Util (); 14 | 15 | # This is the original implementation, which sadly is broken 16 | # on perl 5.10+ within string evals 17 | sub on_scope_end (&) { 18 | $^H |= 0x020000; 19 | 20 | # localised %^H behaves funny on 5.8 - a 21 | # 'local %^H;' 22 | # is in effect the same as 23 | # 'local %^H = %^H;' 24 | # therefore make sure we use different keys so that things do not 25 | # fire too early due to hashkey overwrite 26 | push @{ 27 | $^H{sprintf '__B_H_EOS__guardstack_0X%x', Scalar::Util::refaddr(\%^H) } 28 | ||= bless ([], 'B::Hooks::EndOfScope::PP::_SG_STACK') 29 | }, shift; 30 | } 31 | 32 | package # hide from the pauses 33 | B::Hooks::EndOfScope::PP::_SG_STACK; 34 | 35 | use warnings; 36 | use strict; 37 | 38 | sub DESTROY { 39 | B::Hooks::EndOfScope::PP::__invoke_callback($_) for @{$_[0]}; 40 | } 41 | 42 | 1; 43 | -------------------------------------------------------------------------------- /lib/B/Hooks/EndOfScope/PP/FieldHash.pm: -------------------------------------------------------------------------------- 1 | # Implementation of a pure-perl on_scope_end for perls > 5.10 2 | # (relies on Hash::Util:FieldHash) 3 | 4 | package # hide from pause 5 | B::Hooks::EndOfScope::PP::FieldHash; 6 | 7 | use strict; 8 | use warnings; 9 | 10 | our $VERSION = '0.15'; 11 | 12 | use Tie::Hash (); 13 | use Hash::Util::FieldHash 'fieldhash'; 14 | 15 | # Here we rely on a combination of several behaviors: 16 | # 17 | # * %^H is deallocated on scope exit, so any references to it disappear 18 | # * A lost weakref in a fieldhash causes the corresponding key to be deleted 19 | # * Deletion of a key on a tied hash triggers DELETE 20 | # 21 | # Therefore the DELETE of a tied fieldhash containing a %^H reference will 22 | # be the hook to fire all our callbacks. 23 | 24 | fieldhash my %hh; 25 | { 26 | package # hide from pause too 27 | B::Hooks::EndOfScope::PP::_TieHintHashFieldHash; 28 | use base 'Tie::StdHash'; 29 | sub DELETE { 30 | my $ret = shift->SUPER::DELETE(@_); 31 | B::Hooks::EndOfScope::PP::__invoke_callback($_) for @$ret; 32 | $ret; 33 | } 34 | } 35 | 36 | sub on_scope_end (&) { 37 | $^H |= 0x020000; 38 | 39 | tie(%hh, 'B::Hooks::EndOfScope::PP::_TieHintHashFieldHash') 40 | unless tied %hh; 41 | 42 | push @{ $hh{\%^H} ||= [] }, shift; 43 | } 44 | 45 | 1; 46 | -------------------------------------------------------------------------------- /inc/MakeMakerSubs.pm: -------------------------------------------------------------------------------- 1 | # Secondary compile testing via ExtUtils::CBuilder 2 | sub can_xs { 3 | # Do we have the configure_requires checker? 4 | unless (eval 'require ExtUtils::CBuilder; 1') { 5 | # They don't obey configure_requires, so it is 6 | # someone old and delicate. Try to avoid hurting 7 | # them by falling back to an older simpler test. 8 | return can_cc(); 9 | } 10 | 11 | return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler; 12 | } 13 | 14 | # can we locate a (the) C compiler 15 | sub can_cc { 16 | my @chunks = split(/ /, $Config::Config{cc}) or return; 17 | 18 | # $Config{cc} may contain args; try to find out the program part 19 | while (@chunks) { 20 | return can_run("@chunks") || (pop(@chunks), next); 21 | } 22 | 23 | return; 24 | } 25 | 26 | # check if we can run some command 27 | sub can_run { 28 | my ($cmd) = @_; 29 | 30 | return $cmd if -x $cmd; 31 | if (my $found_cmd = MM->maybe_command($cmd)) { 32 | return $found_cmd; 33 | } 34 | 35 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { 36 | next if $dir eq ''; 37 | my $abs = File::Spec->catfile($dir, $cmd); 38 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); 39 | } 40 | 41 | return; 42 | } 43 | 44 | # is this a smoker? 45 | sub is_smoker { 46 | return ( $ENV{AUTOMATED_TESTING} ) 47 | } 48 | 49 | 1; 50 | -------------------------------------------------------------------------------- /lib/B/Hooks/EndOfScope/XS.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope::XS; 2 | # ABSTRACT: Execute code after a scope finished compilation - XS implementation 3 | 4 | use strict; 5 | use warnings; 6 | 7 | our $VERSION = '0.15'; 8 | 9 | use Variable::Magic 0.48 (); 10 | use Sub::Exporter::Progressive 0.001006 -setup => { 11 | exports => ['on_scope_end'], 12 | groups => { default => ['on_scope_end'] }, 13 | }; 14 | 15 | my $wiz = Variable::Magic::wizard 16 | data => sub { [$_[1]] }, 17 | free => sub { $_->() for @{ $_[1] }; () }, 18 | # When someone localise %^H, our magic doesn't want to be copied 19 | # down. We want it to be around only for the scope we've initially 20 | # attached ourselfs to. Merely having MGf_LOCAL and a noop svt_local 21 | # callback achieves this. If anything wants to attach more magic of our 22 | # kind to a localised %^H, things will continue to just work as we'll be 23 | # attached with a new and empty callback list. 24 | local => \undef 25 | ; 26 | 27 | sub on_scope_end (&) { 28 | my $cb = shift; 29 | 30 | $^H |= 0x020000; 31 | 32 | if (my $stack = Variable::Magic::getdata %^H, $wiz) { 33 | push @{ $stack }, $cb; 34 | } 35 | else { 36 | Variable::Magic::cast %^H, $wiz, $cb; 37 | } 38 | } 39 | 40 | 41 | =head1 DESCRIPTION 42 | 43 | This is the implementation of L based on 44 | L, which is an XS module dependent on a compiler. It will 45 | always be automatically preferred if L is available. 46 | 47 | =func on_scope_end 48 | 49 | on_scope_end { ... }; 50 | 51 | on_scope_end $code; 52 | 53 | Registers C<$code> to be executed after the surrounding scope has been 54 | compiled. 55 | 56 | This is exported by default. See L on how to customize it. 57 | 58 | =cut 59 | 60 | 1; 61 | -------------------------------------------------------------------------------- /t/10-test_without_vm_pure_pp.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | 5 | use B::Hooks::EndOfScope; 6 | 7 | plan skip_all => "Tests already executed in pure-perl mode" 8 | if $INC{'B/Hooks/EndOfScope/PP.pm'}; 9 | 10 | use Config; 11 | use IPC::Open2 qw(open2); 12 | use File::Glob 'bsd_glob'; 13 | 14 | # in case the user had it set 15 | $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = ''; 16 | 17 | # for the $^X-es 18 | $ENV{PERL5LIB} = join ($Config{path_sep}, @INC); 19 | 20 | my $has_dh = eval { require Devel::Hide; Devel::Hide->VERSION('0.0007') }; 21 | die 'author tests require Devel::Hide for testing the PP path!' if not $has_dh 22 | and ($ENV{AUTHOR_TESTING} or $ENV{RELEASE_TESTING}); 23 | fail 'smokers require Devel::Hide for testing the PP path!' if not $has_dh 24 | and $ENV{AUTOMATED_TESTING}; 25 | 26 | $ENV{DEVEL_HIDE_VERBOSE} = 0 if $has_dh; 27 | $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP' unless $has_dh; 28 | 29 | # rerun the tests under the assumption of no vm at all 30 | my @files = bsd_glob("t/0*.t"); 31 | push @files, 'xt/author/00-compile.t' if $ENV{AUTHOR_TESTING}; 32 | for my $fn (@files) { 33 | 34 | next if $fn eq 't/00-report-prereqs.t'; 35 | 36 | note "retesting $fn"; 37 | my @cmd = ( 38 | $^X, 39 | $has_dh ? '-MDevel::Hide=Variable::Magic' : (), 40 | $fn 41 | ); 42 | 43 | # this is cheating, and may even hang here and there (testing on windows passed fine) 44 | # if it does - will have to fix it somehow (really *REALLY* don't want to pull 45 | # in IPC::Cmd just for a fucking test) 46 | # the alternative would be to have an ENV check in each test to force a subtest 47 | open2(my $out, my $in, @cmd); 48 | while (my $ln = <$out>) { 49 | print " $ln"; 50 | } 51 | 52 | wait; 53 | ok (! $?, "Wstat $? from: @cmd"); 54 | } 55 | 56 | done_testing; 57 | -------------------------------------------------------------------------------- /lib/B/Hooks/EndOfScope.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope; 2 | # ABSTRACT: Execute code after a scope finished compilation 3 | # KEYWORDS: code hooks execution scope 4 | 5 | use strict; 6 | use warnings; 7 | 8 | our $VERSION = '0.15'; 9 | 10 | # note - a %^H tie() fallback will probably work on 5.6 as well, 11 | # if you need to go that low - sane patches passing *all* tests 12 | # will be gladly accepted 13 | use 5.008001; 14 | 15 | BEGIN { 16 | use Module::Implementation 0.05; 17 | Module::Implementation::build_loader_sub( 18 | implementations => [ 'XS', 'PP' ], 19 | symbols => [ 'on_scope_end' ], 20 | )->(); 21 | } 22 | 23 | use Sub::Exporter::Progressive -setup => { 24 | exports => [ 'on_scope_end' ], 25 | groups => { default => ['on_scope_end'] }, 26 | }; 27 | 28 | =head1 SYNOPSIS 29 | 30 | on_scope_end { ... }; 31 | 32 | =head1 DESCRIPTION 33 | 34 | This module allows you to execute code when perl finished compiling the 35 | surrounding scope. 36 | 37 | =func on_scope_end 38 | 39 | on_scope_end { ... }; 40 | 41 | on_scope_end $code; 42 | 43 | Registers C<$code> to be executed after the surrounding scope has been 44 | compiled. 45 | 46 | This is exported by default. See L on how to customize it. 47 | 48 | =head1 PURE-PERL MODE CAVEAT 49 | 50 | While L has access to some very dark sorcery to make it 51 | possible to throw an exception from within a callback, the pure-perl 52 | implementation does not have access to these hacks. Therefore, what 53 | would have been a compile-time exception is instead converted to a 54 | warning, and your execution will continue as if the exception never 55 | happened. 56 | 57 | To explicitly request an XS (or PP) implementation one has two choices. Either 58 | to import from the desired implementation explicitly: 59 | 60 | use B::Hooks::EndOfScope::XS 61 | or 62 | use B::Hooks::EndOfScope::PP 63 | 64 | or by setting C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> to either C or 65 | C. 66 | 67 | =head1 SEE ALSO 68 | 69 | L 70 | 71 | L 72 | 73 | =cut 74 | 75 | 1; 76 | -------------------------------------------------------------------------------- /lib/B/Hooks/EndOfScope/PP.pm: -------------------------------------------------------------------------------- 1 | package B::Hooks::EndOfScope::PP; 2 | # ABSTRACT: Execute code after a scope finished compilation - PP implementation 3 | 4 | use warnings; 5 | use strict; 6 | 7 | our $VERSION = '0.15'; 8 | 9 | use Module::Runtime 0.012 'require_module'; 10 | use constant _PERL_VERSION => "$]"; 11 | 12 | BEGIN { 13 | if (_PERL_VERSION =~ /^5\.009/) { 14 | # CBA to figure out where %^H got broken and which H::U::HH is sane enough 15 | die "By design B::Hooks::EndOfScope does not operate in pure-perl mode on perl 5.9.X\n" 16 | } 17 | elsif (_PERL_VERSION < '5.010') { 18 | require_module('B::Hooks::EndOfScope::PP::HintHash'); 19 | *on_scope_end = \&B::Hooks::EndOfScope::PP::HintHash::on_scope_end; 20 | } 21 | else { 22 | require_module('B::Hooks::EndOfScope::PP::FieldHash'); 23 | *on_scope_end = \&B::Hooks::EndOfScope::PP::FieldHash::on_scope_end; 24 | } 25 | } 26 | 27 | use Sub::Exporter::Progressive -setup => { 28 | exports => ['on_scope_end'], 29 | groups => { default => ['on_scope_end'] }, 30 | }; 31 | 32 | sub __invoke_callback { 33 | local $@; 34 | eval { $_[0]->(); 1 } or do { 35 | my $err = $@; 36 | require Carp; 37 | Carp::cluck( (join ' ', 38 | 'A scope-end callback raised an exception, which can not be propagated when', 39 | 'B::Hooks::EndOfScope operates in pure-perl mode. Your program will CONTINUE', 40 | 'EXECUTION AS IF NOTHING HAPPENED AFTER THIS WARNING. Below is the complete', 41 | 'exception text, followed by a stack-trace of the callback execution:', 42 | ) . "\n\n$err\n\r" ); 43 | 44 | sleep 1 if -t *STDERR; # maybe a bad idea...? 45 | }; 46 | } 47 | 48 | =head1 DESCRIPTION 49 | 50 | This is the pure-perl implementation of L based only on 51 | modules available as part of the perl core. Its leaner sibling 52 | L will be automatically preferred if all 53 | dependencies are available and C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> is 54 | not set to C<'PP'>. 55 | 56 | =func on_scope_end 57 | 58 | on_scope_end { ... }; 59 | 60 | on_scope_end $code; 61 | 62 | Registers C<$code> to be executed after the surrounding scope has been 63 | compiled. 64 | 65 | This is exported by default. See L on how to customize it. 66 | 67 | =cut 68 | 69 | 1; 70 | -------------------------------------------------------------------------------- /dist.ini: -------------------------------------------------------------------------------- 1 | name = B-Hooks-EndOfScope 2 | author = Florian Ragwitz 3 | author = Peter Rabbitson 4 | license = Perl_5 5 | copyright_year = 2008 6 | copyright_holder = Florian Ragwitz 7 | 8 | [@Author::ETHER] 9 | :version = 0.086 10 | installer = MakeMaker 11 | surgical_podweaver = 1 12 | -remove = PodCoverageTests ; TODO 13 | Authority.authority = cpan:FLORA 14 | Git::Tag.tag_format = %v 15 | Git::NextVersion.version_regexp = ^(.+)$ 16 | Test::Version.has_version = 0 ; for internal modules (FIXME: new option forthcoming) 17 | Test::MinimumVersion.max_target_perl = 5.008001 18 | 19 | [Prereqs::Soften] 20 | module = Variable::Magic 21 | module = Devel::Hide 22 | module = Carp 23 | module = Hash::Util::FieldHash 24 | module = Scalar::Util 25 | module = Tie::Hash 26 | module = Tie::StdHash 27 | module = base 28 | module = constant 29 | 30 | [Prereqs / ConfigureRequires] 31 | ; for proper can_xs 32 | ; ribasushi, I think you want EU::CB 0.26 minimum 33 | ExtUtils::CBuilder = 0.26 34 | 35 | [Prereqs / DevelopRequires] 36 | Devel::Hide = 0.0007 ; releasers *must* test both the XS and PP paths 37 | 38 | [DynamicPrereqs] 39 | :version = 0.007 40 | -delimiter = | 41 | -raw = |require 'inc/MakeMakerSubs.pm'; 42 | -raw = |if (can_xs()) { 43 | -raw = | # when changing, also update in dist.ini, B::Hooks::EndOfScope::XS 44 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Variable::Magic'} = $FallbackPrereqs{'Variable::Magic'} = '0.48'; 45 | -raw = | 46 | -raw = | # make sure we smoke the pure-perl version fallback 47 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Devel::Hide'} = $FallbackPrereqs{'Devel::Hide'} = '0.0007' 48 | -raw = | if is_smoker(); 49 | -raw = |} 50 | -raw = |else { 51 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Hash::Util::FieldHash'} = $FallbackPrereqs{'Hash::Util::FieldHash'} = 0; 52 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Scalar::Util'} = $FallbackPrereqs{'Scalar::Util'} = 0; 53 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Tie::Hash'} = $FallbackPrereqs{'Tie::Hash'} = 0; 54 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'Tie::StdHash'} = $FallbackPrereqs{'Tie::StdHash'} = 0; 55 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'base'} = $FallbackPrereqs{'base'} = 0; 56 | -raw = | $WriteMakefileArgs{PREREQ_PM}{'constant'} = $FallbackPrereqs{'constant'} = 0; 57 | -raw = |} 58 | 59 | ; authordep Pod::Weaver::Section::Contributors 60 | -------------------------------------------------------------------------------- /README.pod: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =encoding UTF-8 4 | 5 | =head1 NAME 6 | 7 | B::Hooks::EndOfScope - Execute code after a scope finished compilation 8 | 9 | =head1 VERSION 10 | 11 | version 0.14 12 | 13 | =head1 SYNOPSIS 14 | 15 | on_scope_end { ... }; 16 | 17 | =head1 DESCRIPTION 18 | 19 | This module allows you to execute code when perl finished compiling the 20 | surrounding scope. 21 | 22 | =head1 FUNCTIONS 23 | 24 | =head2 on_scope_end 25 | 26 | on_scope_end { ... }; 27 | 28 | on_scope_end $code; 29 | 30 | Registers C<$code> to be executed after the surrounding scope has been 31 | compiled. 32 | 33 | This is exported by default. See L on how to customize it. 34 | 35 | =head1 PURE-PERL MODE CAVEAT 36 | 37 | While L has access to some very dark sorcery to make it 38 | possible to throw an exception from within a callback, the pure-perl 39 | implementation does not have access to these hacks. Therefore, what 40 | would have been a compile-time exception is instead converted to a 41 | warning, and your execution will continue as if the exception never 42 | happened. 43 | 44 | To explicitly request an XS (or PP) implementation one has two choices. Either 45 | to import from the desired implementation explicitly: 46 | 47 | use B::Hooks::EndOfScope::XS 48 | or 49 | use B::Hooks::EndOfScope::PP 50 | 51 | or by setting C<$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION}> to either C or 52 | C. 53 | 54 | =head1 SEE ALSO 55 | 56 | L 57 | 58 | L 59 | 60 | =head1 AUTHORS 61 | 62 | =over 4 63 | 64 | =item * 65 | 66 | Florian Ragwitz 67 | 68 | =item * 69 | 70 | Peter Rabbitson 71 | 72 | =back 73 | 74 | =head1 COPYRIGHT AND LICENSE 75 | 76 | This software is copyright (c) 2008 by Florian Ragwitz. 77 | 78 | This is free software; you can redistribute it and/or modify it under 79 | the same terms as the Perl 5 programming language system itself. 80 | 81 | =head1 CONTRIBUTORS 82 | 83 | =for stopwords Karen Etheridge Simon Wilper Tomas Doran 84 | 85 | =over 4 86 | 87 | =item * 88 | 89 | Karen Etheridge 90 | 91 | =item * 92 | 93 | Simon Wilper 94 | 95 | =item * 96 | 97 | Tomas Doran 98 | 99 | =back 100 | 101 | =cut 102 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history for {{$dist->name}} 2 | 3 | {{$NEXT}} 4 | - updated the tooling for generating Makefile.PL 5 | 6 | 0.14 2015-01-31 23:59:03Z 7 | - line numbers in shipped code are now the same as the repository source, 8 | for easier debugging 9 | - more accurate dynamic prereq declarations 10 | 11 | 0.13 2014-01-07 21:17:39Z 12 | - Variable::Magic added as a runtime recommendation for greater visibility 13 | (RT#89245) 14 | - fixed broken logic in compiler detection on older perls 15 | - fixed inaccurate repository metadata 16 | 17 | 0.12 2012-12-04 20:13:00Z 18 | - Complete pure-perl implementation in addition to the one based on 19 | Variable::Magic. You can specify the implementation explicitly by 20 | use-ing B::Hooks::EndOfScope::PP or B::Hooks::EndOfScope::XS, or 21 | by setting $ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} to either 'XS' 22 | or 'PP' 23 | - Switch from using Sub::Exporter to the more conservative 24 | Sub::Exporter::Progressive 25 | 26 | 0.11 2012-02-23 10:19:18Z 27 | - A minor efficiency improvement. 28 | 29 | 0.10 2012-02-16 08:41:54Z 30 | - Stop propagating our magic through localisation. 31 | 32 | 0.09 2010-05-07 20:11:49Z 33 | - Improve distribution metadata. 34 | 35 | 0.08 2009-04-19 17:15:44Z 36 | - Depend on Variable::Magic 0.34 so exceptions during compile time that 37 | trigger a destructor don't cause an exception on 5.10 anymore. 38 | 39 | 0.07 2009-02-20 13:22:16Z 40 | - Depend on Variable::Magic 0.31 so exceptions thrown in on_scope_end 41 | blocks don't lose their error message. 42 | 43 | 0.06 2009-01-18 23:51:45Z 44 | - Depend on Variable::Magic 0.27 to stop exceptions thrown in 45 | on_scope_end blocks from segfaulting. Also add a test for that. 46 | 47 | 0.05 2009-01-04 19:46:07Z 48 | - Use Variable::Magic and cast %^H instead Scope::Guard and relying 49 | on a timely destruction of objects within %^H. This fixes using 50 | on_scope_end in blocks where string evals are compiled as those 51 | increment the refcount of objects in %^H on 5.10. 52 | 53 | 0.04 2008-10-20 10:56:23Z 54 | - Remove an unused bit from the $^H mask. 55 | 56 | 0.03 2008-10-20 04:53:20Z 57 | - Improve testing of multiple hooks. 58 | - More documentation. 59 | - Require perl 5.8.0. 60 | 61 | 0.02 2008-10-19 08:25:15Z 62 | - Specify all dependencies. 63 | 64 | 0.01 2008-10-19 07:29:13Z 65 | - Initial release. 66 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- 1 | 2 | CONTRIBUTING 3 | 4 | Thank you for considering contributing to this distribution. This file 5 | contains instructions that will help you work with the source code. 6 | 7 | PLEASE NOTE that if you have any questions or difficulties, you can reach the 8 | maintainer(s) through the bug queue described later in this document 9 | (preferred), or by emailing the releaser directly. You are not required to 10 | follow any of the steps in this document to submit a patch or bug report; 11 | these are just recommendations, intended to help you (and help us help you 12 | faster). 13 | 14 | The distribution is managed with Dist::Zilla (https://metacpan.org/release/Dist-Zilla). 15 | This means than many of the usual files you might expect are not in the 16 | repository, but are generated at release time (e.g. Makefile.PL). 17 | 18 | However, you can run tests directly using the 'prove' tool: 19 | 20 | $ prove -l 21 | $ prove -lv t/some_test_file.t 22 | $ prove -lvr t/ 23 | 24 | In most cases, 'prove' is entirely sufficent for you to test any 25 | patches you have. 26 | 27 | You may need to satisfy some dependencies. The easiest way to satisfy 28 | dependencies is to install the last release -- this is available at 29 | https://metacpan.org/release/B-Hooks-EndOfScope. 30 | 31 | If you use cpanminus, you can do it without downloading the tarball first: 32 | 33 | $ cpanm --reinstall --installdeps --with-recommends B::Hooks::EndOfScope 34 | 35 | Dist::Zilla is a very powerful authoring tool, but requires a number of 36 | author-specific plugins. If you would like to use it for contributing, 37 | install it from CPAN, then run one of the following commands, depending on 38 | your CPAN client: 39 | 40 | $ cpan `dzil authordeps --missing` 41 | or 42 | $ dzil authordeps --missing | cpanm 43 | 44 | You should then also install any additional requirements not needed by the 45 | dzil build but may be needed by tests or other development: 46 | 47 | $ cpan `dzil listdeps --author --missing` 48 | or 49 | $ dzil listdeps --author --missing | cpanm 50 | 51 | Or, you can use the 'dzil stale' command to install all requirements at once: 52 | 53 | $ cpan Dist::Zilla::App::Command::stale 54 | $ cpan `dzil stale --all` 55 | or 56 | $ cpanm Dist::Zilla::App::Command::stale 57 | $ dzil stale --all | cpanm 58 | 59 | You can also do this via cpanm directly: 60 | 61 | $ cpanm --reinstall --installdeps --with-develop --with-recommends B::Hooks::EndOfScope 62 | 63 | Once installed, here are some dzil commands you might try: 64 | 65 | $ dzil build 66 | $ dzil test 67 | $ dzil test --release 68 | $ dzil xtest 69 | $ dzil listdeps --json 70 | $ dzil build --notgz 71 | 72 | You can learn more about Dist::Zilla at http://dzil.org/. 73 | 74 | The code for this distribution is hosted at GitHub. The repository is: 75 | https://github.com/karenetheridge/B-Hooks-EndOfScope 76 | You can submit code changes by forking the repository, pushing your code 77 | changes to your clone, and then submitting a pull request. Detailed 78 | instructions for doing that is available here: 79 | 80 | https://help.github.com/articles/creating-a-pull-request 81 | 82 | If you have found a bug, but do not have an accompanying patch to fix it, you 83 | can submit an issue report here: 84 | https://rt.cpan.org/Public/Dist/Display.html?Name=B-Hooks-EndOfScope 85 | or via bug-B-Hooks-EndOfScope@rt.cpan.org. 86 | This is a good place to send your questions about the usage of this distribution. 87 | 88 | If you send me a patch or pull request, your name and email address will be 89 | included in the documentation as a contributor (using the attribution on the 90 | commit or patch), unless you specifically request for it not to be. If you 91 | wish to be listed under a different name or address, you should submit a pull 92 | request to the .mailmap file to contain the correct mapping. 93 | 94 | 95 | This file was generated via Dist::Zilla::Plugin::GenerateFile::ShareDir 0.005 from a 96 | template file originating in Dist-Zilla-PluginBundle-Author-ETHER-0.085. 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This software is copyright (c) 2008 by Florian Ragwitz. 2 | 3 | This is free software; you can redistribute it and/or modify it under 4 | the same terms as the Perl 5 programming language system itself. 5 | 6 | Terms of the Perl programming language system itself 7 | 8 | a) the GNU General Public License as published by the Free 9 | Software Foundation; either version 1, or (at your option) any 10 | later version, or 11 | b) the "Artistic License" 12 | 13 | --- The GNU General Public License, Version 1, February 1989 --- 14 | 15 | This software is Copyright (c) 2008 by Florian Ragwitz. 16 | 17 | This is free software, licensed under: 18 | 19 | The GNU General Public License, Version 1, February 1989 20 | 21 | GNU GENERAL PUBLIC LICENSE 22 | Version 1, February 1989 23 | 24 | Copyright (C) 1989 Free Software Foundation, Inc. 25 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | 27 | Everyone is permitted to copy and distribute verbatim copies 28 | of this license document, but changing it is not allowed. 29 | 30 | Preamble 31 | 32 | The license agreements of most software companies try to keep users 33 | at the mercy of those companies. By contrast, our General Public 34 | License is intended to guarantee your freedom to share and change free 35 | software--to make sure the software is free for all its users. The 36 | General Public License applies to the Free Software Foundation's 37 | software and to any other program whose authors commit to using it. 38 | You can use it for your programs, too. 39 | 40 | When we speak of free software, we are referring to freedom, not 41 | price. Specifically, the General Public License is designed to make 42 | sure that you have the freedom to give away or sell copies of free 43 | software, that you receive source code or can get it if you want it, 44 | that you can change the software or use pieces of it in new free 45 | programs; and that you know you can do these things. 46 | 47 | To protect your rights, we need to make restrictions that forbid 48 | anyone to deny you these rights or to ask you to surrender the rights. 49 | These restrictions translate to certain responsibilities for you if you 50 | distribute copies of the software, or if you modify it. 51 | 52 | For example, if you distribute copies of a such a program, whether 53 | gratis or for a fee, you must give the recipients all the rights that 54 | you have. You must make sure that they, too, receive or can get the 55 | source code. And you must tell them their rights. 56 | 57 | We protect your rights with two steps: (1) copyright the software, and 58 | (2) offer you this license which gives you legal permission to copy, 59 | distribute and/or modify the software. 60 | 61 | Also, for each author's protection and ours, we want to make certain 62 | that everyone understands that there is no warranty for this free 63 | software. If the software is modified by someone else and passed on, we 64 | want its recipients to know that what they have is not the original, so 65 | that any problems introduced by others will not reflect on the original 66 | authors' reputations. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | GNU GENERAL PUBLIC LICENSE 72 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 73 | 74 | 0. This License Agreement applies to any program or other work which 75 | contains a notice placed by the copyright holder saying it may be 76 | distributed under the terms of this General Public License. The 77 | "Program", below, refers to any such program or work, and a "work based 78 | on the Program" means either the Program or any work containing the 79 | Program or a portion of it, either verbatim or with modifications. Each 80 | licensee is addressed as "you". 81 | 82 | 1. You may copy and distribute verbatim copies of the Program's source 83 | code as you receive it, in any medium, provided that you conspicuously and 84 | appropriately publish on each copy an appropriate copyright notice and 85 | disclaimer of warranty; keep intact all the notices that refer to this 86 | General Public License and to the absence of any warranty; and give any 87 | other recipients of the Program a copy of this General Public License 88 | along with the Program. You may charge a fee for the physical act of 89 | transferring a copy. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion of 92 | it, and copy and distribute such modifications under the terms of Paragraph 93 | 1 above, provided that you also do the following: 94 | 95 | a) cause the modified files to carry prominent notices stating that 96 | you changed the files and the date of any change; and 97 | 98 | b) cause the whole of any work that you distribute or publish, that 99 | in whole or in part contains the Program or any part thereof, either 100 | with or without modifications, to be licensed at no charge to all 101 | third parties under the terms of this General Public License (except 102 | that you may choose to grant warranty protection to some or all 103 | third parties, at your option). 104 | 105 | c) If the modified program normally reads commands interactively when 106 | run, you must cause it, when started running for such interactive use 107 | in the simplest and most usual way, to print or display an 108 | announcement including an appropriate copyright notice and a notice 109 | that there is no warranty (or else, saying that you provide a 110 | warranty) and that users may redistribute the program under these 111 | conditions, and telling the user how to view a copy of this General 112 | Public License. 113 | 114 | d) You may charge a fee for the physical act of transferring a 115 | copy, and you may at your option offer warranty protection in 116 | exchange for a fee. 117 | 118 | Mere aggregation of another independent work with the Program (or its 119 | derivative) on a volume of a storage or distribution medium does not bring 120 | the other work under the scope of these terms. 121 | 122 | 3. You may copy and distribute the Program (or a portion or derivative of 123 | it, under Paragraph 2) in object code or executable form under the terms of 124 | Paragraphs 1 and 2 above provided that you also do one of the following: 125 | 126 | a) accompany it with the complete corresponding machine-readable 127 | source code, which must be distributed under the terms of 128 | Paragraphs 1 and 2 above; or, 129 | 130 | b) accompany it with a written offer, valid for at least three 131 | years, to give any third party free (except for a nominal charge 132 | for the cost of distribution) a complete machine-readable copy of the 133 | corresponding source code, to be distributed under the terms of 134 | Paragraphs 1 and 2 above; or, 135 | 136 | c) accompany it with the information you received as to where the 137 | corresponding source code may be obtained. (This alternative is 138 | allowed only for noncommercial distribution and only if you 139 | received the program in object code or executable form alone.) 140 | 141 | Source code for a work means the preferred form of the work for making 142 | modifications to it. For an executable file, complete source code means 143 | all the source code for all modules it contains; but, as a special 144 | exception, it need not include source code for modules which are standard 145 | libraries that accompany the operating system on which the executable 146 | file runs, or for standard header files or definitions files that 147 | accompany that operating system. 148 | 149 | 4. You may not copy, modify, sublicense, distribute or transfer the 150 | Program except as expressly provided under this General Public License. 151 | Any attempt otherwise to copy, modify, sublicense, distribute or transfer 152 | the Program is void, and will automatically terminate your rights to use 153 | the Program under this License. However, parties who have received 154 | copies, or rights to use copies, from you under this General Public 155 | License will not have their licenses terminated so long as such parties 156 | remain in full compliance. 157 | 158 | 5. By copying, distributing or modifying the Program (or any work based 159 | on the Program) you indicate your acceptance of this license to do so, 160 | and all its terms and conditions. 161 | 162 | 6. Each time you redistribute the Program (or any work based on the 163 | Program), the recipient automatically receives a license from the original 164 | licensor to copy, distribute or modify the Program subject to these 165 | terms and conditions. You may not impose any further restrictions on the 166 | recipients' exercise of the rights granted herein. 167 | 168 | 7. The Free Software Foundation may publish revised and/or new versions 169 | of the General Public License from time to time. Such new versions will 170 | be similar in spirit to the present version, but may differ in detail to 171 | address new problems or concerns. 172 | 173 | Each version is given a distinguishing version number. If the Program 174 | specifies a version number of the license which applies to it and "any 175 | later version", you have the option of following the terms and conditions 176 | either of that version or of any later version published by the Free 177 | Software Foundation. If the Program does not specify a version number of 178 | the license, you may choose any version ever published by the Free Software 179 | Foundation. 180 | 181 | 8. If you wish to incorporate parts of the Program into other free 182 | programs whose distribution conditions are different, write to the author 183 | to ask for permission. For software which is copyrighted by the Free 184 | Software Foundation, write to the Free Software Foundation; we sometimes 185 | make exceptions for this. Our decision will be guided by the two goals 186 | of preserving the free status of all derivatives of our free software and 187 | of promoting the sharing and reuse of software generally. 188 | 189 | NO WARRANTY 190 | 191 | 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 192 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 193 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 194 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 195 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 196 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 197 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 198 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 199 | REPAIR OR CORRECTION. 200 | 201 | 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 202 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 203 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 204 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 205 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 206 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 207 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 208 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 209 | POSSIBILITY OF SUCH DAMAGES. 210 | 211 | END OF TERMS AND CONDITIONS 212 | 213 | Appendix: How to Apply These Terms to Your New Programs 214 | 215 | If you develop a new program, and you want it to be of the greatest 216 | possible use to humanity, the best way to achieve this is to make it 217 | free software which everyone can redistribute and change under these 218 | terms. 219 | 220 | To do so, attach the following notices to the program. It is safest to 221 | attach them to the start of each source file to most effectively convey 222 | the exclusion of warranty; and each file should have at least the 223 | "copyright" line and a pointer to where the full notice is found. 224 | 225 | 226 | Copyright (C) 19yy 227 | 228 | This program is free software; you can redistribute it and/or modify 229 | it under the terms of the GNU General Public License as published by 230 | the Free Software Foundation; either version 1, or (at your option) 231 | any later version. 232 | 233 | This program is distributed in the hope that it will be useful, 234 | but WITHOUT ANY WARRANTY; without even the implied warranty of 235 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 236 | GNU General Public License for more details. 237 | 238 | You should have received a copy of the GNU General Public License 239 | along with this program; if not, write to the Free Software 240 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA 241 | 242 | 243 | Also add information on how to contact you by electronic and paper mail. 244 | 245 | If the program is interactive, make it output a short notice like this 246 | when it starts in an interactive mode: 247 | 248 | Gnomovision version 69, Copyright (C) 19xx name of author 249 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 250 | This is free software, and you are welcome to redistribute it 251 | under certain conditions; type `show c' for details. 252 | 253 | The hypothetical commands `show w' and `show c' should show the 254 | appropriate parts of the General Public License. Of course, the 255 | commands you use may be called something other than `show w' and `show 256 | c'; they could even be mouse-clicks or menu items--whatever suits your 257 | program. 258 | 259 | You should also get your employer (if you work as a programmer) or your 260 | school, if any, to sign a "copyright disclaimer" for the program, if 261 | necessary. Here a sample; alter the names: 262 | 263 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 264 | program `Gnomovision' (a program to direct compilers to make passes 265 | at assemblers) written by James Hacker. 266 | 267 | , 1 April 1989 268 | Ty Coon, President of Vice 269 | 270 | That's all there is to it! 271 | 272 | 273 | --- The Artistic License 1.0 --- 274 | 275 | This software is Copyright (c) 2008 by Florian Ragwitz. 276 | 277 | This is free software, licensed under: 278 | 279 | The Artistic License 1.0 280 | 281 | The Artistic License 282 | 283 | Preamble 284 | 285 | The intent of this document is to state the conditions under which a Package 286 | may be copied, such that the Copyright Holder maintains some semblance of 287 | artistic control over the development of the package, while giving the users of 288 | the package the right to use and distribute the Package in a more-or-less 289 | customary fashion, plus the right to make reasonable modifications. 290 | 291 | Definitions: 292 | 293 | - "Package" refers to the collection of files distributed by the Copyright 294 | Holder, and derivatives of that collection of files created through 295 | textual modification. 296 | - "Standard Version" refers to such a Package if it has not been modified, 297 | or has been modified in accordance with the wishes of the Copyright 298 | Holder. 299 | - "Copyright Holder" is whoever is named in the copyright or copyrights for 300 | the package. 301 | - "You" is you, if you're thinking about copying or distributing this Package. 302 | - "Reasonable copying fee" is whatever you can justify on the basis of media 303 | cost, duplication charges, time of people involved, and so on. (You will 304 | not be required to justify it to the Copyright Holder, but only to the 305 | computing community at large as a market that must bear the fee.) 306 | - "Freely Available" means that no fee is charged for the item itself, though 307 | there may be fees involved in handling the item. It also means that 308 | recipients of the item may redistribute it under the same conditions they 309 | received it. 310 | 311 | 1. You may make and give away verbatim copies of the source form of the 312 | Standard Version of this Package without restriction, provided that you 313 | duplicate all of the original copyright notices and associated disclaimers. 314 | 315 | 2. You may apply bug fixes, portability fixes and other modifications derived 316 | from the Public Domain or from the Copyright Holder. A Package modified in such 317 | a way shall still be considered the Standard Version. 318 | 319 | 3. You may otherwise modify your copy of this Package in any way, provided that 320 | you insert a prominent notice in each changed file stating how and when you 321 | changed that file, and provided that you do at least ONE of the following: 322 | 323 | a) place your modifications in the Public Domain or otherwise make them 324 | Freely Available, such as by posting said modifications to Usenet or an 325 | equivalent medium, or placing the modifications on a major archive site 326 | such as ftp.uu.net, or by allowing the Copyright Holder to include your 327 | modifications in the Standard Version of the Package. 328 | 329 | b) use the modified Package only within your corporation or organization. 330 | 331 | c) rename any non-standard executables so the names do not conflict with 332 | standard executables, which must also be provided, and provide a separate 333 | manual page for each non-standard executable that clearly documents how it 334 | differs from the Standard Version. 335 | 336 | d) make other distribution arrangements with the Copyright Holder. 337 | 338 | 4. You may distribute the programs of this Package in object code or executable 339 | form, provided that you do at least ONE of the following: 340 | 341 | a) distribute a Standard Version of the executables and library files, 342 | together with instructions (in the manual page or equivalent) on where to 343 | get the Standard Version. 344 | 345 | b) accompany the distribution with the machine-readable source of the Package 346 | with your modifications. 347 | 348 | c) accompany any non-standard executables with their corresponding Standard 349 | Version executables, giving the non-standard executables non-standard 350 | names, and clearly documenting the differences in manual pages (or 351 | equivalent), together with instructions on where to get the Standard 352 | Version. 353 | 354 | d) make other distribution arrangements with the Copyright Holder. 355 | 356 | 5. You may charge a reasonable copying fee for any distribution of this 357 | Package. You may charge any fee you choose for support of this Package. You 358 | may not charge a fee for this Package itself. However, you may distribute this 359 | Package in aggregate with other (possibly commercial) programs as part of a 360 | larger (possibly commercial) software distribution provided that you do not 361 | advertise this Package as a product of your own. 362 | 363 | 6. The scripts and library files supplied as input to or produced as output 364 | from the programs of this Package do not automatically fall under the copyright 365 | of this Package, but belong to whomever generated them, and may be sold 366 | commercially, and may be aggregated with this Package. 367 | 368 | 7. C or perl subroutines supplied by you and linked into this Package shall not 369 | be considered part of this Package. 370 | 371 | 8. The name of the Copyright Holder may not be used to endorse or promote 372 | products derived from this software without specific prior written permission. 373 | 374 | 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 375 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 376 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 377 | 378 | The End 379 | 380 | --------------------------------------------------------------------------------