Correctly parse paper sizes returned by paperconf (#1208985)

Patch from Michael Spacil.
This commit is contained in:
Jiri Popelka 2015-05-29 13:55:06 +02:00
parent f2486ca516
commit 54fece8a72
2 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,6 @@
diff -up psutils-1.23/configure.paperconf psutils-1.23/configure
--- psutils-1.23/configure.paperconf 2014-01-22 10:31:58.000000000 +0100
+++ psutils-1.23/configure 2014-03-04 16:19:48.053365284 +0100
+++ psutils-1.23/configure 2015-05-20 14:25:40.636115433 +0200
@@ -15700,7 +15700,7 @@ fi
@ -12,13 +12,29 @@ diff -up psutils-1.23/configure.paperconf psutils-1.23/configure
diff -up psutils-1.23/psutil.c.paperconf psutils-1.23/psutil.c
--- psutils-1.23/psutil.c.paperconf 2014-01-16 11:20:54.000000000 +0100
+++ psutils-1.23/psutil.c 2014-03-04 16:18:58.361057495 +0100
@@ -88,7 +88,7 @@ int paper_size(const char *paper_name, d
+++ psutils-1.23/psutil.c 2015-05-29 13:24:12.834350330 +0200
@@ -88,13 +87,21 @@ int paper_size(const char *paper_name, d
int res = 0;
if (paper_name == NULL) /* Use default paper name */
paper_name = pgetline(PAPER);
- if (paper_name && (cmd = xasprintf(PAPER " --unit=pt --size %s", paper_name)) && (l = pgetline(cmd)))
- res = sscanf(l, "%lg %lg", width, height);
+ if (paper_name && (cmd = xasprintf(PAPER " -s %s", paper_name)) && (l = pgetline(cmd)))
res = sscanf(l, "%lg %lg", width, height);
+ {
+ for (int i = 0; i < strlen(l); i++)
+ {
+ if (l[i] == ',')
+ {
+ l[i] = '.';
+ }
+ }
+ res = sscanf(l, "%lg %lg", width, height);
+ }
free(l);
free(cmd);
return res == 2;
}
-
/* Make a file seekable, using temporary files if necessary */
FILE *seekable(FILE *fp)
{

View File

@ -1,7 +1,7 @@
Summary: PostScript Utilities
Name: psutils
Version: 1.23
Release: 6%{?dist}
Release: 7%{?dist}
License: psutils
# We can't follow https://fedoraproject.org/wiki/Packaging:SourceURL#Github
@ -79,6 +79,9 @@ sed -i -e 's,/usr/bin/env perl,%{__perl},' \
%changelog
* Fri May 29 2015 Jiri Popelka <jpopelka@redhat.com> - 1.23-7
- Correctly parse paper sizes returned by paperconf (#1208985)
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.23-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild