changeset 4160:fcc6db86f5c7

[gaim-migrate @ 4389] Nicola's Lichtmaier (niqueco) writes: "Several things: I've added some "const"s here and there. I've declared some functions as "pure" or "const" (helps gcc to optimize the code). I've declared debug_printf so that gcc can check the printf format string (this makes visible several formatting bugs!) I've changed minor things in util.c (why having an useless extra call to g_strncasecmp?). And I've added some _() as usual. I hope some of this gets checked in, if not all." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 31 Dec 2002 18:19:14 +0000
parents 3f267c74e50a
children c79961f48063
files src/about.c src/conversation.c src/gaim.h src/ui.h src/util.c
diffstat 5 files changed, 39 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/about.c	Tue Dec 31 05:24:17 2002 +0000
+++ b/src/about.c	Tue Dec 31 18:19:14 2002 +0000
@@ -118,18 +118,18 @@
 				WEBSITE "</A><BR><BR>", -1, GTK_IMHTML_NO_SCROLL);
 
 		gtk_imhtml_append_text(GTK_IMHTML(text),
-				"<FONT SIZE=\"3\">IRC:</FONT> #gaim on irc.freenode.net"
-				"<BR><BR>", -1, GTK_IMHTML_NO_SCROLL);
+				_("<FONT SIZE=\"3\">IRC:</FONT> #gaim on irc.freenode.net"
+				"<BR><BR>"), -1, GTK_IMHTML_NO_SCROLL);
 
 		gtk_imhtml_append_text(GTK_IMHTML(text),
 			_("<FONT SIZE=\"3\">Active Developers:</FONT><BR>"), -1, GTK_IMHTML_NO_SCROLL);
 		gtk_imhtml_append_text(GTK_IMHTML(text),
-			"  Rob Flynn (maintainer) "
+			_("  Rob Flynn (maintainer) "
 			"&lt;<A HREF=\"mailto:rob@marko.net\">rob@marko.net</A>&gt;<BR>"
 			"  Sean Egan (coder) "
 			"&lt;<A HREF=\"mailto:bj91704@binghamton.edu\">"
 			"bj91704@binghamton.edu</A>&gt;"
-			"<BR><BR>", -1, GTK_IMHTML_NO_SCROLL);
+			"<BR><BR>"), -1, GTK_IMHTML_NO_SCROLL);
 
 		gtk_imhtml_append_text(GTK_IMHTML(text),
 			_("<FONT SIZE=\"3\">Crazy Patch Writers:</FONT><BR>"), -1, GTK_IMHTML_NO_SCROLL);
@@ -149,14 +149,14 @@
 		gtk_imhtml_append_text(GTK_IMHTML(text),
 				_("<FONT SIZE=\"3\">Retired Developers:</FONT><BR>"), -1, GTK_IMHTML_NO_SCROLL);
 		gtk_imhtml_append_text(GTK_IMHTML(text),
-				"  Jim Duchek<BR>"
+				_("  Jim Duchek<BR>"
 				"  Eric Warmenhoven "
 				"&lt;<A HREF=\"mailto:warmenhoven@yahoo.com\">"
 				"warmenhoven@yahoo.com</A>&gt;<BR>"
 				"  Mark Spencer (original author) "
 				"&lt;<A HREF=\"mailto:markster@marko.net\">"
 				"markster@marko.net</A>&gt;"
-				"<BR><BR>", -1, GTK_IMHTML_NO_SCROLL);
+				"<BR><BR>"), -1, GTK_IMHTML_NO_SCROLL);
 
 		gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)), 0);
 
--- a/src/conversation.c	Tue Dec 31 05:24:17 2002 +0000
+++ b/src/conversation.c	Tue Dec 31 18:19:14 2002 +0000
@@ -317,7 +317,7 @@
 		set_convo_title(cnv);
 }
 
