commit a60aaa30af90261ceb84baebc7fa3c737724542f
parent 5cff3c79f62476122a11b9a87489e3e9ee4f6222
Author: Ed van Bruggen <edvb@uw.edu>
Date: Tue, 20 Mar 2018 19:32:19 -0700
Add support for comments
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -114,11 +114,12 @@ issymbol(char c)
return BETWEEN(c, 'a', 'z') || strchr("+-*/", c);
}
-/* TODO skip comments */
static void
skip_spaces(Str str)
{
- for (; *str->d && isspace(*str->d); str->d++);
+ str->d += strspn(str->d, " \t\n"); /* skip white space */
+ for (; *str->d == ';'; str->d++) /* skip comments until newline */
+ str->d += strcspn(str->d, "\n");
}
/* return hashed number based on key */