commit d531fce2fa19acc4bc2437c4b87a87d1babd46b8
parent 4aeee032c893e67ea3adb4b8f18683a5b20050d0
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 28 Dec 2018 23:03:59 -0800
Warn on no closing double quote or incorrect ratio
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tisp.c b/tisp.c
@@ -458,6 +458,8 @@ read_num(Str str)
switch (*str->d) {
case '/':
str->d++;
+ if (!isnum(str->d))
+ warn("incorrect ratio format, no denominator found");
return mk_rat(sign * num, read_sign(str) * read_int(str));
case '.':
s = emalloc(sizeof(str));
@@ -479,7 +481,9 @@ read_str(Env env, Str str)
{
int len = 0;
char *s = ++str->d;
- for (; *str->d && *str->d++ != '"'; len++);
+ for (; *str->d++ != '"'; len++)
+ if (!*str->d)
+ warn("reached end before closing double quote");
s[len] = '\0';
return mk_str(env, s);
}