-struct log_conversation *find_log_info(char *name)
+struct log_conversation *find_log_info(const char *name)
 {
 	char *pname = g_malloc(1024);
 	GList *lc = log_conversations;
--- a/src/gaim.h	Tue Dec 31 05:24:17 2002 +0000
+++ b/src/gaim.h	Tue Dec 31 18:19:14 2002 +0000
@@ -408,7 +408,7 @@
 extern gint check_idle(gpointer);
 
 /* Functions in prefs.c */
-extern void debug_printf(char * fmt, ...);
+extern void debug_printf(char * fmt, ...) G_GNUC_PRINTF(1,2);
 
 /* Functions in server.c */
 /* input to serv */
@@ -454,10 +454,10 @@
 extern void clean_pid();
 extern char *date();
 extern gint linkify_text(char *);
-extern FILE *open_log_file (char *, int);
+extern FILE *open_log_file (const char *, int);
 extern char *sec_to_text(guint);
-extern struct aim_user *find_user(const char *, int);
-extern char *full_date();
+extern struct aim_user *find_user(const char *, int) G_GNUC_PURE;
+extern char *full_date() G_GNUC_PURE;
 extern void check_gaim_versions();
 extern char *away_subs(char *, char *);
 extern char *stylize(gchar *, int);
@@ -471,7 +471,7 @@
 extern void system_log(enum log_event, struct gaim_connection *, struct buddy *, int);
 extern char *add_cr(char *);
 extern void strip_linefeed(char *);
-extern time_t get_time(int, int, int, int, int, int);
+extern time_t get_time(int, int, int, int, int, int) G_GNUC_CONST;
 extern FILE *gaim_mkstemp(gchar **);
 extern char *convert_string(char *, const char *, const char *);
 extern const char *handle_uri(char *);
--- a/src/ui.h	Tue Dec 31 05:24:17 2002 +0000
+++ b/src/ui.h	Tue Dec 31 18:19:14 2002 +0000
@@ -396,7 +396,7 @@
 extern int is_logging(char *);
 extern void set_state_lock(int);
 extern void rm_log(struct log_conversation *);
-extern struct log_conversation *find_log_info(char *);
+extern struct log_conversation *find_log_info(const char *);
 extern void remove_tags(struct conversation *, char *);
 extern void update_log_convs();
 extern void update_transparency();
--- a/src/util.c	Tue Dec 31 05:24:17 2002 +0000
+++ b/src/util.c	Tue Dec 31 18:19:14 2002 +0000
@@ -67,7 +67,7 @@
 	return date;
 }
 
