Mercurial > pidgin
changeset 10636:0f5c5e6fb27f
[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 <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 24 Feb 2005 01:11:17 +0000 |
parents | 6895c4212362 |
children | 43194088f3f7 |
files | src/gtklog.c src/protocols/oscar/oscar.c src/util.c src/util.h |
diffstat | 4 files changed, 25 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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<br>", _("Birthday"), date); } if (info->age) {
--- 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
--- 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); + /*@}*/