From patchwork Fri Feb 24 19:16:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 65616 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 CA0A1385483F for ; Fri, 24 Feb 2023 19:16:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA0A1385483F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677266195; bh=dmDUoP7AfheEW7axIB/88pJwIRs4yNYXDZ1CcJNgh7Q=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ooJ/8Lbp4ryilA3x1LQOqXtJAOeCXm6OLMl0Epd7RzPxbvQMSkoy2oojcCuVhDMRR pmGpSi+GB1g8ZoLuFzBU5XwaEjpb2r175GZomIgtn3/F9lkNx3TNslMbBlhfBoMAFi 17jYmb+R6rcrGtEIMMPg1sw9Mb7OwxEkbcgX6iLc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id CE0C53857C45 for ; Fri, 24 Feb 2023 19:16:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE0C53857C45 To: Subject: [PATCH 1/2] testsuite: Provide means to regexp in multiline patterns MIME-Version: 1.0 Message-ID: <20230224191603.3935F20447@pchp3.se.axis.com> Date: Fri, 24 Feb 2023 20:16:03 +0100 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Ok to commit? -- >8 -- Those multi-line-patterns are literal. Sometimes a regexp needs to be matched. This is a start: just three elements are supported: "(" ")" and the compound ")?" (and on second thought, it can be argued that "(...)" alone is not useful). Note that Tcl "string map" is documented to have the desired effect: a once-over but no re-recognitions of previously replaced mapped elements. Also, drop a doubled "containing". testsuite: * lib/multiline.exp (_build_multiline_regex): Map "{re:" to "(", ":re}" to ")" and ":re?}" to ")?". --- gcc/testsuite/lib/multiline.exp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp index 5eccf2bbebc1..f746bc3a618e 100644 --- a/gcc/testsuite/lib/multiline.exp +++ b/gcc/testsuite/lib/multiline.exp @@ -297,7 +297,7 @@ proc _get_lines { filename first_line last_line } { # Convert $multiline from a list of strings to a multiline regex # We need to support matching arbitrary followup text on each line, -# to deal with comments containing containing DejaGnu directives. +# to deal with comments containing DejaGnu directives. proc _build_multiline_regex { multiline index } { verbose "_build_multiline_regex: $multiline $index" 4 @@ -307,7 +307,10 @@ proc _build_multiline_regex { multiline index } { verbose " line: $line" 4 # We need to escape "^" and other regexp metacharacters. - set line [string map {"^" "\\^" + set line [string map {"\{re:" "(" + ":re?\}" ")?" + ":re\}" ")" + "^" "\\^" "(" "\\(" ")" "\\)" "[" "\\["