diff options
| author | 2022-08-10 04:12:33 +0200 | |
|---|---|---|
| committer | 2022-08-10 04:12:33 +0200 | |
| commit | b33ee6afa74ab1e83554d1b535d81c7df0b3fca5 (patch) | |
| tree | d5fb52a1529bf35658468adae796757e664bc792 /bootstrap/parse.c | |
| parent | 769aa95cf3374117c86ec652117dcbab97497eec (diff) | |
many bugfix
Diffstat (limited to 'bootstrap/parse.c')
| -rw-r--r-- | bootstrap/parse.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c index 8d6fe2c..49f01b1 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -2781,7 +2781,7 @@ getbasedir(const char *path) { static struct comfile doimport(struct parser *P, const char *path) { - static vec_t(const char *) seen; + static vec_t(struct entry { const char *s; struct comfile cf; }) seen; char path2[PATH_MAX], _rpath[PATH_MAX], *rpath; struct comfile cf = {0}; struct parser P2; @@ -2791,15 +2791,15 @@ doimport(struct parser *P, const char *path) { if (!(rpath = realpath(path2, _rpath))) fatal(P, P->tokspan, "import %q: %s", path, strerror(errno)); for (int i = 0; i < seen.length; ++i) - if (!strcmp(seen.data[i], rpath)) - return cf; + if (!strcmp(seen.data[i].s, rpath)) + return seen.data[i].cf; rpath = xstrdup(rpath); - vec_push(&seen, rpath); // P2.primenv = P->primenv; initparser(&P2, xstrdup(path2)); P2.is_header = 1; parse(&cf, &P2); + vec_push(&seen, ((struct entry) { rpath, cf })); return cf; } @@ -3003,7 +3003,7 @@ parsedecl(decl_yielder_t yield, void *yarg, struct parser *P, bool toplevel) { const char *path; struct comfile cf; assert(toplevel); - path = lexexpect(P, TKstrlit).str; + path = (tok = lexexpect(P, TKstrlit)).str; cf = doimport(P, path); free((void *)path); for (int i = 0; i < cf.decls.n; ++i) { @@ -3011,7 +3011,6 @@ parsedecl(decl_yielder_t yield, void *yarg, struct parser *P, bool toplevel) { if (yield) yield(decl, yarg); } - free(cf.decls.d); lexexpect(P, ';'); return; } else if (lexmatch(P, &tok, TKident)) { |