From 69487ed29aed49ca0e3481e9783e02e9156258b2 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 22 May 2020 17:14:48 -0700 Subject: fix: encapsulated the IO stack into the lexer --- sys/cmd/cc/pp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sys/cmd/cc/pp.c') diff --git a/sys/cmd/cc/pp.c b/sys/cmd/cc/pp.c index 30a162b..5eed4b2 100644 --- a/sys/cmd/cc/pp.c +++ b/sys/cmd/cc/pp.c @@ -3,6 +3,17 @@ // ----------------------------------------------------------------------- // helper functions +static +void +pushomit(Lexer *lx, string omit) +{ + if (lx->omit.len == lx->omit.cap) { + lx->omit.cap += 20; + lx->omit.path = realloc(lx->omit.path, lx->omit.cap*sizeof(*lx->omit.path)); + } + lx->omit.path[lx->omit.len++] = omit; +} + // NOTE: The iterator of lexer lx->b IS NOT reset. // Its the caller's responsibility. static @@ -910,7 +921,7 @@ ppprag(Lexer *lx) } lx->b = lx->buf; if (strcmp(s, "once") == 0) { - pushomit(lx->io->path); + pushomit(lx, lx->io->path); return 0; } Bad: -- cgit v1.2.1