im.pidgin.pidgin: 8152fe0104bfcc5da3dda8b81badd6f63f9532b8

sadrul at pidgin.im sadrul at pidgin.im
Fri Oct 12 18:25:36 EDT 2007


-----------------------------------------------------------------
Revision: 8152fe0104bfcc5da3dda8b81badd6f63f9532b8
Ancestor: df81d122928e469dcce201911c13410548a3c450
Author: sadrul at pidgin.im
Date: 2007-10-12T22:12:29
Branch: im.pidgin.pidgin

Modified files:
        libpurple/plugins/log_reader.c

ChangeLog: 

Use functions and loops and all those fancy things.

-------------- next part --------------
============================================================
--- libpurple/plugins/log_reader.c	69bf3dc2cab0901bfcf5392bc48d9e33b30bd328
+++ libpurple/plugins/log_reader.c	94ce5d4de8a816ee88c17f9f1f4c4adc907011fc
@@ -28,7 +28,20 @@ enum name_guesses {
 	NAME_GUESS_THEM
 };
 
+/* Some common functions. */
+static int get_month(const char *month)
+{
+	int iter;
+	const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
+	for (iter = 0; months[iter]; iter++) {
+		if (strcmp(month, months[iter]) == 0)
+			break;
+	}
+	return iter;
+}
 
+
 /*****************************************************************************
  * Adium Logger                                                              *
  *****************************************************************************/
@@ -1348,37 +1361,8 @@ static GList *trillian_logger_list(Purpl
 						 * daylight savings time.
 						 */
 						tm.tm_isdst = -1;
+						tm.tm_mon = get_month(month);
 
-						/* Ugly hack, in case current locale
-						 * is not English. This code is taken
-						 * from log.c.
-						 */
-						if (strcmp(month, "Jan") == 0) {
-							tm.tm_mon= 0;
-						} else if (strcmp(month, "Feb") == 0) {
-							tm.tm_mon = 1;
-						} else if (strcmp(month, "Mar") == 0) {
-							tm.tm_mon = 2;
-						} else if (strcmp(month, "Apr") == 0) {
-							tm.tm_mon = 3;
-						} else if (strcmp(month, "May") == 0) {
-							tm.tm_mon = 4;
-						} else if (strcmp(month, "Jun") == 0) {
-							tm.tm_mon = 5;
-						} else if (strcmp(month, "Jul") == 0) {
-							tm.tm_mon = 6;
-						} else if (strcmp(month, "Aug") == 0) {
-							tm.tm_mon = 7;
-						} else if (strcmp(month, "Sep") == 0) {
-							tm.tm_mon = 8;
-						} else if (strcmp(month, "Oct") == 0) {
-							tm.tm_mon = 9;
-						} else if (strcmp(month, "Nov") == 0) {
-							tm.tm_mon = 10;
-						} else if (strcmp(month, "Dec") == 0) {
-							tm.tm_mon = 11;
-						}
-
 						data = g_new0(
 							struct trillian_logger_data, 1);
 						data->path = g_strdup(path);
@@ -2226,23 +2210,14 @@ static GList *amsn_logger_list(PurpleLog
 						                   "Error parsing start date for %s\n",
 						                   filename);
 					} else {
-						const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
-								"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
 						tm.tm_year -= 1900;
 
 						/* Let the C library deal with
 						 * daylight savings time.
 						 */
 						tm.tm_isdst = -1;
+						tm.tm_mon = get_month(month);
 
-						/* Ugly hack, in case current locale
-						 * is not English. This code is taken
-						 * from log.c.
-						 */
-						for (tm.tm_mon = 0; months[tm.tm_mon]; tm.tm_mon++) {
-							if (strcmp(month, months[tm.tm_mon]) == 0)
-								break;
-						}
 						found_start = TRUE;
 						offset = c - contents;
 						start_log = c;


More information about the Commits mailing list