pidgin: 23fc27a3: Strip both and

sadrul at pidgin.im sadrul at pidgin.im
Thu Jan 28 20:44:41 EST 2010


-----------------------------------------------------------------
Revision: 23fc27a319dd87434fdaf42acecbe1962468bbb8
Ancestor: 94f37ea0c09905f4121d63eff0dc9b4bd91d98bf
Author: sadrul at pidgin.im
Date: 2010-01-28T20:39:24
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/23fc27a319dd87434fdaf42acecbe1962468bbb8

Modified files:
        pidgin/gtkthemes.c

ChangeLog: 

Strip both \n and \r at the end of the lines when parsing a smiley theme.

Closes #10521.

-------------- next part --------------
============================================================
--- pidgin/gtkthemes.c	1cfe20a97f67926dd1e44d216962336e680723ae
+++ pidgin/gtkthemes.c	cc57f531ac671e167cccae0beab863ff07a02bd4
@@ -263,7 +263,14 @@ void pidgin_themes_load_smiley_theme(con
 
 		if (buf[0] == '#' || buf[0] == '\0')
 			continue;
-
+		else {
+			int len = strlen(buf);
+			while (len && (buf[len - 1] == '\r' || buf[len - 1] == '\n'))
+				buf[--len] = '\0';
+			if (len == 0)
+				continue;
+		}
+		
 		i = buf;
 		while (isspace(*i))
 			i++;
@@ -280,25 +287,17 @@ void pidgin_themes_load_smiley_theme(con
 				list->smileys = g_slist_reverse(list->smileys);
 			list = child;
 		} else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) {
-			int len;
 			g_free(theme->name);
 			theme->name = g_strdup(i + strlen("Name="));
-			len = strlen(theme->name);
-			theme->name[len-1] = 0;
-			if(len > 2 && theme->name[len-2] == '\r')
-				theme->name[len-2] = 0;
 		} else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) {
 			g_free(theme->desc);
 			theme->desc = g_strdup(i + strlen("Description="));
-			theme->desc[strlen(theme->desc)-1] = 0;
 		} else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) {
 			g_free(theme->icon);
 			theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
-			theme->icon[strlen(theme->icon)-1] = 0;
 		} else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) {
 			g_free(theme->author);
 			theme->author = g_strdup(i + strlen("Author="));
-			theme->author[strlen(theme->author)-1] = 0;
 		} else if (load && list) {
 			gboolean hidden = FALSE;
 			char *sfile = NULL;
@@ -311,7 +310,7 @@ void pidgin_themes_load_smiley_theme(con
 				char l[64];
 				int li = 0;
 				while (!isspace(*i) && li < sizeof(l) - 1) {
-					if (*i == '\\' && *(i+1) != '\0' && *(i+1) != '\n' && *(i+1) != '\r')
+					if (*i == '\\' && *(i+1) != '\0')
 						i++;
 					l[li++] = *(i++);
 				}


More information about the Commits mailing list