From 8a25cb84e7c51749dd6d43d58e4952ef311eed45 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 29 Mar 2018 23:08:34 -0400 Subject: [PATCH] expose inew_number --- parser.c | 4 ++-- parser.h | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/parser.c b/parser.c index 14031dc..103b80d 100644 --- a/parser.c +++ b/parser.c @@ -402,7 +402,7 @@ variable **iparse(instance *it, const char *s) for (int c = 0; c >= 0; end++) { if (s[end] == '(') c++; - if (c == 0 && last != end && (s[end] == ',' || s[end] == ')')) { + if (c == 0 && last != end && (s[end] == ',' || s[end] == ')' || s[end] == '\0')) { argcount++; char *arg = strnclone(s + last, end - last); uint32_t parenidx = ooffset; @@ -418,7 +418,7 @@ variable **iparse(instance *it, const char *s) ops[parenidx] = (variable *)(OP_MAGIC | count); last = end + 1; } - if (s[end] == ')') + if (s[end] == ')' || s[end] == '\0') c--; } if (s[end] != '\0') diff --git a/parser.h b/parser.h index f1ffe70..b032bb4 100644 --- a/parser.h +++ b/parser.h @@ -78,6 +78,14 @@ int idoline(instance *it, const char *s); */ void inew_cfunc(instance *it, const char *name, func_t func); +/** + * Creates a script-accessible float number. + * @param it the current instance + * @param name the name of the new variable + * @param f the variable's initial value + */ +void inew_number(instance *it, const char *name, float f); + /** * Pops a word from the instance's stack. * @param it the current instance