diff src/util.c @ 4282:aa20cc16dc08

[gaim-migrate @ 4533] Let's see here... I kinda rewrote normalize. I think it should be more efficient this way, because memory isn't allocated. I dunno. That function is called quite a bit, though. The ngettext thing is cool, but having parameters in the right order is cooler. :-) I made is so aliases on the server list overwrite the local aliases. They would only be the same if you sign on elsewhere and change them, so this should be ok. I renamed some variables in ssi.c. Time Warner is still a horrible, horrible company. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 10 Jan 2003 23:08:56 +0000
parents af2eeb7f7cf8
children 5978e3d53f29
line wrap: on
line diff
--- a/src/util.c	Fri Jan 10 22:45:53 2003 +0000
+++ b/src/util.c	Fri Jan 10 23:08:56 2003 +0000
@@ -466,25 +466,19 @@
 char *normalize(const char *s)
 {
 	static char buf[BUF_LEN];
-	char *t, *u;
-	int x = 0;
+	int i, j;
 
 	g_return_val_if_fail((s != NULL), NULL);
 
-	u = t = g_strdup(s);
-
-	strcpy(t, s);
-	g_strdown(t);
+	strncpy(buf, s, BUF_LEN);
+	for (i=0, j=0; buf[j]; i++, j++) {
+		while (buf[j] == ' ')
+			j++;
+		buf[i] = buf[j];
+	}
+	buf[i] = '\0';
+	g_strdown(buf);
 
-	while (*t && (x < BUF_LEN - 1)) {
-		if (*t != ' ') {
-			buf[x] = *t;
-			x++;
-		}
-		t++;
-	}
-	buf[x] = '\0';
-	g_free(u);
 	return buf;
 }