diff -r 721fb658ee46 -r 2e75223c078e pidgin/gtkconv.c --- a/pidgin/gtkconv.c Thu Jun 14 18:31:26 2012 -0400 +++ b/pidgin/gtkconv.c Fri Jun 15 00:23:44 2012 -0400 @@ -5088,6 +5088,7 @@ str = g_string_new(NULL); while ((cur = strchr(cur, '%'))) { + char *freeval = NULL; const char *replace = NULL; const char *fin = NULL; @@ -5117,7 +5118,6 @@ } else if (g_str_has_prefix(cur, "%timeOpened")) { const char *tmp = cur + strlen("%timeOpened"); - char *format = NULL; if (*tmp == '{') { const char *end; @@ -5125,18 +5125,21 @@ end = strstr(tmp, "}%"); if (!end) /* Invalid string */ continue; - format = g_strndup(tmp, end - tmp); + if (!tm) { + mtime = time(NULL); + tm = localtime(&mtime); + } + replace = freeval = purple_uts35_to_str(tmp, end - tmp, tm); fin = end + 1; + } else { + if (!tm) { + mtime = time(NULL); + tm = localtime(&mtime); + } + + replace = purple_utf8_strftime("%X", tm); } - if (!tm) { - mtime = time(NULL); - tm = localtime(&mtime); - } - - replace = purple_utf8_strftime(format ? format : "%X", tm); - g_free(format); - } else if (g_str_has_prefix(cur, "%dateOpened%")) { if (!tm) { mtime = time(NULL); @@ -5161,6 +5164,8 @@ } else { prev = cur = strchr(cur + 1, '%') + 1; } + g_free(freeval); + freeval = NULL; } /* And wrap it up */ @@ -6190,7 +6195,6 @@ } else if (g_str_has_prefix(cur, "%time")) { const char *tmp = cur + strlen("%time"); - char *format = NULL; if (*tmp == '{') { char *end; @@ -6198,16 +6202,17 @@ end = strstr(tmp, "}%"); if (!end) /* Invalid string */ continue; - format = g_strndup(tmp, end - tmp); + if (!tm) + tm = localtime(&mtime); + replace = freeval = purple_uts35_to_str(tmp, end - tmp, tm); fin = end + 1; + } else { + if (!tm) + tm = localtime(&mtime); + + replace = purple_utf8_strftime("%X", tm); } - if (!tm) - tm = localtime(&mtime); - - replace = purple_utf8_strftime(format ? format : "%X", tm); - g_free(format); - } else if (g_str_has_prefix(cur, "%shortTime%")) { if (!tm) tm = localtime(&mtime);