diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-02-28 23:50:42 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-03-01 01:41:15 +0100 |
commit | ebda8ec1c00447a6845ce50e9f272624948f810f (patch) | |
tree | 5ccf860c666301e07e8306595a8ee19040cee0a5 | |
parent | eaceeafad39ade20c28b6634d30379763511c6e6 (diff) | |
download | sparse-dev-ebda8ec1c00447a6845ce50e9f272624948f810f.tar.gz |
pre-proc: do some path normalization
An header file like 'header.h':
#pragma once
#include "./header.h"
doesn't work because:
1) both filenames are different, so it will be be included anyway
2) after that it will be included again under the name "././header.h"
and so on until it eventually fails with ENAMETOOLONG.
Prevent this by stripping leading "./"s in the paths.
This is not good enough for testing file equivalence by is enough to
avoid the loop.
Link: https://lore.kernel.org/r/CAHk-=wjFWZMVWTbvUMVxQqGKvGMC_BNrahCtTkpEjxoC0k-T=A@mail.gmail.com
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | pre-process.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pre-process.c b/pre-process.c index 7a1478f6..3fb25082 100644 --- a/pre-process.c +++ b/pre-process.c @@ -884,6 +884,12 @@ static void set_stream_include_path(struct stream *stream) memcpy(m, stream->name, len); m[len] = 0; path = m; + /* normalize this path */ + while (path[0] == '.' && path[1] == '/') { + path += 2; + while (path[0] == '/') + path++; + } } stream->path = path; } |