From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 6994F384B0C9 for ; Thu, 20 Oct 2022 20:49:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6994F384B0C9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29KF87U1002791; Thu, 20 Oct 2022 22:49:02 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=selector1; bh=1FTfjqL7Uvn5tNbUzijn7PxGCfVEvrZKE28ixIb3kMg=; b=vym3yHsPkaNvKnBopHuDjRxo+R0EPeW6ICYuxCJQRMmlF4UGl3M1lwJQANba4f5wDKzY BCv/EHHnJ8zVo1f88W8jHVNsr+KUEmSpFdrhTHAvXsZFsEL0Ka609i1CjxAZDxavlpiS xW6KFgb7lX4tMZR5CnOGguzsKlCtYZ9uOby/mobgh/T6rumO+v5ZfEbMfvne4nkQYiER TJr/XrqHR7fO+1Izk0Gk4mD69koGbLy1Kw7A77mFsJwFGX8mZGTxPrALluzP+qspSpFF qoegl0DjDtutkBXtg1FUw3DYL26dMMYRttH+j01bnOCeCTqARRJHwGPAZawNtyd8cpaU 6g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3k94sdtq2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 22:49:02 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 505CD10002A; Thu, 20 Oct 2022 22:48:55 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5AB7520A75D; Thu, 20 Oct 2022 22:48:55 +0200 (CEST) Received: from jkgcxl0002.jkg.st.com (10.210.54.218) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 20 Oct 2022 22:48:54 +0200 From: =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= To: CC: , , =?UTF-8?q?Torbj=C3=B6rn=20SVENSSON?= Subject: [PATCH] cpp/remap: Only override if string matched Date: Thu, 20 Oct 2022 22:48:26 +0200 Message-ID: <20221020204825.3248771-1-torbjorn.svensson@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.210.54.218] X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_11,2022-10-20_01,2022-06-22_01 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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