[collectd] [PATCH] src/common.c: Add end-of-line characters to strsplit()

Michał Mirosław mirq-linux at rere.qmqm.pl
Sat Jun 14 02:29:05 CEST 2008


This fixes plugins that use it to break lines read using fgets()
and forget that "\n" is left at the buffer's end. At least
battery and wireless plugins is affected.

Signed-off-by: Michał Mirosław <mirq-linux at rere.qmqm.pl>

--- a/src/common.c
+++ b/src/common.c
@@ -224,7 +224,7 @@ int strsplit (char *string, char **fields, size_t size)
 	i = 0;
 	ptr = string;
 	saveptr = NULL;
-	while ((fields[i] = strtok_r (ptr, " \t", &saveptr)) != NULL)
+	while ((fields[i] = strtok_r (ptr, " \t\r\n", &saveptr)) != NULL)
 	{
 		ptr = NULL;
 		i++;



More information about the collectd mailing list