From patchwork Thu Oct 20 20:48:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Torbjorn SVENSSON X-Patchwork-Id: 6397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp316482wrr; Thu, 20 Oct 2022 13:49:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D5l5ko/68ebaSAttAZsxFrrERXqkX/Jtk/10nMJ1n7A/zv2JQ2v//IO50b4kh15wVJReX X-Received: by 2002:a17:906:478d:b0:78d:ec4d:e2e0 with SMTP id cw13-20020a170906478d00b0078dec4de2e0mr12592006ejc.34.1666298988311; Thu, 20 Oct 2022 13:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298988; cv=none; d=google.com; s=arc-20160816; b=kH2eOiyPX8bsN9SYYA1YtQyGl+i/OyfPndIMp7FxOZ30O6VaocN9ev5D2sovYUpelf 05sVCCiRXMmHcDRD43f9NBq0pLYTVywvaXG+n3rWbrgPSyM1Rs3s6mgDT1ZXc4p98fO6 6BQCeOoKL12V8w+BrzS4wJ0PkyqcpowxXGce15XDtZu8ElMl/LGLDb9hL85brGV3h33w R680h9SEMF4BTa0BUL7Ts3v2OoQkea0NXPH9Ot2r7Bj0AydGREpf70TnPeWMZvc5gA+u n/M2LhuMzKnDR7AXlp4VIdbSwr0IRTWyKy7ztO01j/SfcxurThC0bQHFixq0VuheZvq6 HiIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=1FTfjqL7Uvn5tNbUzijn7PxGCfVEvrZKE28ixIb3kMg=; b=LtF+X45HWRtLoo2ENocejRhid+pWB+7fTX7ksfLcjZ+WtoIRYMAAFFq+/m00KZFUjz pC++95zcw3qjmplGTTa63X2InpJZfmDDlf5XxoQrHFz1ETrgoyfTgn2bx+fjL7Ioyu3r LwQKF8F82w7SgBk8toICF88v191+V7yhmovHOwbL08C/fw9F9J5QuI1kca2Zq+8hOUIj QmLU1tl8HWW1F9KesvzMstXQ06FYWlZzJ87qbfAo+VB8wvfSmRZEiocIyOqcoPfc+G32 dOe0JDLV1RGSOpXb18ZL4W07at+hddUwrGvvu3TAR0gZXiRY8Tfhiqer1YGcRUPlHz82 XZpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YhvAMHZH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jg37-20020a170907972500b00791a37e665esi7279855ejc.10.2022.10.20.13.49.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 13:49:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YhvAMHZH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5D8F2384B02A for ; Thu, 20 Oct 2022 20:49:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5D8F2384B02A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666298987; bh=1FTfjqL7Uvn5tNbUzijn7PxGCfVEvrZKE28ixIb3kMg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=YhvAMHZHrDab671uT7JdUV4+a4Zp0+K2Rkcloc8nVxhN/KBG2ylSTWt/OxfVrU5Vk 4oLRDz0ty+OvxHpQA56mZqfaBFwH1ICgJlVDcIhH2cRJyAZinKRvzl8SdADwxaR24K iiuBM6Q6uXiWToOdAhNlXu3cOpNEw0ybQloIXdaI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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 To: 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Torbj=C3=B6rn_SVENSSON_via_Gcc-patches?= From: Torbjorn SVENSSON Reply-To: =?utf-8?q?Torbj=C3=B6rn_SVENSSON?= Cc: tromey@redhat.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241128135646855?= X-GMAIL-MSGID: =?utf-8?q?1747241128135646855?= 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