[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/01: gropdf was choking on -I flag passed by groff.
From: |
Deri James |
Subject: |
[groff] 01/01: gropdf was choking on -I flag passed by groff. |
Date: |
Tue, 27 Oct 2015 15:48:07 +0000 |
deri pushed a commit to branch master
in repository groff.
commit 0fd1ab8c1c07c7c9bfadd30042a617e7f855d13e
Author: Deri James <address@hidden>
Date: Tue Oct 27 15:43:41 2015 +0000
gropdf was choking on -I flag passed by groff.
Now uses these directories to search for included pdfs.
* src/devices/gropdf/gropdf.pl: Handle -I flag, avoid
unitialised values.
* src/roff/groff/groff.1.man: Include 'X pdf: pdfpic'
* src/devices/gropdf/gropdf.1.man: Document -I flag
---
ChangeLog | 12 ++++++++
src/devices/gropdf/gropdf.1.man | 39 +++++++++++-----------------
src/devices/gropdf/gropdf.pl | 54 +++++++++++++++++++++++++++++++-------
src/roff/groff/groff.1.man | 4 ++-
4 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48c2371..2333859 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2015-10-27 Deri James <address@hidden>
+
+ gropdf was choking on -I flag passed by groff, now uses
+ these directories to search for included pdfs.
+
+ * src/devices/gropdf/gropdf.pl: Handle -I flag, avoid
+ unitialised values.
+
+ * src/roff/groff/groff.1.man: Include 'X pdf: pdfpic'
+
+ * src/devices/gropdf/gropdf.1.man: Document -I flag
+
2015-09-10 Bernd Warken <address@hidden>
* src/roff/grog/subs.pl: fix comments
diff --git a/src/devices/gropdf/gropdf.1.man b/src/devices/gropdf/gropdf.1.man
index 76fdc87..25287a6 100644
--- a/src/devices/gropdf/gropdf.1.man
+++ b/src/devices/gropdf/gropdf.1.man
@@ -47,7 +47,7 @@ the original English.
.SY gropdf
.OP \-delvs
.OP \-F dir
-\#.OP \-I dir
+.OP \-I dir
.OP \-p papersize
\#.OP \-w n
.OP \-y foundry
@@ -132,29 +132,20 @@ to the search path for font, and device description files;
is the name of the device, usually
.BR pdf .
.
-.\" .TP
-.\" .BI \-I dir
-.\" This option may be used to add a directory to the search path for
-.\" files on the command line and files named in
-.\" .B \[rs]X'ps: import'
-.\" and
-.\" .B \[rs]X'ps: file'
-.\" escapes.
-.\" .
-.\" The search path is initialized with the current directory.
-.\" .
-.\" This option may be specified more than once; the directories are then
-.\" searched in the order specified (but before the current directory).
-.\" .
-.\" If you want to make the current directory be read before other directories,
-.\" add
-.\" .B \-I.\&
-.\" at the appropriate place.
-.\" .
-.\" .IP
-.\" No directory search is performed for files with an absolute file name.
-.\" .
-.\" .TP
+.TP
+.BI \-I dir
+This option may be used to add a directory to the search path for
+files named in
+.B \[rs]X'pdf: pdfpic'
+escape.
+.
+The current directory is always searched first.
+.
+This option may be specified more than once; the directories are then
+searched in the order specified.
+.
+.IP
+No directory search is performed for files with an absolute file name.
.
.TP
.B \-l
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index 89767fc..0744378 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -180,10 +180,13 @@ my $debug=0;
my $version=0;
my $stats=0;
my $unicodemap;
+my @idirs;
#Load_Config();
-GetOptions("F=s" => \$fd, 'l' => \$frot, 'p=s' => \$fpsz, 'd!' => \$debug, 'v'
=> \$version, 'e' => \$embedall, 'y=s' => \$Foundry, 's' => \$stats, 'u:s' =>
\$unicodemap);
+GetOptions("F=s" => \$fd, 'I=s' => address@hidden, 'l' => \$frot, 'p=s' =>
\$fpsz, 'd!' => \$debug, 'v' => \$version, 'e' => \$embedall, 'y=s' =>
\$Foundry, 's' => \$stats, 'u:s' => \$unicodemap);
+
+unshift(@idirs,'.');
if ($version)
{
@@ -925,7 +928,7 @@ sub do_x
elsif (lc($xprm[1]) eq 'pdfpic')
{
my $fil=$xprm[2];
- my $flag=uc($xprm[3])||'-L';
+ my $flag=uc($xprm[3]||'-L');
my $wid=GetPoints($xprm[4])||-1;
my $hgt=GetPoints($xprm[5]||-1);
my $ll=GetPoints($xprm[6]||0);
@@ -1175,7 +1178,7 @@ sub GetPoints
{
my $val=shift;
- $val=ToPoints($1,$2) if ($val=~m/(-?[\d.]+)([cipnz])/);
+ $val=ToPoints($1,$2) if ($val and $val=~m/(-?[\d.]+)([cipnz])/);
return $val;
}
@@ -1302,6 +1305,35 @@ sub LoadSWF
return $xonm;
}
+sub OpenInc
+{
+ my $fn=shift;
+ my $fnm=$fn;
+ my $F;
+
+ if (substr($fnm,0,1) eq '/' or substr($fnm,1,1) eq ':') # dos
+ {
+ if (-r $fnm and open($F,"<$fnm"))
+ {
+ return($F,$fnm);
+ }
+ }
+ else
+ {
+ foreach my $dir (@idirs)
+ {
+ $fnm="$dir/$fn";
+
+ if (-r "$fnm" and open($F,"<$fnm"))
+ {
+ return($F,$fnm);
+ }
+ }
+ }
+
+ return(undef,$fn);
+}
+
sub LoadPDF
{
my $pdfnm=shift;
@@ -1316,17 +1348,19 @@ sub LoadPDF
my $instream=0;
my $cont;
- if (!open(PD,"<$pdfnm"))
+ my ($PD,$PDnm)=OpenInc($pdfnm);
+
+ if (!defined($PD))
{
Msg(0,"Failed to open PDF '$pdfnm'");
return undef;
}
- my $hdr=<PD>;
+ my $hdr=<$PD>;
$/="\r" if (length($hdr) > 10);
- while (<PD>)
+ while (<$PD>)
{
chomp;
@@ -1363,8 +1397,8 @@ sub LoadPDF
{
if ($curobj > -1)
{
- $pdf->[$curobj]->{STREAMPOS}=[tell(PD),$strmlen];
- seek(PD,$strmlen,1);
+ $pdf->[$curobj]->{STREAMPOS}=[tell($PD),$strmlen];
+ seek($PD,$strmlen,1);
$instream=1;
}
else
@@ -1377,9 +1411,9 @@ sub LoadPDF
$pdftxt.=$_.' ';
}
- close(PD);
+ close($PD);
- open(PD,"<$pdfnm");
+ open(PD,"<$PDnm");
# $pdftxt=~s/\]/ \]/g;
my (@pdfwds)=split(' ',$pdftxt);
my $wd;
diff --git a/src/roff/groff/groff.1.man b/src/roff/groff/groff.1.man
index 8d015cd..83ab7d3 100644
--- a/src/roff/groff/groff.1.man
+++ b/src/roff/groff/groff.1.man
@@ -241,8 +241,10 @@ and
.B .so
requests, and
.B \eX'ps: import'
-and
+,
.B \eX'ps: file'
+and
+.B \eX'pdf: pdfpic'
escapes).
.
The current directory is always searched first.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/01: gropdf was choking on -I flag passed by groff.,
Deri James <=