diff options
| author | 2025-10-17 18:00:52 +0200 | |
|---|---|---|
| committer | 2025-10-17 18:30:36 +0200 | |
| commit | ffc76d36f985817a86ff73822e0ed268226737dd (patch) | |
| tree | 45b8c70a8e07e2abb3eef9f4e0a50d672b7e40bb /c.c | |
| parent | ed58941c2c5dc62d7c5703d4be205626f9c3389b (diff) | |
add -E preprocessing option
Diffstat (limited to 'c.c')
| -rw-r--r-- | c.c | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -4017,20 +4017,34 @@ docomp(struct comp *cm) } } -void -ccomp(const char *file) +static void +initcm(struct comp *cm, const char *file) { enum { N = 1<<12 }; static union { char m[sizeof(struct arena) + N]; struct arena *_align; } amem[2]; - struct comp cm = {0}; - const char *err = initlexer(&cm.lx, NULL, file); + const char *err = initlexer(&cm->lx, NULL, file); if (err) fatal(NULL, "Cannot open %'s: %s", file, err); - cm.fnarena = (void *)amem[0].m; - cm.fnarena->cap = N; - cm.exarena = (void *)amem[1].m; - cm.exarena->cap = N; + cm->fnarena = (void *)amem[0].m; + cm->fnarena->cap = N; + cm->exarena = (void *)amem[1].m; + cm->exarena->cap = N; +} + +void +ccomp(const char *file) +{ + struct comp cm = {0}; + initcm(&cm, file); docomp(&cm); } +void +cpp(struct wbuf *out, const char *file) +{ + struct comp cm = {0}; + initcm(&cm, file); + lexerdump(&cm.lx, out); +} + /* vim:set ts=3 sw=3 expandtab: */ |