[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 12/15: [gropdf]: Validate `DESC` file as grops(1) does.
From: |
G. Branden Robinson |
Subject: |
[groff] 12/15: [gropdf]: Validate `DESC` file as grops(1) does. |
Date: |
Mon, 6 Jun 2022 22:26:14 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 38b27aeaa49e24de2c90af865e14b2c45c30c0b0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jun 6 00:16:53 2022 -0500
[gropdf]: Validate `DESC` file as grops(1) does.
* src/devices/gropdf/gropdf.pl (LoadDesc): Validate device description
file for essential directives and acceptable values as grops(1) does.
---
ChangeLog | 6 ++++++
src/devices/gropdf/gropdf.pl | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index c8320535..fe87a4b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-06-06 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/devices/gropdf/gropdf.pl (LoadDesc): Validate device
+ description file for essential directives and acceptable values
+ as grops(1) does.
+
2022-06-04 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff, grohtml, grops, grotty]: Update wording of diagnostic
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index 9002cd6e..a230eb3c 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -689,6 +689,32 @@ sub LoadDesc
Die("device description file 'DESC' missing mandatory directive"
. " '$directive'") if !exists($desc{$directive});
}
+
+ foreach my $directive ('unitwidth', 'res', 'sizescale')
+ {
+ my $val=$desc{$directive};
+ Die("device description file 'DESC' directive '$directive'"
+ . " value must be positive; got '$val'")
+ if ($val !~ m/^\d+$/ or $val <= 0);
+ }
+
+ if (exists($desc{'hor'}))
+ {
+ my $hor=$desc{'hor'};
+ Die("device horizontal motion quantum must be 1, got '$hor'")
+ if ($hor != 1);
+ }
+
+ if (exists($desc{'vert'}))
+ {
+ my $vert=$desc{'vert'};
+ Die("device vertical motion quantum must be 1, got '$vert'")
+ if ($vert != 1);
+ }
+
+ my ($res,$ss)=($desc{'res'},$desc{'sizescale'});
+ Die("device resolution must be a multiple of 72*sizescale, got"
+ . " '$res' ('sizescale'=$ss)") if (($res % ($ss * 72)) != 0);
}
sub rad { $_[0]*3.14159/180 }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 12/15: [gropdf]: Validate `DESC` file as grops(1) does.,
G. Branden Robinson <=