From 711f56ad9093b18197ca82415317f4a3748d45ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Torbj=C3=B6rn=20SVENSSON?= Date: Thu, 20 Oct 2022 22:38:57 +0200 Subject: [PATCH] libcpp/remap: Only override if string matched MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the pointer if the backslash pattern matches. Output without this patch: .../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No such file or directory With patch applied, no output and the test case succeeds. libcpp/ChangeLog * files.cc: Ensure pattern matches before use. Signed-off-by: Torbjörn SVENSSON --- libcpp/files.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpp/files.cc b/libcpp/files.cc index 24208f7..a18b1ca 100644 --- a/libcpp/files.cc +++ b/libcpp/files.cc @@ -1833,7 +1833,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file) #ifdef HAVE_DOS_BASED_FILE_SYSTEM { const char *p2 = strchr (fname, '\\'); - if (!p || (p > p2)) + if (!p || (p2 && p > p2)) p = p2; } #endif -- 2.7.4