commit 1b96e78d6407353d55a56bd1ebae7d94e5ad2406
parent a3447a663f73a7e4ea7a71ddf23944becf936f50
Author: Sebastian <sebastian@sebsite.pw>
Date: Mon, 7 Mar 2022 20:47:13 -0500
lex: only permit space, tab, and newline as whitespace
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/lex.c b/src/lex.c
@@ -203,11 +203,17 @@ next(struct lexer *lexer, struct location *loc, bool buffer)
return c;
}
+static bool
+isharespace(uint32_t c)
+{
+ return c == '\t' || c == '\n' || c == ' ';
+}
+
static uint32_t
wgetc(struct lexer *lexer, struct location *loc)
{
uint32_t c;
- while ((c = next(lexer, loc, false)) != UTF8_INVALID && isspace(c)) ;
+ while ((c = next(lexer, loc, false)) != UTF8_INVALID && isharespace(c)) ;
return c;
}