diff src/util.c @ 1829:bdfb37ae28b4

[gaim-migrate @ 1839] not that anything uses this committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 09 May 2001 09:56:18 +0000
parents 7f889cdfa03e
children 4dbd8533d209
line wrap: on
line diff
--- a/src/util.c	Wed May 09 05:24:50 2001 +0000
+++ b/src/util.c	Wed May 09 09:56:18 2001 +0000
@@ -591,7 +591,7 @@
 
 	c = text;
 
-	while (c) {
+	while (*c) {
 		tmp = tmp << 8;
 		tmp += *c;
 		n++;
@@ -611,17 +611,19 @@
 	switch (n) {
 
 	case 2:
+		tmp <<= 8;
 		out = g_realloc(out, len + 5);
-		out[len] = alphabet[(tmp >> 12) & 0x3f];
-		out[len + 1] = alphabet[(tmp >> 6) & 0x3f];
-		out[len + 2] = alphabet[tmp & 0x3f];
+		out[len] = alphabet[(tmp >> 18) & 0x3f];
+		out[len + 1] = alphabet[(tmp >> 12) & 0x3f];
+		out[len + 2] = alphabet[(tmp >> 6) & 0x3f];
 		out[len + 3] = '=';
 		out[len + 4] = 0;
 		break;
 	case 1:
+		tmp <<= 16;
 		out = g_realloc(out, len + 4);
-		out[len] = alphabet[(tmp >> 6) & 0x3f];
-		out[len + 1] = alphabet[tmp & 0x3f];
+		out[len] = alphabet[(tmp >> 12) & 0x3f];
+		out[len + 1] = alphabet[(tmp >> 6) & 0x3f];
 		out[len + 2] = '=';
 		out[len + 3] = 0;
 		break;