Catch more failure modes of strftime() when presented with conversion
authorTor Lillqvist <tml@novell.com>
Fri, 2 Jun 2006 12:34:06 +0000 (12:34 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Fri, 2 Jun 2006 12:34:06 +0000 (12:34 +0000)
2006-06-02  Tor Lillqvist  <tml@novell.com>

* configure.in: Catch more failure modes of strftime() when
presented with conversion specifications %l and %k: On Windows,
these just do nothing, you don't get a 'l' or 'k' in the result,
which was all we used to test for here. Catch also if strftime()
does nothing at all when presented with a format containing
unsupported conversion specifications.

* libedataserver/e-data-server-util.c (e_strftime): The Microsoft
strftime() doesn't have %e either.

ChangeLog
configure.in
libedataserver/e-data-server-util.c

index f39bc58..54da131 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-06-02  Tor Lillqvist  <tml@novell.com>
+
+       * configure.in: Catch more failure modes of strftime() when
+       presented with conversion specifications %l and %k: On Windows,
+       these just do nothing, you don't get a 'l' or 'k' in the result,
+       which was all we used to test for here. Catch also if strftime()
+       does nothing at all when presented with a format containing
+       unsupported conversion specifications.
+
+       * libedataserver/e-data-server-util.c (e_strftime): The Microsoft
+       strftime() doesn't have %e either.
+
 2006-06-01  Jeffrey Stedfast  <fejj@novell.com>
 
        * libedataserver/e-msgport.c (e_msgport_get): Loop the reads
index 657c5e1..cd06d2b 100644 (file)
@@ -335,9 +335,10 @@ int main(int argc, char **argv)
 
        time(&rawtime);
        timeinfo=localtime(&rawtime);
+       buf[0] = '\0';
        strftime(buf, 10, "%l %k", timeinfo);
 
-       if (strstr(buf, "l") || strstr(buf, "k"))
+       if (buf[0] == '\0' || buf[0] == ' ' || strstr(buf, "l") || strstr(buf, "k"))
                exit(1);
        else
                exit(0);
index 5755ba5..5bcf4c5 100644 (file)
@@ -354,6 +354,15 @@ size_t e_strftime(char *s, size_t max, const char *fmt, const struct tm *tm)
                ff = c;
        }
 
+#ifdef G_OS_WIN32
+       /* The Microsoft strftime() doesn't have %e either */
+       ff = ffmt;
+       while ((c = strstr(ff, "%e")) != NULL) {
+               c[1] = 'd';
+               ff = c;
+       }
+#endif
+
        ret = strftime(s, max, ffmt, tm);
        g_free(ffmt);
        return ret;