summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.c b/util.c
index 136ff1b213..fc8874c942 100644
--- a/util.c
+++ b/util.c
@@ -3936,6 +3936,24 @@ ret1:
*rve = s;
return s0;
}
+
+void
+ruby_each_words(const char *str, void (*func)(const char*, int, void*), void *arg)
+{
+ const char *end;
+ int len;
+
+ if (!str) return;
+ for (; *str; str = end) {
+ while (ISSPACE(*str) || *str == ',') str++;
+ if (!*str) break;
+ end = str;
+ while (*end && !ISSPACE(*end) && *end != ',') end++;
+ len = end - str;
+ (*func)(str, len, arg);
+ }
+}
+
#ifdef __cplusplus
}
#endif