diff options
| author | 2026-03-05 18:17:35 +0100 | |
|---|---|---|
| committer | 2026-03-05 18:17:35 +0100 | |
| commit | bc415887ad22d3fa64632c85ad147546d47652a5 (patch) | |
| tree | 0203eacdc58365423d7cf9c5e10f36772fe97cbd | |
| parent | 1ec29c2bb4350d09ee34b8eff53b9974fcc0a81f (diff) | |
cpp: #include".." shouldn't look in working directory
| -rw-r--r-- | c/lex.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1786,12 +1786,14 @@ ppinclude(struct lexer *lx, const struct span *span0) expecteol(lx, "include"); joinspan(&span.ex, tk.span.ex); if (tk.t == TKPPHDRQ) { - /* try raw path: absolute or relative to working dir */ - xbgrow(&path, tk.len + 1); - memcpy(path, tk.s, tk.len); - path[tk.len] = 0; - if (tryinclude(lx, &span, path)) return; - if (tk.s[0] == '/') goto NotFound; + if (tk.s[0] == '/') { + /* try absolute path */ + xbgrow(&path, tk.len + 1); + memcpy(path, tk.s, tk.len); + path[tk.len] = 0; + if (tryinclude(lx, &span, path)) return; + goto NotFound; + } /* try relative to current file's directory */ base = getfilename(lx->fileid, 0); |