PATCH: un-localize postscript output

Marcus Meissner marcus at jet.franken.de
Sun Oct 3 07:03:36 CDT 2004


Hi,

The postscript output engine is using sprintf(), which if LC_NUMERIC usage
is enabled in the program (coming from sublibraries or from ourselves)
generated "0,00 setgray" instead of "0.00 setgray" with LANG=de_DE.utf-8
in FrameMaker 7.

This patch fixes the float printfs.
I am not sure whether the %d integer printfs are affected too but I am guessing
yes.

Ciao, Marcus

Changelog:
	Make sure PostScript floats are printed with LC_NUMERIC="C".

Index: dlls/wineps/ps.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/ps.c,v
retrieving revision 1.28
diff -u -r1.28 ps.c
--- dlls/wineps/ps.c	22 Sep 2004 02:46:39 -0000	1.28
+++ dlls/wineps/ps.c	3 Oct 2004 10:18:12 -0000
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+#include <locale.h>
 
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
@@ -469,7 +470,9 @@
 
     /* Make angles -ve and swap order because we're working with an upside
        down y-axis */
+    push_lc_numeric("C");
     sprintf(buf, psarc, x, y, w, h, -ang2, -ang1);
+    pop_lc_numeric();
     return PSDRV_WriteSpool(physDev, buf, strlen(buf));
 }
 
@@ -500,12 +503,16 @@
     PSDRV_CopyColor(&physDev->inkColor, color);
     switch(color->type) {
     case PSCOLOR_RGB:
+        push_lc_numeric("C");
         sprintf(buf, pssetrgbcolor, color->value.rgb.r, color->value.rgb.g,
 		color->value.rgb.b);
+        pop_lc_numeric();
 	return PSDRV_WriteSpool(physDev, buf, strlen(buf));
 
     case PSCOLOR_GRAY:
+        push_lc_numeric("C");
         sprintf(buf, pssetgray, color->value.gray.i);
+        pop_lc_numeric();
 	return PSDRV_WriteSpool(physDev, buf, strlen(buf));
 
     default:
@@ -604,7 +611,9 @@
 {
     char buf[256];
 
+    push_lc_numeric("C");
     sprintf(buf, psrotate, ang);
+    pop_lc_numeric();
     return PSDRV_WriteSpool(physDev, buf, strlen(buf));
 }
 
Index: dlls/wineps/psdrv.h
===================================================================
RCS file: /home/wine/wine/dlls/wineps/psdrv.h,v
retrieving revision 1.52
diff -u -r1.52 psdrv.h
--- dlls/wineps/psdrv.h	4 May 2004 04:13:06 -0000	1.52
+++ dlls/wineps/psdrv.h	3 Oct 2004 10:18:12 -0000
@@ -549,4 +549,13 @@
 extern DWORD RLE_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
 extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf);
 
+#define push_lc_numeric(x) do {					\
+	const char *tmplocale = setlocale(LC_NUMERIC,NULL);	\
+	setlocale(LC_NUMERIC,x);
+
+#define pop_lc_numeric()					\
+	setlocale(LC_NUMERIC,tmplocale);			\
+} while (0)
+
+
 #endif
Index: dlls/wineps/type42.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/type42.c,v
retrieving revision 1.11
diff -u -r1.11 type42.c
--- dlls/wineps/type42.c	22 Sep 2004 02:46:39 -0000	1.11
+++ dlls/wineps/type42.c	3 Oct 2004 10:18:12 -0000
@@ -26,6 +26,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <assert.h>
+#include <locale.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -199,9 +200,11 @@
     buf = HeapAlloc(GetProcessHeap(), 0, sizeof(start) + strlen(ps_name) +
 		    100);
 
+    push_lc_numeric("C");
     sprintf(buf, start, ps_name,
 	    (float)bbox->left / emsize, (float)bbox->bottom / emsize,
 	    (float)bbox->right / emsize, (float)bbox->top / emsize);
+    pop_lc_numeric();
 
     PSDRV_WriteSpool(physDev, buf, strlen(buf));
 
-- 



More information about the wine-patches mailing list