aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-28 19:54:39 +0100
committerMax Kellermann <max@duempel.org>2008-12-28 19:54:39 +0100
commit2598cdd86814c7792a431470a9143d609399697b (patch)
tree427af84e31e0c1b510be16b01ec4d780fa913fcd
parent4b3a055ffe39c8f71a93b2bffef9ef602b8ae2bf (diff)
downloadmpd-2598cdd86814c7792a431470a9143d609399697b.tar.gz
mpd-2598cdd86814c7792a431470a9143d609399697b.tar.xz
mpd-2598cdd86814c7792a431470a9143d609399697b.zip
buffer2array: use GLib's g_ascii_isspace()
g_ascii_isspace() includes \r and \n. This means that lines from a text file don't have to be chopped prior to buffer2array().
-rw-r--r--src/buffer2array.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/buffer2array.c b/src/buffer2array.c
index 0479de51b..0b99c0a4c 100644
--- a/src/buffer2array.c
+++ b/src/buffer2array.c
@@ -17,14 +17,10 @@
*/
#include "buffer2array.h"
-#include "os_compat.h"
-static inline
-int
-isWhiteSpace(char c)
-{
- return (c == ' ' || c == '\t');
-}
+#include <glib.h>
+
+#include <string.h>
int buffer2array(char *buffer, char *array[], const int max)
{
@@ -44,19 +40,20 @@ int buffer2array(char *buffer, char *array[], const int max)
}
}
} else {
- while (isWhiteSpace(*c))
- ++c;
- array[i++] = c++;
+ c = g_strchug(c);
if (*c == '\0')
return i;
- while (!isWhiteSpace(*c) && *c != '\0')
+
+ array[i++] = c++;
+
+ while (!g_ascii_isspace(*c) && *c != '\0')
++c;
}
if (*c == '\0')
return i;
*(c++) = '\0';
- while (isWhiteSpace(*c))
- ++c;
+
+ c = g_strchug(c);
}
return i;
}