From: Torbjörn SVENSSON Date: Thu, 20 Oct 2022 20:38:57 +0000 (+0200) Subject: libcpp/remap: Only override if string matched X-Git-Tag: basepoints/gcc-14~3004 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=711f56ad9093b18197ca82415317f4a3748d45ae;p=thirdparty%2Fgcc.git libcpp/remap: Only override if string matched 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 --- diff --git a/libcpp/files.cc b/libcpp/files.cc index 24208f7b0f82..a18b1caf48db 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