diff options
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 22 | ||||
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_System_Driver.cxx | 10 | ||||
| -rw-r--r-- | src/drivers/PostScript/Fl_PostScript.cxx | 16 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 10 |
7 files changed, 47 insertions, 14 deletions
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 <FL/Fl.H> #include <FL/x.H> #include <string.h> +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 +#include <xlocale.h> +#else +#include <locale.h> +#endif +#include <stdio.h> 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 <FL/Fl.H> #include <X11/Xlib.h> +#include <locale.h> +#include <stdio.h> +#ifdef __APPLE_CC__ // allows Darwin + X11 +#include <xlocale.h> +#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 <stdio.h> #include <FL/Fl_PostScript.H> #include <FL/Fl_Native_File_Chooser.H> +#include <FL/Fl_System_Driver.H> #include <stdarg.h> -#include <locale.h> #if defined(USE_X11) #include <src/Fl_Font.H> #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 <FL/Fl.H> #include <FL/fl_utf8.h> #include <stdio.h> +#include <stdarg.h> #include <windows.h> #include <wchar.h> #include <process.h> +#include <locale.h> #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$". // |
