groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: Fixes <https://savannah.gnu.org/bugs/?63757>


From: Deri James
Subject: [groff] 01/01: Fixes <https://savannah.gnu.org/bugs/?63757>
Date: Thu, 9 Feb 2023 10:29:01 -0500 (EST)

deri pushed a commit to branch master
in repository groff.

commit 7fb6e3ffd06c0ad8058e5de2325eef55f178ef67
Author: Deri James <deri@chuzzlewit.myzen.co.uk>
AuthorDate: Thu Feb 9 15:27:56 2023 +0000

    Fixes <https://savannah.gnu.org/bugs/?63757>
    
    * src/devices/gropdf/gropdf.pl: Parse papersize string for
    possible multiple (space separated) entries. First valid entry
    wins.
    
    [gropdf] Parse multiple entries in 'papersize' as specified in
    the groff_font man page. Reported by Ben Wong and fix based on
    his patch, thanks.
---
 ChangeLog                    | 12 +++++++
 src/devices/gropdf/gropdf.pl | 75 ++++++++++++++++++++++++++------------------
 2 files changed, 57 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e3836b18e..b5c347fb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-02-09  Deri James  <deri@chuzzlewit.myzen.co.uk>
+
+       [gropdf] Parse multiple entries in 'papersize' as specified in
+       the groff_font man page. Reported by Ben Wong and fix based on
+       his patch, thanks.
+
+       * src/devices/gropdf/gropdf.pl: Parse papersize string for
+       possible multiple (space separated) entries. First valid entry
+       wins.
+
+       Fixes https://savannah.gnu.org/bugs/?63757
+
 2023-02-04  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        Correct numerous typos and solecisms throughout the source tree.
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index f24889219..c65a1051f 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -286,46 +286,61 @@ LoadDownload();
 LoadDesc();
 
 my $unitwidth=$desc{unitwidth};
-my $papersz=$desc{papersize};
-$papersz=lc($fpsz) if $fpsz;
 
 $env{FontHT}=0;
 $env{FontSlant}=0;
 MakeMatrix();
 
-if (substr($papersz,0,1) eq '/' and -r $papersz)
+my $possiblesizes = $desc{papersize};
+$possiblesizes = $fpsz if $fpsz;
+my $papersz;
+for $papersz ( split(" ", lc($possiblesizes).' #duff#') )
 {
-    if (open(P,"<$papersz"))
+    # No valid papersize found?
+    if ($papersz eq '#duff#')
     {
-       while (<P>)
-       {
-           chomp;
-           s/# .*//;
-           next if $_ eq '';
-           $papersz=$_;
-           last
-       }
+       Warn("ignoring unrecognized paper format(s) '$possiblesizes'");
+       last;
+    }
 
-       close(P);
+    # Check for "/etc/papersize"
+    elsif (substr($papersz,0,1) eq '/' and -r $papersz)
+    {
+        if (open(P,"<$papersz"))
+        {
+            while (<P>)
+            {
+                chomp;
+                s/# .*//;
+                next if $_ eq '';
+                $papersz=lc($_);
+                last;
+            }
+            close(P);
+        }
     }
-}
 
-if ($papersz=~m/([\d.]+)([cipP]),([\d.]+)([cipP])/)
-{
-    @defaultmb=@mediabox=(0,0,ToPoints($3,$4),ToPoints($1,$2));
-}
-elsif (exists($ppsz{$papersz}))
-{
-    @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]);
-}
-elsif (substr($papersz,-1) eq 'l' and exists($ppsz{substr($papersz,0,-1)}))
-{
-    # Note 'legal' ends in 'l' but will be caught above
-    
@defaultmb=@mediabox=(0,0,$ppsz{substr($papersz,0,-1)}->[1],$ppsz{substr($papersz,0,-1)}->[0]);
-}
-else
-{
-    Warn("ignoring unrecognized paper format '$papersz'");
+    # Allow height,width specified directly in centimeters, inches, or points.
+    if ($papersz=~m/([\d.]+)([cipP]),([\d.]+)([cipP])/)
+    {
+        @defaultmb=@mediabox=(0,0,ToPoints($3,$4),ToPoints($1,$2));
+        last;
+    }
+    # Look $papersz up as a name such as "a4" or "letter".
+    elsif (exists($ppsz{$papersz}))
+    {
+        @defaultmb=@mediabox=(0,0,$ppsz{$papersz}->[0],$ppsz{$papersz}->[1]);
+        last;
+    }
+    # Check for a landscape version
+    elsif (substr($papersz,-1) eq 'l' and exists($ppsz{substr($papersz,0,-1)}))
+    {
+       # Note 'legal' ends in 'l' but will be caught above
+       
@defaultmb=@mediabox=(0,0,$ppsz{substr($papersz,0,-1)}->[1],$ppsz{substr($papersz,0,-1)}->[0]);
+       last;
+    }
+
+    # If we get here, $papersz was invalid, so try the next one.
 }
 
 my (@dt)=localtime($ENV{SOURCE_DATE_EPOCH} || time);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]