changeset 3778:91689264d812 HEAD

*_strsplit_spaces() was skipping only space separators, while it should have skipped all (like its API comments said).
author Timo Sirainen <tss@iki.fi>
date Fri, 30 Dec 2005 22:06:10 +0200
parents 39c293635875
children e87a8db60d25
files src/lib/strfuncs.c
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/strfuncs.c	Fri Dec 30 21:49:38 2005 +0200
+++ b/src/lib/strfuncs.c	Fri Dec 30 22:06:10 2005 +0200
@@ -504,8 +504,11 @@
 
 	i_assert(*separators != '\0');
 
-	if (spaces)
-		while (*data == ' ') data++;
+	if (spaces) {
+		/* skip leading separators */
+		while (strchr(separators, *data) != NULL)
+			data++;
+	}
 	if (*data == '\0')
 		return p_new(pool, char *, 1);
 
@@ -527,13 +530,12 @@
 				alloc_count = new_alloc_count;
 			}
 
-			if (*str != ' ' || !spaces)
-				*str = '\0';
-			else {
-				*str = '\0';
-				while (str[1] == ' ') str++;
+			*str = '\0';
+			if (spaces) {
+				while (strchr(separators, str[1]) != NULL)
+					str++;
 
-				/* ignore trailing spaces */
+				/* ignore trailing separators */
 				if (str[1] == '\0')
 					break;
 			}