# HG changeset patch # User Sean Egan # Date 1109207477 0 # Node ID 0f5c5e6fb27f3a8ca9b7cababda34556fcccdfd6 # Parent 6895c421236201f23bb3c05feb613961eddfa0f9 [gaim-migrate @ 12118] The strftime warnings fiunally got to me, so I made gaim_strftime to work around it. Turns out KingAnt had already discovered this solution for oscar.c but left it #iffed out. committer: Tailor Script diff -r 6895c4212362 -r 0f5c5e6fb27f src/gtklog.c --- a/src/gtklog.c Wed Feb 23 23:39:59 2005 +0000 +++ b/src/gtklog.c Thu Feb 24 01:11:17 2005 +0000 @@ -32,6 +32,7 @@ #include "gtklog.h" #include "gtkutils.h" #include "log.h" +#include "util.h" static GHashTable *log_viewers = NULL; static void populate_log_tree(GaimGtkLogViewer *lv); @@ -96,7 +97,7 @@ GaimLog *log = logs->data; char title[64]; char *title_utf8; /* temporary variable for utf8 conversion */ - strftime(title, sizeof(title), "%c", localtime(&log->time)); + gaim_strftime(title, sizeof(title), "%c", localtime(&log->time)); title_utf8 = gaim_utf8_try_convert(title); strncpy(title, title_utf8, sizeof(title)); g_free(title_utf8); @@ -183,7 +184,7 @@ read = gaim_log_read(log, &flags); viewer->flags = flags; - strftime(time, sizeof(time), "%c", localtime(&log->time)); + gaim_strftime(time, sizeof(time), "%c", localtime(&log->time)); title = g_strdup_printf("%s - %s", log->name, time); title_utf8 = gaim_utf8_try_convert(title); g_free(title); @@ -223,8 +224,8 @@ while (logs) { GaimLog *log = logs->data; - strftime(month, sizeof(month), "%B %Y", localtime(&log->time)); - strftime(title, sizeof(title), "%c", localtime(&log->time)); + gaim_strftime(month, sizeof(month), "%B %Y", localtime(&log->time)); + gaim_strftime(title, sizeof(title), "%c", localtime(&log->time)); /* do utf8 conversions */ utf8_tmp = gaim_utf8_try_convert(month); diff -r 6895c4212362 -r 0f5c5e6fb27f src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Wed Feb 23 23:39:59 2005 +0000 +++ b/src/protocols/oscar/oscar.c Thu Feb 24 01:11:17 2005 +0000 @@ -5157,6 +5157,13 @@ { return strftime(s, max, fmt, tm); } + +/* + * Before even realizing this was here, I went and did the same thing in util.c. + * + * Use gaim_strftime() + */ + #endif static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) @@ -5220,7 +5227,7 @@ tm.tm_mday = (int)info->birthday; tm.tm_mon = (int)info->birthmonth-1; tm.tm_year = (int)info->birthyear-1900; - strftime(date, sizeof(date), "%x", &tm); + gaim_strftime(date, sizeof(date), "%x", &tm); oscar_string_append(str, "\n
", _("Birthday"), date); } if (info->age) { diff -r 6895c4212362 -r 0f5c5e6fb27f src/util.c --- a/src/util.c Wed Feb 23 23:39:59 2005 +0000 +++ b/src/util.c Thu Feb 24 01:11:17 2005 +0000 @@ -573,6 +573,10 @@ return retval; } +size_t gaim_strftime(char *s, size_t max, const char *format, const struct tm *tm) +{ + return strftime(s, max, format, tm); +} /************************************************************************** * Markup Functions diff -r 6895c4212362 -r 0f5c5e6fb27f src/util.h --- a/src/util.h Wed Feb 23 23:39:59 2005 +0000 +++ b/src/util.h Thu Feb 24 01:11:17 2005 +0000 @@ -194,6 +194,14 @@ */ time_t gaim_str_to_time(const char *timestamp, gboolean utc); +/** + * Creates a string according to a time and format string + * + * This function just calls strftime. The only advantage to using it + * is that gcc won't give a warning if you use %c + */ +size_t gaim_strftime(char *s, size_t max, const char *format, const struct tm *tm); + /*@}*/