From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 13DBF1F5AE for ; Sun, 18 Jul 2021 12:56:36 +0000 (UTC) Received: from localhost ([::1]:50838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m56LS-0003m0-LC for normalperson@yhbt.net; Sun, 18 Jul 2021 08:56:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m56LO-0003ft-Fk for bug-gnulib@gnu.org; Sun, 18 Jul 2021 08:56:30 -0400 Received: from freefriends.org ([96.88.95.60]:37036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m56LM-0006dn-Im for bug-gnulib@gnu.org; Sun, 18 Jul 2021 08:56:30 -0400 X-Envelope-From: arnold@skeeve.com Received: from freefriends.org (freefriends.org [96.88.95.60]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 16ICuEdJ027370 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 18 Jul 2021 06:56:15 -0600 Received: (from arnold@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 16ICuEjF027369; Sun, 18 Jul 2021 06:56:14 -0600 From: arnold@skeeve.com Message-Id: <202107181256.16ICuEjF027369@freefriends.org> X-Authentication-Warning: frenzy.freefriends.org: arnold set sender to arnold@skeeve.com using -f Date: Sun, 18 Jul 2021 06:56:14 -0600 To: eggert@cs.ucla.edu, bug-gnulib@gnu.org, arnold@skeeve.com Subject: Re: possible bug in regex and dfa References: <85ef7fe3-c793-f082-3df1-3011fd8d0966@cs.ucla.edu> In-Reply-To: <85ef7fe3-c793-f082-3df1-3011fd8d0966@cs.ucla.edu> User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=96.88.95.60; envelope-from=arnold@skeeve.com; helo=freefriends.org X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi. Paul Eggert wrote: > On 7/15/21 1:48 PM, Arnold Robbins wrote: > > The regexp used there, ".^", to my mind should be treated as invalid. > > No, that regular expression is valid because "." matches newline in > POSIX EREs. So the "." matches a newline, and the following "^" matches > the start of the next line. Bruno Haible wrote: > > No, that regular expression is valid because "." matches newline in > > POSIX EREs. > > And if you don't like this, you need to remove the RE_DOT_NEWLINE flag from > the value that you pass to re_set_syntax. Dot matching newline isn't the issue here. It's ^ matching in the middle of a string. For my purposes, ^ should only match at the beginning of a *string* (as $ should only match at the end of a string). I haven't rechecked POSIX, but this is how awk has behaved since forever. (And how I've documented things in the manual, also since forever.) For RS, gawk treats the concatenation of the input files as one long string, so ^ should only match at the very beginning, and $ at the very end. But even for strings the GNU regex routines seem to get it wrong: $ cat y.awk BEGIN { data = "a.^b\na.^b\n" gsub(/.^/, ">&<", data) print data } $ mawk -f y.awk # gets it right IMHO a.^b a.^b $ nawk -f y.awk nawk: syntax error in regular expression .^ at source line number 3 source file y.awk context is gsub(/.^/, ">&<", >>> data) <<< $ ./gawk -f y.awk a.^b> < Is there some way I can get the regex routines (and dfa) to relate to ^ and $ as relative to the *string* and not the *line*? Thanks, Arnold