r46246 - in /trunk/libpostscript-file-perl: Changes MANIFEST META.yml Makefile.PL README debian/changelog lib/PostScript/File.pm t/fi05pstr.t t/fi06content.t
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Fri Oct 23 12:14:03 UTC 2009
Author: jawnsy-guest
Date: Fri Oct 23 12:13:56 2009
New Revision: 46246
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=46246
Log:
New upstream release
Added:
trunk/libpostscript-file-perl/t/fi06content.t
- copied unchanged from r46245, branches/upstream/libpostscript-file-perl/current/t/fi06content.t
Modified:
trunk/libpostscript-file-perl/Changes
trunk/libpostscript-file-perl/MANIFEST
trunk/libpostscript-file-perl/META.yml
trunk/libpostscript-file-perl/Makefile.PL
trunk/libpostscript-file-perl/README
trunk/libpostscript-file-perl/debian/changelog
trunk/libpostscript-file-perl/lib/PostScript/File.pm
trunk/libpostscript-file-perl/t/fi05pstr.t
Modified: trunk/libpostscript-file-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/Changes?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/Changes (original)
+++ trunk/libpostscript-file-perl/Changes Fri Oct 23 12:13:56 2009
@@ -1,4 +1,12 @@
Revision history for Perl extension PostScript::File.
+
+1.04 October 22, 2009
+ - add_comment now appends to comments (as originally documented)
+ (fixes RT#25786)
+ - Allow WIDTHxHEIGHT as a paper size
+ - Remove spaces before DSC comments even when strip none
+ - pstr now wraps strings longer than 240 characters
+ - strip comments is more aggressive (but won't remove DSC comments)
1.03 October 20, 2009
- Added pstr function/method
Modified: trunk/libpostscript-file-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/MANIFEST?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/MANIFEST (original)
+++ trunk/libpostscript-file-perl/MANIFEST Fri Oct 23 12:13:56 2009
@@ -10,5 +10,6 @@
t/fi03debug.t
t/fi04pages.t
t/fi05pstr.t
+t/fi06content.t
t/release-pod-coverage.t
t/release-pod-syntax.t
Modified: trunk/libpostscript-file-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/META.yml?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/META.yml (original)
+++ trunk/libpostscript-file-perl/META.yml Fri Oct 23 12:13:56 2009
@@ -15,4 +15,4 @@
Sys::Hostname: 0
resources:
repository: http://github.com/madsen/postscript-file
-version: 1.03
+version: 1.04
Modified: trunk/libpostscript-file-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/Makefile.PL?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/Makefile.PL (original)
+++ trunk/libpostscript-file-perl/Makefile.PL Fri Oct 23 12:13:56 2009
@@ -9,7 +9,7 @@
NAME => 'PostScript::File',
AUTHOR => "Christopher\ Willmot\ \<chris\@willmot\.co\.uk\>\,\ Christopher\ J\.\ Madsen\ \<perl\@cjmweb\.net\>",
ABSTRACT => "Base\ class\ for\ creating\ Adobe\ PostScript\ files",
- VERSION => '1.03',
+ VERSION => '1.04',
EXE_FILES => [ qw() ],
(eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()),
PREREQ_PM => {
Modified: trunk/libpostscript-file-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/README?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/README (original)
+++ trunk/libpostscript-file-perl/README Fri Oct 23 12:13:56 2009
@@ -1,4 +1,4 @@
-PostScript::File version 1.03, released October 20, 2009
+PostScript::File version 1.04, released October 22, 2009
This module produces the outline for an Adobe PostScript file. It provides
convenient routines for writing postscript directly, including reporting
@@ -40,21 +40,15 @@
CHANGES
- Here's what's new in version 1.03 of PostScript::File:
+ Here's what's new in version 1.04 of PostScript::File:
(See the file "Changes" for the full revision history.)
- - Added pstr function/method
- - Added embed_document method
- - The dir & file parameters to new now actually work
- - The file_ext parameter and {get,set}_file_ext methods allow
- you to change the way PostScript::File appends an extension
- to the output filename
- - The PNG output added in 1.01 is now documented
- - Using Ghostscript to generate PNG should work on Windows now
- - Include resource types in %%DocumentSuppliedResources comment
- - Fixed has_function to avoid false positives
- - Include procset PostScript_File in %%DocumentSuppliedResources
- - PostScript::File now requires Perl 5.8.0 or later
+ - add_comment now appends to comments (as originally documented)
+ (fixes RT#25786)
+ - Allow WIDTHxHEIGHT as a paper size
+ - Remove spaces before DSC comments even when strip none
+ - pstr now wraps strings longer than 240 characters
+ - strip comments is more aggressive (but won't remove DSC comments)
Modified: trunk/libpostscript-file-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/debian/changelog?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/debian/changelog (original)
+++ trunk/libpostscript-file-perl/debian/changelog Fri Oct 23 12:13:56 2009
@@ -1,3 +1,9 @@
+libpostscript-file-perl (1.04-1) UNRELEASED; urgency=low
+
+ * New upstream release
+
+ -- Jonathan Yu <jawnsy at cpan.org> Fri, 23 Oct 2009 04:42:40 -0400
+
libpostscript-file-perl (1.03-1) unstable; urgency=low
* New upstream release
Modified: trunk/libpostscript-file-perl/lib/PostScript/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/lib/PostScript/File.pm?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/lib/PostScript/File.pm (original)
+++ trunk/libpostscript-file-perl/lib/PostScript/File.pm Fri Oct 23 12:13:56 2009
@@ -1,5 +1,5 @@
package PostScript::File;
-our $VERSION = '1.03';
+our $VERSION = '1.04';
use 5.008;
use strict;
use warnings;
@@ -18,7 +18,7 @@
# global constants
my $rmspace = qr(^\s+)m; # remove leading spaces
-my $rmcomment = qr(^\s+\(% .*\)?)m; # remove single line comments
+my $rmcomment = qr(^\s*\(%(?![!%]).*\n\)?)m; # remove single line comments
=head1 NAME
@@ -26,8 +26,8 @@
=head1 VERSION
-This document describes version 1.03 of PostScript::File,
-released October 20, 2009.
+This document describes version 1.04 of PostScript::File,
+released October 22, 2009.
=head1 SYNOPSIS
@@ -484,6 +484,9 @@
Legal, 'US-Legal', Tabloid, 'SuperB', Ledger, 'Comm #10 Envelope', 'Envelope-Monarch', 'Envelope-DL',
'Envelope-C5', 'EuroPostcard'. (Default: "A4")
+You can also give a string in the form 'WIDTHxHEIGHT', where WIDTH and
+HEIGHT are numbers (in points). This sets the paper size to "Custom".
+
This also sets C<width> and C<height>. B<get_paper> returns the value set here.
=head3 right
@@ -629,8 +632,8 @@
=head3 strip
-Set whether the postscript code is filtered. C<space> strips leading spaces so the user can indent freely
-without increasing the file size. C<comments> remove lines beginning with '%' as well. (Default: "space")
+Set whether the PostScript code is filtered. C<space> strips leading spaces so the user can indent freely
+without increasing the file size. C<comments> remove lines beginning with '%' as well. C<none> does no filtering. (Default: "space")
=cut
@@ -671,7 +674,7 @@
$o->{DocSupplied} .= "\%\%+ Encoded_Fonts\n";
my $encoding = $o->{reencode};
my $ext = $o->{font_suffix};
- ($fonts .= <<END_FONTS) =~ s/$o->{strip}//gm;
+ $fonts .= $o->_here_doc(<<END_FONTS);
\%\%BeginResource: Encoded_Fonts
/STARTDIFFENC { mark } bind def
/ENDDIFFENC {
@@ -774,23 +777,23 @@
my $hostname = hostname();
my $postscript = $o->{eps} ? "\%!PS-Adobe-3.0 EPSF-3.0\n" : "\%!PS-Adobe-3.0\n";
if ($o->{eps}) {
- ($postscript .= <<END_EPS) =~ s/$o->{strip}//gm;
+ $postscript .= $o->_here_doc(<<END_EPS);
\%\%BoundingBox: $o->{bbox}[0] $o->{bbox}[1] $o->{bbox}[2] $o->{bbox}[3]
END_EPS
}
if ($o->{headings}) {
- ($postscript .= <<END_TITLES) =~ s/$o->{strip}//gm;
+ $postscript .= $o->_here_doc(<<END_TITLES);
\%\%For: $user\@$hostname
\%\%Creator: Perl module ${\( ref $o )} v$PostScript::File::VERSION
\%\%CreationDate: ${\( scalar localtime )}
END_TITLES
- ($postscript .= <<END_PS_ONLY) =~ s/$o->{strip}//gm if (not $o->{eps});
+ $postscript .= $o->_here_doc(<<END_PS_ONLY) if (not $o->{eps});
\%\%DocumentMedia: $o->{paper} $o->{width} $o->{height} 80 ( ) ( )
END_PS_ONLY
}
my $landscapefn = "";
- ($landscapefn .= <<END_LANDSCAPE) =~ s/$o->{strip}//gm if ($landscape);
+ $landscapefn .= $o->_here_doc(<<END_LANDSCAPE) if ($landscape);
% Rotate page 90 degrees
% _ => _
/landscape {
@@ -800,7 +803,7 @@
END_LANDSCAPE
my $clipfn = "";
- ($clipfn .= <<END_CLIPPING) =~ s/$o->{strip}//gm if ($clipping);
+ $clipfn .= $o->_here_doc(<<END_CLIPPING) if ($clipping);
% Draw box as clipping path
% x0 y0 x1 y1 => _
/cliptobox {
@@ -818,7 +821,7 @@
END_CLIPPING
my $errorfn = "";
- ($errorfn .= <<END_ERRORS) =~ s/$o->{strip}//gm if ($o->{errors});
+ $errorfn .= $o->_here_doc(<<END_ERRORS) if ($o->{errors});
/errx $o->{errx} def
/erry $o->{erry} def
/errmsg ($o->{errmsg}) def
@@ -852,7 +855,7 @@
END_ERRORS
my $debugfn = "";
- ($debugfn .= <<END_DEBUG_ON) =~ s/$o->{strip}//gm if ($o->{debug});
+ $debugfn .= $o->_here_doc(<<END_DEBUG_ON) if ($o->{debug});
/debugdict 25 dict def
debugdict begin
@@ -1015,7 +1018,7 @@
end
END_DEBUG_ON
- ($debugfn .= <<END_DEBUG_OFF) =~ s/$o->{strip}//gm if (defined($o->{debug}) and not $o->{debug});
+ $debugfn .= $o->_here_doc(<<END_DEBUG_OFF) if (defined($o->{debug}) and not $o->{debug});
% Define out the db_ functions
/debugdict 25 dict def
debugdict begin
@@ -1035,12 +1038,12 @@
my $supplied = "";
if ($landscapefn or $clipfn or $errorfn or $debugfn) {
$o->{DocSupplied} .= "\%\%+ procset PostScript_File\n";
- ($supplied .= <<END_DOC_SUPPLIED) =~ s/$o->{strip}//gm;
+ $supplied .= $o->_here_doc(<<END_DOC_SUPPLIED);
\%\%BeginProcSet: PostScript_File
- $landscapefn
- $clipfn
- $errorfn
- $debugfn
+ $landscapefn
+ $clipfn
+ $errorfn
+ $debugfn
\%\%EndProcSet
END_DOC_SUPPLIED
}
@@ -1059,22 +1062,22 @@
$postscript .= $o->{Preview} if ($o->{Preview});
- ($postscript .= <<END_DEFAULTS) =~ s/$o->{strip}//gm if ($o->{Defaults});
+ $postscript .= $o->_here_doc(<<END_DEFAULTS) if ($o->{Defaults});
\%\%BeginDefaults
$o->{Defaults}
\%\%EndDefaults
END_DEFAULTS
- ($postscript .= <<END_PROLOG) =~ s/$o->{strip}//gm;
+ $postscript .= $o->_here_doc(<<END_PROLOG);
\%\%BeginProlog
- $supplied
- $fonts
- $o->{Resources}
- $o->{Functions}
+ $supplied
+ $fonts
+ $o->{Resources}
+ $o->{Functions}
\%\%EndProlog
END_PROLOG
- ($postscript .= <<END_SETUP) =~ s/$o->{strip}//gm if ($o->{Setup});
+ $postscript .= $o->_here_doc(<<END_SETUP) if ($o->{Setup});
\%\%BeginSetup
$o->{Setup}
\%\%EndSetup
@@ -1087,7 +1090,7 @@
my $o = shift;
my $postscript = "";
- ($postscript .= <<END_TRAILER) =~ s/$o->{strip}//gm if ($o->{Trailer});
+ $postscript .= $o->_here_doc(<<END_TRAILER) if ($o->{Trailer});
\%\%Trailer
$o->{Trailer}
END_TRAILER
@@ -1176,7 +1179,7 @@
$pagebb = "\%\%PageBoundingBox: $pbox[0] $pbox[1] $pbox[2] $pbox[3]";
}
my $cliptobox = $o->{pageclip}[$p] ? "$pbox[0] $pbox[1] $pbox[2] $pbox[3] cliptobox" : "";
- ($postscript .= <<END_PAGE_SETUP) =~ s/$o->{strip}//gm;
+ $postscript .= $o->_here_doc(<<END_PAGE_SETUP);
\%\%Page: $o->{page}->[$p] ${\($p+1)}
$pagebb
\%\%BeginPageSetup
@@ -1188,7 +1191,7 @@
\%\%EndPageSetup
END_PAGE_SETUP
$postscript .= $o->{Pages}->[$p];
- ($postscript .= <<END_PAGE_TRAILER) =~ s/$o->{strip}//gm;
+ $postscript .= $o->_here_doc(<<END_PAGE_TRAILER);
\%\%PageTrailer
$o->{PageTrailer}
$debugend
@@ -1345,7 +1348,14 @@
sub set_paper {
my $o = shift;
my $paper = shift || "A4";
- my ($width, $height) = split(/\s+/, $size{lc($paper)});
+ my ($width, $height) = split(/\s+/, $size{lc($paper)} || '');
+
+ if (not $height and $paper =~ /^(\d+(?:\.\d+)?)\s*x\s*(\d+(?:\.\d+)?)$/i) {
+ $width = $1;
+ $height = $2;
+ $paper = 'Custom';
+ } # end if $paper is 'WIDTH x HEIGHT'
+
if ($height) {
$o->{paper} = $paper;
$o->{width} = $width;
@@ -1755,7 +1765,7 @@
sub add_comment {
my ($o, $entry) = @_;
- $o->{Comments} = "\%\%$entry\n" if defined($entry);
+ $o->{Comments} .= "\%\%$entry\n" if defined($entry);
}
=head2 get_comments()
@@ -1785,7 +1795,7 @@
my ($o, $width, $height, $depth, $lines, $entry) = @_;
if (defined $entry) {
$entry =~ s/$o->{strip}//gm;
- ($o->{Preview} = <<END_PREVIEW) =~ s/$o->{strip}//gm;
+ $o->{Preview} = $o->_here_doc(<<END_PREVIEW);
\%\%BeginPreview: $width $height $depth $lines
$entry
\%\%EndPreview
@@ -1840,7 +1850,7 @@
$resource =~ s/$o->{strip}//gm;
$o->{DocSupplied} .= "\%\%+ $supplied_type{$type} $name\n"
if defined $supplied_type{$type};
- ($o->{Resources} = <<END_USER_RESOURCE) =~ s/$o->{strip}//gm;
+ $o->{Resources} = $o->_here_doc(<<END_USER_RESOURCE);
\%\%Begin${type}: $name $params
$resource
\%\%End$type
@@ -1896,7 +1906,7 @@
if (defined($name) and defined($entry)) {
$entry =~ s/$o->{strip}//gm;
$o->{DocSupplied} .= "\%\%+ procset $name\n";
- ($o->{Functions} .= <<END_USER_FUNCTIONS) =~ s/$o->{strip}//gm;
+ $o->{Functions} .= $o->_here_doc(<<END_USER_FUNCTIONS);
\%\%BeginProcSet: $name
$entry
\%\%EndProcSet
@@ -1960,7 +1970,7 @@
{
my ($o, $filename) = @_;
- my $id = $o->pstr($filename);
+ my $id = $o->pstr(substr($filename, -234), 1); # in case it's long
$o->{DocSupplied} .= "%%+ file $id\n"
unless index($o->{DocSupplied}, "%%+ file $id\n") >= 0;
@@ -2268,6 +2278,24 @@
my $o = shift;
$o->{clipcmd} = "clip";
}
+
+# Strip leading spaces off a here document:
+
+sub _here_doc
+{
+ my ($o, $text) = @_;
+
+ if ($o->{strip}) {
+ $text =~ s/$o->{strip}//gm;
+ } elsif ($text =~ /^([ \t]+)/) {
+ my $space = $1;
+
+ $text =~ s/^$space//gm;
+ $text =~ s/^[ \t]+\n/\n/gm;
+ } # end elsif no strip but $text is indented
+
+ $text;
+} # end _here_doc
=head1 EXPORTED FUNCTIONS
@@ -2441,13 +2469,23 @@
sub pstr {
shift if @_ == 2; # We were called as a method
my $string = shift;
+ my $nowrap = shift;
$string =~ s/([$specialKeys])/$special{$1}/go;
- "($string)";
+ $string = "($string)";
+ # A PostScript file should not have more than 255 chars per line:
+ $string =~ s/(.{240}[^\\])/$1\\\n/g unless $nowrap;
+ $string =~ s/^([ %])/\\$1/mg; # Make sure it doesn't get stripped
+
+ $string;
} # end pstr
-=head2 pstr( string )
-
-Converts the string to a string representation suitable for postscript code.
+=head2 pstr( string, [nowrap] )
+
+Converts the string to a string representation suitable for postscript
+code. If the result is more than 240 characters, it will be broken
+into multiple lines unless the optional nowrap parameter is true. (A
+PostScript file should not contain lines with more than 255
+characters.)
This may also be called as a class or object method.
Modified: trunk/libpostscript-file-perl/t/fi05pstr.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpostscript-file-perl/t/fi05pstr.t?rev=46246&op=diff
==============================================================================
--- trunk/libpostscript-file-perl/t/fi05pstr.t (original)
+++ trunk/libpostscript-file-perl/t/fi05pstr.t Fri Oct 23 12:13:56 2009
@@ -2,7 +2,7 @@
#---------------------------------------------------------------------
# Copyright 2009 Christopher J. Madsen
#
-# Author: Christopher J. Madsen <cjm at pobox.com>
+# Author: Christopher J. Madsen <perl at pobox.com>
# Created: 12 Oct 2009
#
# This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
use strict;
use warnings;
-use Test::More tests => 6;
+use Test::More;
use PostScript::File 'pstr';
@@ -30,7 +30,15 @@
'Hello, world' => '(Hello, world)',
'is (' => '(is \()',
"has\n newline" => '(has\n newline)',
+ 'xxxx ' x 100 => '(' . ('xxxx ' x 48) . "\\\n" .
+ ('xxxx ' x 48) . "x\\\nxxx " .
+ ('xxxx ' x 3) . ')',
+ 'a ' x 50 => '(' . ('a ' x 24) . "\\\n" .
+ ('a ' x 24) . "a\\\n\\ " .
+ ('a ' x 1) . ')',
);
+
+plan tests => scalar @realTests;
my @tests = @realTests;
@@ -38,6 +46,7 @@
my $in = shift @tests;
(my $name = $in) =~ s/\s+/ /g;
+ $name = substr($name, 0, 50);
is(pstr($in), shift @tests, $name);
} # end while @tests
@@ -49,6 +58,7 @@
my $in = shift @tests;
(my $name = $in) =~ s/\s+/ /g;
+ $name = substr($name, 0, 50);
is(PostScript::File->pstr($in), shift @tests, "class method $name");
} # end while @tests
More information about the Pkg-perl-cvs-commits
mailing list