public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] cpp/remap: Only override if string matched
@ 2022-10-20 20:48 Torbjörn SVENSSON
  2022-11-02 18:21 ` PING^1 " Torbjorn SVENSSON
  0 siblings, 1 reply; 5+ messages in thread
From: Torbjörn SVENSSON @ 2022-10-20 20:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: tromey, yvan.roux, Torbjörn SVENSSON

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 <torbjorn.svensson@foss.st.com>
---
 libcpp/files.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcpp/files.cc b/libcpp/files.cc
index 24208f7b0f8..a18b1caf48d 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.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-21 12:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 20:48 [PATCH] cpp/remap: Only override if string matched Torbjörn SVENSSON
2022-11-02 18:21 ` PING^1 " Torbjorn SVENSSON
2022-11-17 16:44   ` PING^2 " Torbjorn SVENSSON
2022-11-20 20:31   ` PING^1 " Jeff Law
2022-11-21 12:38     ` Torbjorn SVENSSON

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).