summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-30 15:47:23 +0000
committerManolo Gouy <Manolo>2016-03-30 15:47:23 +0000
commit2ac2b506a8ea6e0656a8bb6f81a8f0c1887256b7 (patch)
tree56e1b03c337a5d5c6b920a35a4ed7bf77ea40e3a
parentfc7b00dad8f84bf0afb58323258100b3c82321a9 (diff)
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
-rw-r--r--FL/Fl_System_Driver.H3
-rw-r--r--src/Fl_System_Driver.cxx4
-rw-r--r--src/drivers/Darwin/Fl_Darwin_System_Driver.H1
-rw-r--r--src/drivers/Darwin/Fl_Darwin_System_Driver.cxx22
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.H1
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.cxx10
-rw-r--r--src/drivers/PostScript/Fl_PostScript.cxx16
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.H1
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx10
9 files changed, 53 insertions, 15 deletions
diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H
index 0588a3b89..5599b2a83 100644
--- a/FL/Fl_System_Driver.H
+++ b/FL/Fl_System_Driver.H
@@ -118,7 +118,8 @@ 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);
-
+ // implement to shield fprintf() from locale changes in decimal point
+ virtual int clocale_printf(FILE *output, const char *format, va_list args);
};
#endif // FL_SYSTEM_DRIVER_H
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 <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$".
//