Commit | Line | Data |
---|---|---|
a608666d TGR |
1 | From c126eea11c4ee39cbe9c0c76f920626b618b6ee9 Mon Sep 17 00:00:00 2001 |
2 | From: Ralph Little <littlesincanada@yahoo.co.uk> | |
3 | Date: Sun, 1 Sep 2019 17:03:44 -0700 | |
4 | Subject: [PATCH] Apply debian upstream patch 0135-fix_pdf_floats | |
5 | ||
6 | Original patch commentary: | |
7 | ||
8 | Description: Fix floats in PDF and PostScript | |
9 | Set LC_NUMERIC to POSIX before printing floats when building | |
10 | PostScript or PDF output. | |
11 | Author: Julien BLACHE <jblache@debian.org> | |
12 | Forwarded: yes | |
13 | ||
14 | ------------ | |
15 | Looks like float printing format is affected by the current locale. | |
16 | Ensures that we always get POSIX formatting of floats. | |
17 | --- | |
18 | src/xsane-save.c | 19 +++++++++++++++++++ | |
19 | 1 file changed, 19 insertions(+) | |
20 | ||
21 | diff --git a/src/xsane-save.c b/src/xsane-save.c | |
22 | index f14df05..63550cc 100644 | |
23 | --- a/src/xsane-save.c | |
24 | +++ b/src/xsane-save.c | |
25 | @@ -26,6 +26,8 @@ | |
26 | #include "xsane-back-gtk.h" | |
27 | #include "xsane-front-gtk.h" | |
28 | #include "xsane-save.h" | |
29 | +#include <locale.h> | |
30 | +#include <string.h> | |
31 | #include <time.h> | |
32 | #include <sys/wait.h> | |
33 | ||
34 | @@ -2425,6 +2427,7 @@ static void xsane_save_ps_create_image_header(FILE *outfile, | |
35 | int flatedecode) | |
36 | { | |
37 | int depth; | |
38 | + char *save_locale; | |
39 | ||
40 | depth = image_info->depth; | |
41 | ||
42 | @@ -2442,8 +2445,15 @@ static void xsane_save_ps_create_image_header(FILE *outfile, | |
43 | ||
44 | fprintf(outfile, "%d rotate\n", degree); | |
45 | fprintf(outfile, "%d %d translate\n", position_left, position_bottom); | |
46 | + | |
47 | + save_locale = strdup(setlocale(LC_NUMERIC, NULL)); | |
48 | + setlocale(LC_NUMERIC, "POSIX"); | |
49 | + | |
50 | fprintf(outfile, "%f %f scale\n", width, height); | |
51 | ||
52 | + setlocale(LC_NUMERIC, save_locale); | |
53 | + free(save_locale); | |
54 | + | |
55 | fprintf(outfile, "<<\n"); | |
56 | fprintf(outfile, " /ImageType 1\n"); | |
57 | fprintf(outfile, " /Width %d\n", image_info->image_width); | |
58 | @@ -3921,6 +3931,7 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr | |
59 | int position_left, position_bottom, box_left, box_bottom, box_right, box_top, depth; | |
60 | int left, bottom; | |
61 | float rad; | |
62 | + char *save_locale; | |
63 | ||
64 | DBG(DBG_proc, "xsane_save_pdf_create_page_header\n"); | |
65 | ||
66 | @@ -4035,8 +4046,16 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr | |
67 | ||
68 | fprintf(outfile, "q\n"); | |
69 | fprintf(outfile, "1 0 0 1 %d %d cm\n", position_left, position_bottom); /* translate */ | |
70 | + | |
71 | + save_locale = strdup(setlocale(LC_NUMERIC, NULL)); | |
72 | + setlocale(LC_NUMERIC, "POSIX"); | |
73 | + | |
74 | fprintf(outfile, "%f %f -%f %f 0 0 cm\n", cos(rad), sin(rad), sin(rad), cos(rad)); /* rotate */ | |
75 | fprintf(outfile, "%f 0 0 %f 0 0 cm\n", width, height); /* scale */ | |
76 | + | |
77 | + setlocale(LC_NUMERIC, save_locale); | |
78 | + free(save_locale); | |
79 | + | |
80 | fprintf(outfile, "BI\n"); | |
81 | fprintf(outfile, " /W %d\n", image_info->image_width); | |
82 | fprintf(outfile, " /H %d\n", image_info->image_height); | |
83 | -- | |
84 | 2.22.0 | |
85 |