summaryrefslogtreecommitdiff
path: root/debian/patches/21_gutenprintui_plist_localefix.dpatch
blob: e55c07a9fadb52531e8901773636e95e918228bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#! /bin/sh /usr/share/dpatch/dpatch-run
## 21_gutenprintui_plist_localefix.dpatch.dpatch by  <Roger Leigh <rleigh@debian.org>>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Set locale to C before executing lpr to get non-localised output

@DPATCH@

diff -urN gutenprint-5.0.2.original/src/gutenprintui/plist.c gutenprint-5.0.2/src/gutenprintui/plist.c
--- gutenprint-5.0.2.original/src/gutenprintui/plist.c	2007-12-15 20:35:42.000000000 +0000
+++ gutenprint-5.0.2/src/gutenprintui/plist.c	2008-01-06 00:21:35.255869419 +0000
@@ -1,5 +1,5 @@
 /*
- * "$Id: plist.c,v 1.3.6.2 2007/12/15 20:35:42 rlk Exp $"
+ * "$Id: plist.c,v 1.3.6.3 2008/01/05 22:32:28 rlk Exp $"
  *
  *   Print plug-in for the GIMP.
  *
@@ -41,7 +41,6 @@
 #include <signal.h>
 #include <sys/wait.h>
 
-
 typedef enum
 {
   PRINTERS_NONE,
@@ -347,7 +346,7 @@
 static void
 stpui_errfunc(void *file, const char *buf, size_t bytes)
 {
-  g_message(buf);
+  g_message("%s",buf);
 }
 
 void
@@ -966,9 +965,15 @@
   yyin = fp;
 
   stpui_printrc_current_printer = NULL;
-  setlocale(LC_ALL, "C");
+#ifdef HAVE_LOCALE_H
+  locale = g_strdup(setlocale(LC_NUMERIC, NULL));
+  setlocale(LC_NUMERIC, "C");
+#endif
   retval = yyparse();
-  setlocale(LC_ALL, "");
+#ifdef HAVE_LOCALE_H
+  setlocale(LC_NUMERIC, locale);
+  SAFE_FREE(locale);
+#endif
   if (stpui_printrc_current_printer)
     {
       int i;
@@ -1010,17 +1015,23 @@
       (void) memset(line, 0, 1024);
       if (fgets(line, sizeof(line), fp) != NULL)
 	{
-	  /* Force locale to "C", so that numbers scan correctly */
-	  setlocale(LC_ALL, "C");
+#ifdef HAVE_LOCALE_H
+	  char *locale = g_strdup(setlocale(LC_NUMERIC, NULL));
+	  setlocale(LC_NUMERIC, "C");
+#endif
 	  if (strncmp("#PRINTRCv", line, 9) == 0)
 	    {
+	      /* Force locale to "C", so that numbers scan correctly */
 #ifdef DEBUG
 	      fprintf(stderr, "Found printrc version tag: `%s'\n", line);
 	      fprintf(stderr, "Version number: `%s'\n", &(line[9]));
 #endif
 	      (void) sscanf(&(line[9]), "%d", &format);
 	    }
-	  setlocale(LC_ALL, "");
+#ifdef HAVE_LOCALE_H
+	  setlocale(LC_NUMERIC, locale);
+	  SAFE_FREE(locale);
+#endif
 	}
       rewind(fp);
       switch (format)
@@ -1063,7 +1074,10 @@
        */
 
       /* Force locale to "C", so that numbers print correctly */
-      setlocale(LC_ALL, "C");
+#ifdef HAVE_LOCALE_H
+      char *locale = g_strdup(setlocale(LC_NUMERIC, NULL));
+      setlocale(LC_NUMERIC, "C");
+#endif
 #ifdef DEBUG
       fprintf(stderr, "Number of printers: %d\n", stpui_plist_count);
 #endif
@@ -1198,7 +1212,10 @@
 	  fprintf(stderr, "Wrote printer %d: %s\n", i, p->name);
 #endif
 	}
-      setlocale(LC_ALL, "");
+#ifdef HAVE_LOCALE_H
+      setlocale(LC_NUMERIC, locale);
+      SAFE_FREE(locale);
+#endif
       fclose(fp);
     }
   else
@@ -1236,6 +1253,8 @@
   identify_print_system();
   if (global_printing_system)
   {
+    const char *old_locale = getenv("LC_ALL");
+    (void) setenv("LC_ALL", "C", 1);
     if ((pfile = popen(global_printing_system->scan_command, "r")) != NULL)
     {
      /*
@@ -1257,6 +1276,10 @@
 	    }
 	}
       pclose(pfile);
+      if (old_locale)
+	setenv("LC_ALL", old_locale, 1);
+      else
+	unsetenv("LC_ALL");
     }
   }
 }
@@ -1597,6 +1620,7 @@
 		      else	/* Child 2 (printer command) */
 			{
 			  char *command;
+			  char *locale;
 			  if (stpui_plist_get_command_type(printer) ==
 			      COMMAND_TYPE_DEFAULT)
 			    {
@@ -1616,6 +1640,10 @@
 			  close (pipefd[0]);
 			  close (pipefd[1]);
 			  close(syncfd[1]);
+#ifdef HAVE_LOCALE_H
+			  locale = g_strdup(setlocale(LC_NUMERIC, NULL));
+			  setlocale(LC_NUMERIC, "C");
+#endif
 			  execl("/bin/sh", "/bin/sh", "-c", command, NULL);
 			  /* NOTREACHED */
 			  _exit (1);
@@ -1789,5 +1817,5 @@
 }
 
 /*
- * End of "$Id: plist.c,v 1.3.6.2 2007/12/15 20:35:42 rlk Exp $".
+ * End of "$Id: plist.c,v 1.3.6.3 2008/01/05 22:32:28 rlk Exp $".
  */
diff -urN gutenprint-5.0.2.original/src/gutenprintui2/plist.c gutenprint-5.0.2/src/gutenprintui2/plist.c
--- gutenprint-5.0.2.original/src/gutenprintui2/plist.c	2008-01-02 02:29:07.000000000 +0000
+++ gutenprint-5.0.2/src/gutenprintui2/plist.c	2008-01-06 00:21:32.090778572 +0000
@@ -1,5 +1,5 @@
 /*
- * "$Id: plist.c,v 1.6.10.4 2007/12/15 20:35:43 rlk Exp $"
+ * "$Id: plist.c,v 1.6.10.5 2008/01/05 22:32:28 rlk Exp $"
  *
  *   Print plug-in for the GIMP.
  *
@@ -1623,6 +1623,7 @@
 		      else	/* Child 2 (printer command) */
 			{
 			  char *command;
+			  char *locale;
 			  if (stpui_plist_get_command_type(printer) ==
 			      COMMAND_TYPE_DEFAULT)
 			    {
@@ -1642,6 +1643,10 @@
 			  close (pipefd[0]);
 			  close (pipefd[1]);
 			  close(syncfd[1]);
+#ifdef HAVE_LOCALE_H
+			  locale = g_strdup(setlocale(LC_NUMERIC, NULL));
+			  setlocale(LC_NUMERIC, "C");
+#endif
 			  execl("/bin/sh", "/bin/sh", "-c", command, NULL);
 			  /* NOTREACHED */
 			  _exit (1);
@@ -1815,5 +1820,5 @@
 }
 
 /*
- * End of "$Id: plist.c,v 1.6.10.4 2007/12/15 20:35:43 rlk Exp $".
+ * End of "$Id: plist.c,v 1.6.10.5 2008/01/05 22:32:28 rlk Exp $".
  */