Skip to content

Commit fa7ffb0

Browse files
authored
Merge pull request #29 from cxw42/prepost
Minor updates; v0.600.1
2 parents d6ca649 + 53d91f0 commit fa7ffb0

File tree

9 files changed

+72
-25
lines changed

9 files changed

+72
-25
lines changed

MANIFEST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ t/05-external-command.t
1919
t/06-macro.t
2020
t/07-invalid.t
2121
t/08-persistent-state.t
22+
t/09-preproc.t
23+
t/10-postproc.t
2224
t/a.txt
2325
t/b.txt
2426
t/c.txt

Makefile.PL

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ my $secure_perl_path = get_perl_filename();
2323
sub MY::postamble { # TODO also handle Windows nmake syntax (SET vs. export)
2424
return <<EOT;
2525
authortest:
26-
\tRELEASE_TESTING=1 prove -l xt"
26+
\tRELEASE_TESTING=1 prove -l xt
2727
2828
testhere: # Run the tests from lib rather than blib
2929
\t"$secure_perl_path" -Ilib -e 'use Test::Harness "runtests"; runtests \@ARGV;' -- t/*.t
@@ -44,9 +44,10 @@ WriteMakefile(
4444
LICENSE => 'mit',
4545

4646
EXE_FILES => [ 'bin/perlpp' ],
47+
4748
MIN_PERL_VERSION => '5.010',
4849
CONFIGURE_REQUIRES => {
49-
'ExtUtils::MakeMaker' => '0',
50+
'ExtUtils::MakeMaker' => '6.46',
5051
},
5152
BUILD_REQUIRES => {
5253
'App::FatPacker' => '0',
@@ -74,6 +75,18 @@ WriteMakefile(
7475
'Getopt::Long' => '2.5', # Per issue #17
7576
'Pod::Usage' => '0',
7677
},
78+
79+
META_MERGE => {
80+
'meta-spec' => { version => 2 },
81+
resources => {
82+
repository => {
83+
type => 'git',
84+
url => 'https://github.com/interpreters/perlpp.git',
85+
web => 'https://github.com/interpreters/perlpp',
86+
},
87+
},
88+
},
89+
7790
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
7891
clean => { FILES => 'Text-PerlPP-* fatlib' },
7992
);

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The build system is straight ExtUtils::MakeMaker.
5353
Before developing, run
5454

5555
perl Makefile.PL
56-
cpanm --installdeps . # if you have cpanminus installed
56+
cpanm --installdeps . # if you have cpanminus installed
5757

5858
Then, to test your code directly from the lib/ directory, run
5959

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,5 +337,7 @@ FILETYPE can be determined with `:set ft?`
337337

338338
Distributed under the MIT license --- see
339339
[LICENSE.txt](LICENSE.txt) for details.
340-
By Andrey Shubin (d-ash at Github) and Chris White (cxw42 at Github).
341-
340+
By Andrey Shubin ([d-ash](https://github.com/d-ash)) and
341+
Chris White (CXW; [cxw42](https://github.com/cxw42));
342+
additional contributions by Mohammad S Anwar (MANWAR;
343+
[manwar](https://github.com/manwar)).

bin/perlpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,26 @@ L<ExtUtils::PerlPP>, L<HTML::EP>, L<PML>, L<Preproc::Tiny>, L<ePerl>, L<iperl>.
301301
302302
=head1 AUTHORS
303303
304-
Andrey Shubin (d-ash at Github; L<[email protected]>) and
305-
Chris White (cxw42 at Github; L<[email protected]>).
304+
=over
305+
306+
=item *
307+
308+
Originally by Andrey Shubin (d-ash at Github; C<[email protected]>)
309+
310+
=item *
311+
312+
Currently maintained by Chris White (CXW; cxw42 at Github;
313+
314+
315+
=item *
316+
317+
Other contributions by Mohammad S. Anwar (MANWAR; manwar at Github)
318+
319+
=back
306320
307321
=head1 LICENSE AND COPYRIGHT
308322
309-
Copyright 2013-2018 Andrey Shubin and Christopher White.
323+
Copyright 2013-2018 PerlPP Contributors (listed above)
310324
311325
This program is distributed under the MIT (X11) License:
312326
L<http://www.opensource.org/licenses/mit-license.php>

lib/Text/PerlPP.pm

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
package Text::PerlPP;
55

66
# Semantic versioning, packed per Perl rules. Must always be at least one
7-
# digit left of the decimal, and six digits right of the decimal.
8-
our $VERSION = '0.500004';
7+
# digit left of the decimal, and six digits right of the decimal. For
8+
# prerelease versions, put an underscore before the last three digits.
9+
our $VERSION = '0.600001';
910

1011
use 5.010001;
1112
use strict;
@@ -667,17 +668,24 @@ sub Include { # As ProcessFile(), but for use within :macro
667668
$self->StartOB(); # re-open a plain-text OB
668669
} #Include
669670

670-
sub OutputResult {
671+
sub FinalizeResult {
671672
my $self = shift;
672673
my $contents_ref = shift; # reference
673-
my $fname = shift; # "" or other false value => STDOUT
674-
my $proc;
675-
my $out_fh;
676674

677-
for $proc ( @{$self->{Postprocessors}} ) {
675+
for my $proc ( @{$self->{Postprocessors}} ) {
678676
&$proc( $contents_ref );
679677
}
678+
return $contents_ref;
679+
} #FinalizeResult()
680680

681+
sub OutputResult {
682+
my $self = shift;
683+
my $contents_ref = shift; # reference
684+
my $fname = shift; # "" or other false value => STDOUT
685+
686+
$self->FinalizeResult( $contents_ref );
687+
688+
my $out_fh;
681689
if ( $fname ) {
682690
open( $out_fh, ">", $fname ) or die $!;
683691
} else {
@@ -799,34 +807,34 @@ sub Main {
799807
}
800808

801809
if($self->{Opts}->{PRINT_VERSION}) { # print version, raw and dotted
802-
$Text::PerlPP::VERSION =~ m<^([^\.]+)\.(\d{3})(\d{3})>;
803-
printf "PerlPP version %d.%d.%d ($VERSION)\n", $1, $2, $3;
810+
$Text::PerlPP::VERSION =~ m<^([^\.]+)\.(\d{3})(_?)(\d{3})>;
811+
printf "PerlPP version %d.%d.%d ($VERSION)%s\n", $1, $2, $4,
812+
($3 ? ' (dev)' : '');
804813
if($self->{Opts}->{PRINT_VERSION} > 1) {
805814
print "Script: $0\nText::PerlPP: $INC{'Text/PerlPP.pm'}\n";
806815
}
807816
return EXIT_OK;
808817
}
809818

810-
# Preamble
811-
812819
# Save
813820
push @Instances, $self;
814821

815822
$self->{Package} = $self->{Opts}->{INPUT_FILENAME};
816823
$self->{Package} =~ s/^.*?([a-z_][a-z_0-9.]*).pl?$/$1/i;
817824
$self->{Package} =~ s/[^a-z0-9_]/_/gi;
818-
# $self->{Package} is not the whole name, so can start with a number.
825+
# Not the whole name yet, so can start with a number.
819826
$self->{Package} = "PPP_$self->{Package}$#Instances";
820827

821828
# Make $self accessible from inside the package.
822829
# This has to happen first so that :macro or :immediate blocks in the
823830
# script can access it while the input is being parsed.
824831
{
825832
no strict 'refs';
826-
${ "$self->{Package}::" . PPP_SELF_INSIDE }
827-
= $Text::PerlPP::Instances[$#Instances];
833+
${ "$self->{Package}::" . PPP_SELF_INSIDE } = $self;
828834
}
829835

836+
# --- Preamble -----------
837+
830838
$self->StartOB(); # Output from here on will be included in the generated script
831839

832840
# Help the user know where to look
@@ -838,7 +846,7 @@ sub Main {
838846
emit "use constant { true => !!1, false => !!0 };\n";
839847
emit 'our $' . PPP_SELF_INSIDE . ";\n"; # Lexical alias for $self
840848

841-
# Definitions
849+
# --- Definitions --------
842850

843851
# Transfer parameters from the command line (-D) to the processed file,
844852
# as textual representations of expressions.
@@ -902,6 +910,8 @@ sub Main {
902910
}
903911
emit ");\n";
904912

913+
# --- User input ---------
914+
905915
# Initial code from the command line, if any
906916
if($self->{Opts}->{EVAL}) {
907917
$self->emit_pound_line( '<-e>', 1 );
@@ -913,7 +923,7 @@ sub Main {
913923

914924
my $script = $self->EndOB(); # The generated Perl script
915925

916-
# --- Run it ---
926+
# --- Run it -------------
917927
if ( $self->{Opts}->{DEBUG} ) {
918928
print $script;
919929

t/05-external-command.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ my @testcases=(
2727
['', '<?! false ?> More stuff', qr{^$} , qr{command 'false' failed: process exited}],
2828
['-k', '<?! false ?> More stuff', qr{^ More stuff$} , qr{command 'false' failed: process exited}],
2929
# Using capturing for part of the command
30-
['', '<?!echo -n "?>Hello!?<?"?>', qr{^Hello!\?$}],
30+
['', '<?!echo "?>Hello!?<?"?>', qr{^Hello!\?\n$}],
3131

3232
); #@testcases
3333

t/09-preproc.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!perl
2+
use Test::More;
3+
plan skip_all => 'Not yet implemented';

t/10-postproc.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!perl
2+
use Test::More;
3+
plan skip_all => 'Not yet implemented';

0 commit comments

Comments
 (0)