changeset 9716:8158d148b3c2

[gaim-migrate @ 10577] Changed the use of localtime_r to localtime in util.c Also changed some spaces to tabs committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 08 Aug 2004 14:06:58 +0000
parents b030f83693da
children f105bc0270c7
files src/about.c src/util.c
diffstat 2 files changed, 67 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/src/about.c	Sun Aug 08 08:17:38 2004 +0000
+++ b/src/about.c	Sun Aug 08 14:06:58 2004 +0000
@@ -22,10 +22,12 @@
  */
 
 #include "internal.h"
+#include "gtkinternal.h"
+
+#include "gtkdialogs.h"
 #include "gtkimhtml.h"
 #include "gtkutils.h"
 #include "stock.h"
-#include "gtkdialogs.h"
 
 /* XXX For WEBSITE */
 #include "gaim.h"
@@ -34,7 +36,7 @@
 
 static void destroy_about()
 {
-	if (about)
+	if (about != NULL)
 		gtk_widget_destroy(about);
 	about = NULL;
 }
@@ -52,8 +54,10 @@
 	GtkTextIter iter;
 	char *str, *labeltext;
 
-	if (about != NULL)
+	if (about != NULL) {
+		gtk_window_present(GTK_WINDOW(about));
 		return;
+	}
 
 	GAIM_DIALOG(about);
 	gtk_window_set_default_size(GTK_WINDOW(about), 450, -1);
--- a/src/util.c	Sun Aug 08 08:17:38 2004 +0000
+++ b/src/util.c	Sun Aug 08 14:06:58 2004 +0000
@@ -22,10 +22,6 @@
  */
 #include "internal.h"
 
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
 #include "conversation.h"
 #include "debug.h"
 #include "prpl.h"
@@ -508,81 +504,75 @@
 time_t
 gaim_str_to_time(const char *timestamp, gboolean utc)
 {
-    struct tm t;
-    time_t retval = 0;
-    char buf[32];
-    char *c;
-    int tzoff = 0;
-
-    time(&retval);
-    localtime_r(&retval, &t);
-
-    snprintf(buf, sizeof(buf), "%s", timestamp);
-    c = buf;
-
-    /* 4 digit year */
-    if(!sscanf(c, "%04d", &t.tm_year)) return 0;
-    c+=4;
-    if(*c == '-')
-        c++;
-
-	t.tm_year -= 1900;
+	struct tm *t;
+	time_t retval = 0;
+	char buf[32];
+	char *c;
+	int tzoff = 0;
+
+	time(&retval);
+	t = localtime(&retval);
+
+	snprintf(buf, sizeof(buf), "%s", timestamp);
+	c = buf;
+
+	/* 4 digit year */
+	if (!sscanf(c, "%04d", &t->tm_year)) return 0;
+	c += 4;
+	if (*c == '-')
+		c++;
+
+	t->tm_year -= 1900;
 
 	/* 2 digit month */
-	if(!sscanf(c, "%02d", &t.tm_mon)) return 0;
-	c+=2;
-	if(*c == '-')
+	if (!sscanf(c, "%02d", &t->tm_mon)) return 0;
+	c += 2;
+	if (*c == '-')
 		c++;
 
-    t.tm_mon -= 1;
-
-
-    /* 2 digit day */
-    if(!sscanf(c, "%02d", &t.tm_mday)) return 0;
-    c+=2;
-    if(*c == 'T' || *c == '.') { /* we have more than a date, keep going */
-        c++; /* skip the "T" */
-
-        /* 2 digit hour */
-        if(sscanf(c, "%02d:%02d:%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3 ||
-				sscanf(c, "%02d%02d%02d", &t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
-            int tzhrs, tzmins;
-            c+=8;
-            if(*c == '.') /* dealing with precision we don't care about */
-                c += 4;
-
-            if((*c == '+' || *c == '-') &&
-                    sscanf(c+1, "%02d:%02d", &tzhrs, &tzmins)) {
-                tzoff = tzhrs*60*60 + tzmins*60;
-                if(*c == '+')
-                    tzoff *= -1;
-            }
-
-			if(tzoff || utc) {
-
+	t->tm_mon -= 1;
+
+	/* 2 digit day */
+	if (!sscanf(c, "%02d", &t->tm_mday)) return 0;
+	c += 2;
+	if (*c == 'T' || *c == '.') { /* we have more than a date, keep going */
+	c++; /* skip the "T" */
+
+	/* 2 digit hour */
+	if (sscanf(c, "%02d:%02d:%02d", &t->tm_hour, &t->tm_min, &t->tm_sec) == 3 ||
+		sscanf(c, "%02d%02d%02d", &t->tm_hour, &t->tm_min, &t->tm_sec) == 3) {
+		int tzhrs, tzmins;
+		c += 8;
+		if (*c == '.') /* dealing with precision we don't care about */
+			c += 4;
+		if ((*c == '+' || *c == '-') &&
+			sscanf(c+1, "%02d:%02d", &tzhrs, &tzmins)) {
+			tzoff = tzhrs*60*60 + tzmins*60;
+			if (*c == '+')
+				tzoff *= -1;
+			}
+
+			if (tzoff || utc) {
 #ifdef HAVE_TM_GMTOFF
-                tzoff += t.tm_gmtoff;
+				tzoff += t->tm_gmtoff;
 #else
-#   ifdef HAVE_TIMEZONE
-                tzset();    /* making sure */
-                tzoff -= timezone;
-#   endif
+#	ifdef HAVE_TIMEZONE
+				tzset();    /* making sure */
+				tzoff -= timezone;
+#	endif
 #endif
 			}
-        }
-    }
-
-	t.tm_isdst = -1;
-
-	retval = mktime(&t);
-
-    retval += tzoff;
-
-    return retval;
+		}
+	}
+
+	t->tm_isdst = -1;
+	retval = mktime(t);
+	retval += tzoff;
+
+	return retval;
 }
 
 
-
 /**************************************************************************
  * Markup Functions
  **************************************************************************/
@@ -1919,14 +1909,14 @@
 		if(g_file_test(dir, G_FILE_TEST_IS_DIR)) {
 			continue;
 		} else if(g_file_test(dir, G_FILE_TEST_EXISTS)) {
-			gaim_debug(GAIM_DEBUG_WARNING, "build_dir", "bad path: %s\n", path);
+			gaim_debug_warning("build_dir", "bad path: %s\n", path);
 			g_strfreev(components);
 			g_free(dir);
 			return -1;
 		}
 
 		if (mkdir(dir, mode) < 0) {
-			gaim_debug(GAIM_DEBUG_WARNING, "build_dir", "mkdir: %s\n", strerror(errno));
+			gaim_debug_warning("build_dir", "mkdir: %s\n", strerror(errno));
 			g_strfreev(components);
 			g_free(dir);
 			return -1;