diff src/protocols/oscar/util.c @ 5556:8ab1875e6d09

[gaim-migrate @ 5957] This is mostly some small changes to oscar to make it faster and more portable (like, to 64 bit platforms). It's pretty much all from The Ryan McCabe (odin). He's the man. I didn't actually test this, but CVS is probably broken right now anyway. Fear not--if it doesn't work I'll be sure to fix it real good now, ya hear. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 30 May 2003 02:35:44 +0000
parents 2d9f7d2e3558
children 9a34e950792e
line wrap: on
line diff
--- a/src/protocols/oscar/util.c	Fri May 30 00:02:42 2003 +0000
+++ b/src/protocols/oscar/util.c	Fri May 30 02:35:44 2003 +0000
@@ -168,16 +168,14 @@
 faim_export int aim_snlen(const char *sn)
 {
 	int i = 0;
-	const char *curPtr = NULL;
 
 	if (!sn)
 		return 0;
 
-	curPtr = sn;
-	while ( (*curPtr) != (char) NULL) {
-		if ((*curPtr) != ' ')
-		i++;
-		curPtr++;
+	while (*sn != '\0') {
+		if (*sn != ' ')
+			i++;
+		sn++;
 	}
 
 	return i;
@@ -197,29 +195,25 @@
 */
 faim_export int aim_sncmp(const char *sn1, const char *sn2)
 {
-	const char *curPtr1 = NULL, *curPtr2 = NULL;
 
 	if (aim_snlen(sn1) != aim_snlen(sn2))
 		return 1;
 
-	curPtr1 = sn1;
-	curPtr2 = sn2;
-	while ( (*curPtr1 != (char) NULL) && (*curPtr2 != (char) NULL) ) {
-		if ( (*curPtr1 == ' ') || (*curPtr2 == ' ') ) {
-			if (*curPtr1 == ' ')
-				curPtr1++;
-			if (*curPtr2 == ' ')
-				curPtr2++;
-		} else {
-			if ( toupper(*curPtr1) != toupper(*curPtr2))
-				return 1;
-			curPtr1++;
-			curPtr2++;
-		}
+	/* XXX - Should be able to only check if sn1 != '\0', right?  Is that faster? */
+	while ((*sn1 != '\0') && (*sn2 != '\0')) {
+		while (*sn2 == ' ')
+			*sn2++;
+		while (*sn1 == ' ')
+			*sn1++;
+		if (toupper(*sn1) != toupper(*sn2))
+			return 1;
+		sn1++;
+		sn2++;
 	}
 
 	/* Should both be NULL */
-	if (*curPtr1 != *curPtr2)
+	/* XXX - I think this check is not necessary, but I'm afeared to take it out */
+	if (*sn1 != *sn2)
 		return 1;
 
 	return 0;