From bc415887ad22d3fa64632c85ad147546d47652a5 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 5 Mar 2026 18:17:35 +0100 Subject: cpp: #include".." shouldn't look in working directory --- c/lex.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'c') diff --git a/c/lex.c b/c/lex.c index 6099539..459aecd 100644 --- a/c/lex.c +++ b/c/lex.c @@ -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); -- cgit v1.2.3