From 77027331dec11dc8bbdddf5f1dbe568de2286fd3 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 10 Apr 2006 23:16:38 +0000 Subject: [Win32] Instead of %l (which is a GNU extension not implemented in the 2006-03-27 Tor Lillqvist * e-util.c (fix_percent_l): [Win32] Instead of %l (which is a GNU extension not implemented in the Microsoft C library) use %I. Fixes #336055. (e_strftime_fix_am_pm): Call fix_percent_l() when necessary. svn path=/trunk/; revision=31807 --- e-util/ChangeLog | 7 +++++++ e-util/e-util.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'e-util') diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 5b4551ffb9..09a90bfe8e 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,10 @@ +2006-03-27 Tor Lillqvist + + * e-util.c (fix_percent_l): [Win32] Instead of %l (which is a GNU + extension not implemented in the Microsoft C library) use %I. + Fixes #336055. + (e_strftime_fix_am_pm): Call fix_percent_l() when necessary. + 2006-02-12 Karsten Bräckelmann * e-error.c (e_error_newv): diff --git a/e-util/e-util.c b/e-util/e-util.c index d364a06ec9..73a1842919 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -679,6 +679,24 @@ e_sort (void *base, #endif } +#ifdef G_OS_WIN32 +static void +fix_percent_l(const char **fmt, char **newfmt) +{ + /* %l is not implemented in the Microsoft C library. Use %I + * instead. Don't bother that we get a leading zero instead of + * leading blank for hours 0..9. + */ + if (strstr(*fmt, "%l")!=NULL) { + char *p; + *newfmt=g_strdup(*fmt); + p=strstr(*newfmt, "%l"); + p[1]='I'; + *fmt=*newfmt; + } +} +#endif + /** * Function to do a last minute fixup of the AM/PM stuff if the locale * and gettext haven't done it right. Most English speaking countries @@ -703,9 +721,15 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t char *sp; char *ffmt; size_t ret; +#ifdef G_OS_WIN32 + char *newfmt=NULL; +#endif if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) { /* No AM/PM involved - can use the fmt string directly */ +#ifdef G_OS_WIN32 + fix_percent_l(&fmt, &newfmt); +#endif ret=e_strftime(s, max, fmt, tm); } else { /* Get the AM/PM symbol from the locale */ @@ -716,6 +740,9 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t * AM/PM have been defined in the locale * so we can use the fmt string directly **/ +#ifdef G_OS_WIN32 + fix_percent_l(&fmt, &newfmt); +#endif ret=e_strftime(s, max, fmt, tm); } else { /** @@ -737,6 +764,9 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t g_free(ffmt); } } +#ifdef G_OS_WIN32 + g_free(newfmt); +#endif return(ret); } -- cgit v1.2.3