summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util.c b/util.c
index bcb608480f..4bec220f7a 100644
--- a/util.c
+++ b/util.c
@@ -145,3 +145,22 @@ int safe_atoi(const char *s, int *ret_i) {
*ret_i = (unsigned) l;
return 0;
}
+
+/* What is interpreted as whitespace? */
+#define WHITESPACE " \t\n"
+
+/* Split a string into words. */
+char *split_spaces(const char *c, size_t *l, char **state) {
+ char *current;
+
+ current = *state ? *state : (char*) c;
+
+ if (!*current || *c == 0)
+ return NULL;
+
+ current += strspn(current, WHITESPACE);
+ *l = strcspn(current, WHITESPACE);
+ *state = current+*l;
+
+ return (char*) current;
+}