summaryrefslogtreecommitdiff
path: root/src/util/util.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-01-04 18:49:47 -0600
committersanine <sanine.not@pm.me>2023-01-04 18:49:47 -0600
commitdcb7a5389717c33f7fcfa67f5e2048cacc55d820 (patch)
treea32e1f64e1e720739e94f9b89e61addaa55882a5 /src/util/util.c
parent13a7c902c051fa8da1e476687c17bb5431d258e1 (diff)
add kai_text_to_reals
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index c77b3f4..d3e8742 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -21,3 +21,22 @@ void *kai_expand_array(void **array, size_t *count, size_t element_size)
*count = new_count;
return new_element;
}
+
+
+int kai_text_to_reals(ka_real_t *dest, const char *str, size_t count)
+{
+ char *nptr = (char*) str;
+ char *end;
+
+ int result = count;
+
+ for (int i=0; i<count; i++) {
+ dest[i] = KA_STR_TO_REAL(nptr, &end);
+ if (nptr == end) {
+ result -= 1;
+ }
+ nptr = end;
+ }
+
+ return result;
+}