diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index ec4dc174cf9..2893c92d30f 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -21,6 +21,7 @@ #include #include +#include #include "windef.h" #include "winbase.h" @@ -87,6 +88,7 @@ static const PSDRV_DEVMODE DefaultDevmode = HINSTANCE PSDRV_hInstance = 0; HANDLE PSDRV_Heap = 0; +_locale_t c_locale; static BOOL import_ntf_from_reg(void) { @@ -294,6 +296,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { PSDRV_hInstance = hinst; DisableThreadLibraryCalls(hinst); + c_locale = _create_locale( LC_ALL, "C" ); if (__wine_init_unix_call()) return FALSE; @@ -319,6 +322,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) case DLL_PROCESS_DETACH: if (reserved) break; WINE_UNIX_CALL(unix_free_printer_info, NULL); + _free_locale( c_locale ); HeapDestroy( PSDRV_Heap ); break; } diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c index d116f8ebbc0..a1f66cd27b5 100644 --- a/dlls/wineps.drv/ppd.c +++ b/dlls/wineps.drv/ppd.c @@ -884,10 +884,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer ) #define PIA page->ImageableArea if(!PIA) { PIA = HeapAlloc( PSDRV_Heap, 0, sizeof(*PIA) ); - push_lc_numeric("C"); - sscanf(tuple.value, "%f%f%f%f", &PIA->llx, &PIA->lly, - &PIA->urx, &PIA->ury); - pop_lc_numeric(); + _sscanf_l(tuple.value, "%f%f%f%f", c_locale, &PIA->llx, &PIA->lly, &PIA->urx, &PIA->ury); } #undef PIA } @@ -908,9 +905,7 @@ PPD *PSDRV_ParsePPD( const WCHAR *fname, HANDLE printer ) #define PD page->PaperDimension if(!PD) { PD = HeapAlloc( PSDRV_Heap, 0, sizeof(*PD) ); - push_lc_numeric("C"); - sscanf(tuple.value, "%f%f", &PD->x, &PD->y); - pop_lc_numeric(); + _sscanf_l(tuple.value, "%f%f", c_locale, &PD->x, &PD->y); } #undef PD } diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 8e52a97867a..7a8feeaedb8 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -625,9 +625,7 @@ BOOL PSDRV_WriteArc(print_ctx *ctx, INT x, INT y, INT w, INT h, double ang1, /* 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(); + _sprintf_l(buf, psarc, c_locale, x, y, w, h, -ang2, -ang1); return PSDRV_WriteSpool(ctx, buf, strlen(buf)); } @@ -678,16 +676,11 @@ BOOL PSDRV_WriteSetColor(print_ctx *ctx, PSCOLOR *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(); + _sprintf_l(buf, pssetrgbcolor, c_locale, color->value.rgb.r, color->value.rgb.g, color->value.rgb.b); return PSDRV_WriteSpool(ctx, buf, strlen(buf)); case PSCOLOR_GRAY: - push_lc_numeric("C"); - sprintf(buf, pssetgray, color->value.gray.i); - pop_lc_numeric(); + _sprintf_l(buf, pssetgray, c_locale, color->value.gray.i); return PSDRV_WriteSpool(ctx, buf, strlen(buf)); default: @@ -786,9 +779,7 @@ BOOL PSDRV_WriteRotate(print_ctx *ctx, float ang) { char buf[256]; - push_lc_numeric("C"); - sprintf(buf, psrotate, ang); - pop_lc_numeric(); + _sprintf_l(buf, psrotate, c_locale, ang); return PSDRV_WriteSpool(ctx, buf, strlen(buf)); } diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 2c4703de942..c69b2994479 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -544,13 +544,7 @@ extern DWORD ASCII85_encode(BYTE *in_buf, DWORD len, BYTE *out_buf); extern void passthrough_enter(print_ctx *ctx); extern void passthrough_leave(print_ctx *ctx); -#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) +extern _locale_t c_locale; static inline WCHAR *strdupW( const WCHAR *str ) { diff --git a/dlls/wineps.drv/type42.c b/dlls/wineps.drv/type42.c index 0867881b68e..4f598962b73 100644 --- a/dlls/wineps.drv/type42.c +++ b/dlls/wineps.drv/type42.c @@ -203,11 +203,9 @@ TYPE42 *T42_download_header(print_ctx *ctx, char *ps_name, 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(); + _sprintf_l(buf, start, c_locale, ps_name, + (float)bbox->left / emsize, (float)bbox->bottom / emsize, + (float)bbox->right / emsize, (float)bbox->top / emsize); PSDRV_WriteSpool(ctx, buf, strlen(buf));