-gint badchar(char c)
+G_GNUC_CONST static gint badchar(char c)
 {
 	switch (c) {
 	case ' ':
@@ -155,7 +155,7 @@
 				if (!(*c))
 					break;
 			}
-		} else if ((!g_strncasecmp(c, "http://", 7) || (!g_strncasecmp(c, "https://", 8)))) {
+		} else if ((*c=='h') && (!g_strncasecmp(c, "http://", 7) || (!g_strncasecmp(c, "https://", 8)))) {
 			t = c;
 			while (1) {
 				if (badchar(*t)) {
@@ -180,7 +180,7 @@
 
 			}
 		} else if (!g_strncasecmp(c, "www.", 4)) {
-			if (g_strncasecmp(c, "www..", 5)) {
+			if (c[4] != '.') {
 				t = c;
 				while (1) {
 					if (badchar(*t)) {
@@ -227,7 +227,7 @@
 
 			}
 		} else if (!g_strncasecmp(c, "ftp.", 4)) {
-			if (g_strncasecmp(c, "ftp..", 5)) {
+			if (c[4] != '.') {
 				t = c;
 				while (1) {
 					if (badchar(*t)) {
@@ -267,15 +267,14 @@
 				t++;
 
 			}
-		} else if (c != cpy && !g_strncasecmp(c, "@", 1)) {
+		} else if (c != cpy && (*c == '@')) {
 			char *tmp;
 			int flag;
 			int len = 0;
-			char illegal_chars[] = "!@#$%^&*()[]{}/|\\<>\":;\0";
+			const char illegal_chars[] = "!@#$%^&*()[]{}/|\\<>\":;\r\n \0";
 			url_buf[0] = 0;
 
-			if (*(c - 1) == ' ' || *(c + 1) == ' ' || rindex(illegal_chars, *(c + 1))
-			    || *(c + 1) == 13 || *(c + 1) == 10)
+			if (strchr(illegal_chars,*(c - 1)) || strchr(illegal_chars, *(c + 1)))
 				flag = 0;
 			else
 				flag = 1;
@@ -343,7 +342,7 @@
 }
 
 
-FILE *open_gaim_log_file(char *name, int *flag)
+FILE *open_gaim_log_file(const char *name, int *flag)
 {
 	char *buf;
 	char *buf2;
@@ -372,7 +371,7 @@
 	if (!fd) {
 		res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
 		if (res < 0) {
-			g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging",
+			g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
 				   log_all_file);
 			do_error_dialog(buf, NULL, GAIM_ERROR);
 			g_free(buf);
@@ -393,7 +392,7 @@
 	if (!fd) {
 		res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR);
 		if (res < 0) {
-			g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging",
+			g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"),
 				   log_all_file);
 			do_error_dialog(buf, NULL, GAIM_ERROR);
 			g_free(buf);
@@ -406,7 +405,7 @@
 	g_snprintf(log_all_file, 256, "%s" G_DIR_SEPARATOR_S "logs", gaim_dir);
 
 	if( _mkdir(log_all_file) < 0 && errno != EEXIST ) {
-	  g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file);
+	  g_snprintf(buf, BUF_LONG, _("Unable to make directory %s for logging"), log_all_file);
 	  do_error_dialog(buf, NULL, GAIM_ERROR);
 	  g_free(buf);
 	  g_free(buf2);
@@ -427,7 +426,7 @@
 	return fd;
 }
 
-FILE *open_log_file(char *name, int is_chat)
+FILE *open_log_file(const char *name, int is_chat)
 {
 	struct stat st;
 	char realname[256];
@@ -450,10 +449,10 @@
 
 		if (flag) {	/* is a new file */
 			if (logging_options & OPT_LOG_STRIP_HTML) {
-				fprintf(fd, "IM Sessions with %s\n", name);
+				fprintf(fd, _("IM Sessions with %s\n"), name);
 			} else {
 				fprintf(fd, "<HTML><HEAD><TITLE>");
-				fprintf(fd, "IM Sessions with %s", name);
+				fprintf(fd, _("IM Sessions with %s"), name);
 				fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
 			}
 		}
@@ -466,10 +465,10 @@
 
 	if (fd && flag) {	/* is a new file */
 		if (logging_options & OPT_LOG_STRIP_HTML) {
-			fprintf(fd, "IM Sessions with %s\n", name);
+			fprintf(fd, _("IM Sessions with %s\n"), name);
 		} else {
 			fprintf(fd, "<HTML><HEAD><TITLE>");
-			fprintf(fd, "IM Sessions with %s", name);
+			fprintf(fd, _("IM Sessions with %s"), name);
 			fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n");
 		}
 	}
@@ -487,7 +486,7 @@
 		return open_gaim_log_file("system", &x);
 }
 
-char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/";
+const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "0123456789+/";
 
 /* XXX Find bug */
 char *tobase64(const char *text)
@@ -884,8 +883,9 @@
  * dir. Note that there is no trailing slash after .gaim. */
 gchar *gaim_user_dir()
 {
-        if(gaim_home_dir()) {
-		strcpy( (char*)&home_dir, gaim_home_dir() );
+	const gchar *hd = gaim_home_dir();
+        if(hd) {
+		strcpy( (char*)&home_dir, hd );
 		strcat( (char*)&home_dir, G_DIR_SEPARATOR_S ".gaim" );
 		return (gchar*)&home_dir;
 	}
@@ -1219,7 +1219,7 @@
 			else
 			{
 				if( (fp = fopen( result, "w+" )) == NULL ) {
-					debug_printf("Error: Couldn't fopen()in gaim_mkstemp():\n%s\n", result);
+					debug_printf("Error: Couldn't fopen() in gaim_mkstemp():\n%s\n", result);
 				}
 			}
 #else
@@ -1263,7 +1263,7 @@
 	}
 
 	if (gc == NULL)
-		return "Not connected to AIM";
+		return _("Not connected to AIM");
 
  	/* aim:goim?screenname=screenname&message=message */
 	if (!g_strncasecmp(uri, "aim:goim?", strlen("aim:goim?"))) {
@@ -1272,7 +1272,7 @@
 		uri = uri + strlen("aim:goim?");
 		
 		if (!(who = strstr(uri, "screenname="))) {
-			return "No screenname given.";
+			return _("No screenname given.");
 		}
 		/* spaces are encoded as +'s */
 		who = who + strlen("screenname=");
@@ -1309,7 +1309,7 @@
 		/* spaces are encoded as +'s */
 		
 		if (!(who = strstr(uri, "screenname="))) {
-			return "No screenname given.";
+			return _("No screenname given.");
 		}
 		who = who + strlen("screenname=");
 		str = g_string_new(NULL);
@@ -1345,7 +1345,7 @@
 		/* spaces are encoded as +'s */
 		
 		if (!(room = strstr(uri, "roomname="))) {
-			return "No roomname given.";
+			return _("No roomname given.");
 		}
 		room = room + strlen("roomname=");
 		str = g_string_new(NULL);
@@ -1361,7 +1361,7 @@
 		g_free(room);
 		g_list_free(chat);
 	} else {
-		return "Invalid AIM URI";
+		return _("Invalid AIM URI");
 	}