changeset 2548:20418e5702eb

[gaim-migrate @ 2561] deal with pounces committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 19 Oct 2001 09:21:00 +0000
parents ab55ac6234b8
children 7c64b3ad0c3d
files src/list.c
diffstat 1 files changed, 31 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/list.c	Fri Oct 19 08:39:48 2001 +0000
+++ b/src/list.c	Fri Oct 19 09:21:00 2001 +0000
@@ -471,22 +471,6 @@
 	}
 }
 
-/* remove leading whitespace from a string */
-static char *remove_spaces(char *str)
-{
-	int i;
-	char *new;
-
-	if (str == NULL)
-		return NULL;
-
-	i = strspn(str, " \t\n\r\f");
-	new = &str[i];
-
-	return new;
-}
-
-
 /* translate an AIM 3 buddylist (*.lst) to a Gaim buddylist */
 static void translate_lst(FILE *src_fp, char *dest)
 {
@@ -497,7 +481,7 @@
 	sprintf(dest, "m 1\n");
 
 	while (fgets(line, BUF_LEN, src_fp)) {
-		line2 = remove_spaces(line);
+		line2 = g_strchug(line);
 		if (strstr(line2, "group") == line2) {
 			name = strpbrk(line2, " \t\n\r\f") + 1;
 			strcat(dest, "g ");
@@ -533,58 +517,73 @@
 	while (strstr(fgets(line, BUF_LEN, src_fp), "list") == NULL);
 
 	while (1) {
-		fgets(line, BUF_LEN, src_fp);
+		fgets(line, BUF_LEN, src_fp); g_strchomp(line);
 		if (strchr(line, '}') != NULL)
 			break;
 
-		/* Syntax starting with "<group> {" */
 		if (strchr(line, '{') != NULL) {
+			/* Syntax starting with "<group> {" */
+
 			strcat(dest, "g ");
-			buddy = remove_spaces(strtok(line, "{"));
+			buddy = g_strchug(strtok(line, "{"));
 			for (i = 0; i < strlen(buddy); i++) {
-				if (buddy[i] != '\"')
+				if (buddy[i] != '\"') {
 					strncat(dest, &buddy[i], 1);
+				}
 			}
 			strcat(dest, "\n");
 			while (strchr(fgets(line, BUF_LEN, src_fp), '}') == NULL) {
-				buddy = remove_spaces(line);
+				gboolean pounce = FALSE;
+				g_strchomp(line);
+				buddy = g_strchug(line);
+				debug_printf("\nbuddy: \"%s\"\n\n", buddy);
 				strcat(dest, "b ");
+				if (strchr(buddy, '{') != NULL) {
+					/* buddy pounce, etc */
+					char *pos = strchr(buddy, '{') - 1;
+					*pos = 0;
+					pounce = TRUE;
+				}
 				if (strchr(buddy, '\"') != NULL) {
 					buddy++;
 					strncat(dest, buddy, strchr(buddy, '\"') - buddy);
-					strcat(dest, "\n");
 				} else
 					strcat(dest, buddy);
+				strcat(dest, "\n");
+				if (pounce)
+					do
+						fgets(line, BUF_LEN, src_fp);
+					while (!strchr(line, '}'));
 			}
-		}
-		/* Syntax "group buddy buddy ..." */
-		else {
-			buddy = remove_spaces(strtok(line, " \n"));
+		} else {
+
+			/* Syntax "group buddy buddy ..." */
+			buddy = g_strchug(strtok(line, " \n"));
 			strcat(dest, "g ");
 			if (strchr(buddy, '\"') != NULL) {
 				strcat(dest, &buddy[1]);
 				strcat(dest, " ");
-				buddy = remove_spaces(strtok(NULL, " \n"));
+				buddy = g_strchug(strtok(NULL, " \n"));
 				while (strchr(buddy, '\"') == NULL) {
 					strcat(dest, buddy);
 					strcat(dest, " ");
-					buddy = remove_spaces(strtok(NULL, " \n"));
+					buddy = g_strchug(strtok(NULL, " \n"));
 				}
 				strncat(dest, buddy, strlen(buddy) - 1);
 			} else {
 				strcat(dest, buddy);
 			}
 			strcat(dest, "\n");
-			while ((buddy = remove_spaces(strtok(NULL, " \n"))) != NULL) {
+			while ((buddy = g_strchug(strtok(NULL, " \n"))) != NULL) {
 				strcat(dest, "b ");
 				if (strchr(buddy, '\"') != NULL) {
 					strcat(dest, &buddy[1]);
 					strcat(dest, " ");
-					buddy = remove_spaces(strtok(NULL, " \n"));
+					buddy = g_strchug(strtok(NULL, " \n"));
 					while (strchr(buddy, '\"') == NULL) {
 						strcat(dest, buddy);
 						strcat(dest, " ");
-						buddy = remove_spaces(strtok(NULL, " \n"));
+						buddy = g_strchug(strtok(NULL, " \n"));
 					}
 					strncat(dest, buddy, strlen(buddy) - 1);
 				} else {