From 2ac2b506a8ea6e0656a8bb6f81a8f0c1887256b7 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 30 Mar 2016 15:47:23 +0000 Subject: Begin to rewrite Fl_PostScript.cxx under the driver model. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11474 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_System_Driver.cxx | 4 ++++ src/drivers/Darwin/Fl_Darwin_System_Driver.H | 1 + src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 22 ++++++++++++++++++++++ src/drivers/Posix/Fl_Posix_System_Driver.H | 1 + src/drivers/Posix/Fl_Posix_System_Driver.cxx | 10 ++++++++++ src/drivers/PostScript/Fl_PostScript.cxx | 16 ++-------------- src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 1 + src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 10 ++++++++++ 8 files changed, 51 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Fl_System_Driver.cxx b/src/Fl_System_Driver.cxx index 4907c9c2d..686d03ecb 100644 --- a/src/Fl_System_Driver.cxx +++ b/src/Fl_System_Driver.cxx @@ -367,6 +367,10 @@ unsigned Fl_System_Driver::utf8from_mb(char* dst, unsigned dstlen, const char* s return srclen; } +int Fl_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { + return vfprintf(output, format, args); +} + // // End of "$Id$". // diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index bafa422d2..910270653 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -62,6 +62,7 @@ public: virtual int unlink(const char* f) {return ::unlink(f);} virtual int rmdir(const char* f) {return ::rmdir(f);} virtual int rename(const char* f, const char *n) {return ::rename(f, n);} + virtual int clocale_printf(FILE *output, const char *format, va_list args); }; #endif // FL_DARWIN_SYSTEM_DRIVER_H diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 590e23d0b..1430be536 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -22,6 +22,12 @@ #include #include #include +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 +#include +#else +#include +#endif +#include int Fl_X::next_marked_length = 0; @@ -90,6 +96,22 @@ int Fl_Darwin_System_Driver::compose(int &del) { return 1; } +int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if (fl_mac_os_version >= 100400) { + static locale_t postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + return vfprintf_l(output, postscript_locale, format, args); + } +#else + char *saved_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); + int retval = vfprintf(output, format, args); + setlocale(LC_NUMERIC, saved_locale); + return retval; +#endif +} + + // // End of "$Id$". // diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.H b/src/drivers/Posix/Fl_Posix_System_Driver.H index 765d1100c..dc5fe83a2 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.H +++ b/src/drivers/Posix/Fl_Posix_System_Driver.H @@ -63,6 +63,7 @@ public: virtual int unlink(const char* f) {return ::unlink(f);} virtual int rmdir(const char* f) {return ::rmdir(f);} virtual int rename(const char* f, const char *n) {return ::rename(f, n);} + virtual int clocale_printf(FILE *output, const char *format, va_list args); }; #endif // FL_POSIX_SYSTEM_DRIVER_H diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx index ee3c70fe4..2d7abb575 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx @@ -20,6 +20,11 @@ #include "Fl_Posix_System_Driver.H" #include #include +#include +#include +#ifdef __APPLE_CC__ // allows Darwin + X11 +#include +#endif extern XIC fl_xim_ic; // in Fl_x.cxx @@ -63,6 +68,11 @@ void Fl_Posix_System_Driver::compose_reset() if (fl_xim_ic) XmbResetIC(fl_xim_ic); } +int Fl_Posix_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { + static locale_t postscript_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); + return vfprintf_l(output, postscript_locale, format, args); +} + // // End of "$Id$". // diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 2de4ba543..003f39807 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -24,8 +24,8 @@ #include #include #include +#include #include -#include #if defined(USE_X11) #include #if USE_XFT @@ -151,23 +151,11 @@ Fl_PostScript_File_Device::~Fl_PostScript_File_Device() { */ int Fl_PostScript_Graphics_Driver::clocale_printf(const char *format, ...) { -#ifdef FL_PORTING -# pragma message "FL_PORTING: must define LC_NUMERIC" va_list args; va_start(args, format); - int retval = vfprintf(output, format, args); + int retval = Fl_System_Driver::driver()->clocale_printf(output, format, args); va_end(args); return retval; -#else - char *saved_locale = setlocale(LC_NUMERIC, NULL); - setlocale(LC_NUMERIC, "C"); - va_list args; - va_start(args, format); - int retval = vfprintf(output, format, args); - va_end(args); - setlocale(LC_NUMERIC, saved_locale); - return retval; -#endif } #ifndef FL_DOXYGEN diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index dc7e20fc6..67684dc07 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -66,6 +66,7 @@ public: virtual int utf8locale(); virtual unsigned utf8to_mb(const char* src, unsigned srclen, char* dst, unsigned dstlen); virtual unsigned utf8from_mb(char* dst, unsigned dstlen, const char* src, unsigned srclen); + virtual int clocale_printf(FILE *output, const char *format, va_list args); }; #endif // FL_WINAPI_SYSTEM_DRIVER_H diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index acb0cc565..13e74914f 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -22,9 +22,11 @@ #include #include #include +#include #include #include #include +#include #if !defined(FL_DOXYGEN) const char* fl_local_alt = "Alt"; @@ -430,6 +432,14 @@ unsigned Fl_WinAPI_System_Driver::utf8from_mb(char* dst, unsigned dstlen, const return ret; } +int Fl_WinAPI_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { + char *saved_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); + int retval = vfprintf(output, format, args); + setlocale(LC_NUMERIC, saved_locale); + return retval; +} + // // End of "$Id$". // -- cgit v1.2.3