!13 Rewrite papersize to fix psnup psresize execute error

From: @wang--ge 
Reviewed-by: @wk333 
Signed-off-by: @wk333
This commit is contained in:
openeuler-ci-bot 2024-04-19 08:15:54 +00:00 committed by Gitee
commit a06ac92a2e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 42 additions and 1 deletions

View File

@ -3,7 +3,7 @@
Name: psutils
Version: 2.08
Release: 2
Release: 3
Summary: Utilities for manipulating PostScript documents
License: psutils
URL: https://github.com/rrthomas/psutils
@ -12,6 +12,7 @@ URL: https://github.com/rrthomas/psutils
# ./bootstrap && autoreconf -vfi && cd .. && tar -cvf psutils-1.23.tar.gz psutils-1.23
Source0: %{name}-%{version}.tar.gz
Patch0: psutils-paperconf.patch
Patch1: rewrite-papersize.patch
BuildRequires: gcc
BuildRequires: perl-generators
@ -56,6 +57,9 @@ make %{?_smp_mflags}
%{_mandir}/man1/*1*
%changelog
* Fri Apr 19 2024 Ge Wang <wang__ge@126.com> - 2.08-3
- Rewrite papersize to fix psnup psresize execute error
* Sun Apr 07 2024 wulei <wu_lei@hoperun.com> - 2.08-2
- Fix could not run 'paper' command

37
rewrite-papersize.patch Normal file
View File

@ -0,0 +1,37 @@
From 9aed7b37ac2740cf577165d4e3e348fcf17ab4f7 Mon Sep 17 00:00:00 2001
From: wang--ge <wang__ge@126.com>
Date: Fri, 19 Apr 2024 15:37:37 +0800
Subject: [PATCH] rewrite papersize
---
PSUtils.pm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/PSUtils.pm b/PSUtils.pm
index 9a95056..8b64247 100644
--- a/PSUtils.pm
+++ b/PSUtils.pm
@@ -73,13 +73,16 @@ sub paper {
sub paper_size {
my ($paper_name) = @_;
chomp($paper_name = paper([])) unless defined($paper_name);
- my $dimensions = paper(["--unit=pt", "$paper_name"], 1) or return;
- $dimensions =~ / ([.0-9]+)x([.0-9]+) pt$/;
+ my $dimensions_w = paper(["-p", "$paper_name", "-m", "-w"], 1) or return;
+ $dimensions_w =~ / ([.0-9]+) mm$/;
my $old_locale = setlocale(LC_ALL);
setlocale(LC_ALL, "");
- my ($w, $w_unparsed) = strtod($1);
- my ($h, $h_unparsed) = strtod($2);
+ my ($w, $w_unparsed) = strtod($dimensions_w);
+ my $dimensions_h = paper(["-p", "$paper_name", "-m", "-h"], 1) or return;
+ $dimensions_h =~ / ([.0-9]+) mm$/;
+ my ($h, $h_unparsed) = strtod($dimensions_h);
setlocale(LC_ALL, $old_locale);
+ print($w,$h, $dimensions_w, $dimensions_h);
return int($w + 0.5), int($h + 0.5); # round dimensions to nearest point
}
--
2.33.0