From patchwork Fri Oct 29 15:33:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 46792 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 44C803857803 for ; Fri, 29 Oct 2021 15:33:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44C803857803 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635521637; bh=gpZTSAmFV1DUFN4lzDIJbiil83y1NjuuCDOMnldVjUM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YaqvPXoEvpteN5lVm1BisBm4CoX+B287jslZKHFR/RsvBMZKLZ/YJmQ5ldRqoGrs/ kPp2dEA25ViQBv6yMrwhv8zUUuet2bFnL4xDdXZpDzvI+hsJ6OhDBZc8NVobK9Nrhr q935SKI3cfeKsYWaYQRWWipf+nV5I/rVAGFmzSRo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 8C21E3858410 for ; Fri, 29 Oct 2021 15:33:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C21E3858410 Received: by mail-pg1-x533.google.com with SMTP id 83so10226786pgc.8 for ; Fri, 29 Oct 2021 08:33:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version:content-language; bh=gpZTSAmFV1DUFN4lzDIJbiil83y1NjuuCDOMnldVjUM=; b=vzyEBNzg9OPiB/yUy+QXeqjTuup4yIjhVVXoKYIUqUN1F6bnO1XVaNGruyRgUIoJgS V3T6JyYwSMIlEfoBsw4loCRKvjkvird3ZuHj29EqP1HJE1gtKZIUZa7qsJfFs+bSLNdU NTvP3S/TglGhWuz48RmFsAWKZOMnn+Okaanb9lVCiQ/0+xtXoNu5xxykZ4HNaB6OwkUS M0dqOYzb7UIW2AvMU5HRKUGNXUvSWAfg5zvGQKAsp4GPsdKOhFCPKwDC9m6ju4Y8ceLT nJu23SusVsecJU6Vdn6RUQXYX2NJEEUMG3T8KedFCclf0X0NgQCN7g6FexSbe54rYw1m RpVg== X-Gm-Message-State: AOAM533CYPqtCDwR3sz9j+8ye+pynUmdtLki6I1a8BuS6c5QIhcdLO/A JVHbeHdwmP1Uo8YeKCTJz/e/s4t+eBM= X-Google-Smtp-Source: ABdhPJxUs4NqE+gZpiAo4LmPvFhXwGdjH2kZy+fQgVXIZLHDNRzxGMkNP6yUAvbSAks5fOu1h7M4UQ== X-Received: by 2002:a05:6a00:10c3:b0:47c:305f:b318 with SMTP id d3-20020a056a0010c300b0047c305fb318mr11810933pfu.8.1635521606252; Fri, 29 Oct 2021 08:33:26 -0700 (PDT) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id mp16sm6590888pjb.1.2021.10.29.08.33.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 08:33:25 -0700 (PDT) To: GCC Patches Subject: [committed] Avoid overly-greedy match in dejagnu regexp. Message-ID: Date: Fri, 29 Oct 2021 09:33:24 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jeff Law via Gcc-patches From: Jeff Law Reply-To: Jeff Law Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Occasionally I've been seeing failures with the multi-line diagnostics.  It's never been clear what's causing the spurious failures, though I have long suspected a greedy regexp match. It happened again yesterday with a local change that in no way should affect diagnostics, so I finally went searching and found that sure enough the multi-line diagnostics had a ".*" in their regexp.  According to the comments, the .* is primarily to catch any dg directives that may appear -- ie it should eat to EOL, but not multiple lines.  But a .* can indeed match a newline and cause it to eat multiple lines. The fix is simple.  [^\r\n]* will eat to EOL, but not further. Regression tested on x86_64 and on our internal target. Committed to the trunk. Jeff commit 14c7757e9b751781360737f53b71f851fc356d3d Author: Jeff Law Date: Fri Oct 29 11:30:15 2021 -0400 Avoid overly-greedy match in dejagnu regexp. Occasionally I've been seeing failures with the multi-line diagnostics. It's never been clear what's causing the spurious failures, though I have long suspected a greedy regexp match. It happened again yesterday with a local change that in no way should affect diagnostics, so I finally went searching and found that sure enough the multi-line diagnostics had a ".*" in their regexp. According to the comments, the .* is primarily to catch any dg directives that may appear -- ie it should eat to EOL, but not multiple lines. But a .* can indeed match a newline and cause it to eat multiple lines. The fix is simple. [^\r\n]* will eat to EOL, but not further. Regression tested on x86_64 and on our internal target. gcc/testsuite * lib/multiline.exp (_build_multiline_regex): Use a better regexp than .* to match up to EOL. diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp index 0e151b6d222..86387f8209b 100644 --- a/gcc/testsuite/lib/multiline.exp +++ b/gcc/testsuite/lib/multiline.exp @@ -331,7 +331,7 @@ proc _build_multiline_regex { multiline index } { # Support arbitrary followup text on each non-empty line, # to deal with comments containing containing DejaGnu # directives. - append rexp ".*" + append rexp "\[^\\n\\r\]*" } } append rexp "\n"