diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-01-19 16:08:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-19 16:08:29 +0100 |
| commit | 09eff7243a6e8e37d9615df7b951ffa3c03c0ae2 (patch) | |
| tree | 513b39c92f1f6a9d0f0ca7f9a1488f298f7a068e /src/drivers/WinAPI | |
| parent | 793f4b90fac349b096922a6b90ae2731777ac6cf (diff) | |
Fixing and upgrading Fl_Preferences (#374)
* Added filename function to Fl_Preferences
Static function to get filename before opening.
Member to get filename after opening.
Bug fixes for memory mapped preferences.
* ERROR is a macro on Windows, don't use it
* Added Fl_Preferences::dirty().
User can now check if the database will be written
when flushed or destroyed.
Flush returns a crude error code.
* Fl_Preferences::get binary data returns # of bytes read.
* Verified group deletion code
* Fl_Preferences ignores locale.
This will make .prefs files interchangeable
between different computers.
* Updating the Preferences Mode to ignore locale.
* Fixes in docs.
Diffstat (limited to 'src/drivers/WinAPI')
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 41 |
2 files changed, 41 insertions, 2 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index a31d5248b..60dca9d17 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -67,6 +67,8 @@ public: 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); + virtual int clocale_snprintf(char *output, size_t output_size, const char *format, va_list args); + virtual int clocale_sscanf(const char *input, const char *format, va_list args); // these 2 are in Fl_get_key_win32.cxx virtual int event_key(int k); virtual int get_key(int k); diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index a869b8ca0..e88ac8e9b 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -455,9 +455,14 @@ unsigned Fl_WinAPI_System_Driver::utf8from_mb(char *dst, unsigned dstlen, const return ret; } +#if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) +static _locale_t c_locale = NULL; +#endif + int Fl_WinAPI_System_Driver::clocale_printf(FILE *output, const char *format, va_list args) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) - static _locale_t c_locale = _create_locale(LC_NUMERIC, "C"); + if (!c_locale) + c_locale = _create_locale(LC_NUMERIC, "C"); int retval = _vfprintf_l(output, format, c_locale, args); #else char *saved_locale = setlocale(LC_NUMERIC, NULL); @@ -468,6 +473,35 @@ int Fl_WinAPI_System_Driver::clocale_printf(FILE *output, const char *format, va return retval; } +int Fl_WinAPI_System_Driver::clocale_snprintf(char *output, size_t output_size, const char *format, va_list args) { +#if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) + if (!c_locale) + c_locale = _create_locale(LC_NUMERIC, "C"); + int retval = _vsnprintf_l(output, output_size, format, c_locale, args); +#else + char *saved_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); + int retval = vsnprintf(output, output_size, format, args); + setlocale(LC_NUMERIC, saved_locale); +#endif + return retval; +} + +int Fl_WinAPI_System_Driver::clocale_sscanf(const char *input, const char *format, va_list args) { +#if defined(_MSC_VER) && (_MSC_VER >= 1400 /*Visual Studio 2005*/) + if (!c_locale) + c_locale = _create_locale(LC_NUMERIC, "C"); + int retval = _vsscanf_l(input, format, c_locale, args); +#else + char *saved_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); + int retval = vsscanf(input, format, args); + setlocale(LC_NUMERIC, saved_locale); +#endif + return retval; +} + + int Fl_WinAPI_System_Driver::filename_list(const char *d, dirent ***list, int (*sort)(struct dirent **, struct dirent **), char *errmsg, int errmsg_sz) { @@ -814,7 +848,10 @@ void Fl_WinAPI_System_Driver::newUUID(char *uuidBuffer) } } -char *Fl_WinAPI_System_Driver::preference_rootnode(Fl_Preferences *prefs, Fl_Preferences::Root root, const char *vendor, +/* + Note: `prefs` can be NULL! + */ +char *Fl_WinAPI_System_Driver::preference_rootnode(Fl_Preferences * /*prefs*/, Fl_Preferences::Root root, const char *vendor, const char *application) { # define FLPREFS_RESOURCE "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" |
