From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by sourceware.org (Postfix) with ESMTPS id D4E1B386F460 for ; Mon, 27 Jun 2022 09:54:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D4E1B386F460 Received: by mail-vs1-xe2c.google.com with SMTP id k25so8445285vso.6 for ; Mon, 27 Jun 2022 02:54:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cIWcEd+WAiuKxm36UqwgkQan4MAZXF5RR+rYE68/rDc=; b=uuq4/LwolbvHsnpxHhpE9HYzw/oOEy51eAmZrqSSUTP44KjnPQ1CepHlo7pM0pleCt mfIhYdTxH/AZEKUWz99MN6Om719F5RkCxJI76j6XhLKrPlhJk1AI8CdYucTOZkVM+Rn3 BcT0+cpI2mde/oa/l4ViMwS8F2fPOTDiLb8P0fyrl0sNwverF/wb5xzRbA5QMp0pBgG4 RFs6jE4KDuI1jsD6PG1GJkm8YcKdCYrM1AwMTAmsO4ZMOy8P5CtTr8uMV7VZStAnGBPk X8X6Wun6i4vSeB1fxe+3zimA+lN5mc6ozz2T9vEioHKDsk9jaiUkGLJOzhfb+eTVRlNJ XfTQ== X-Gm-Message-State: AJIora/edu40cw4lzF15D+KCWJo19VvvAH66lezREgORc6oPxM/cw21a lQNg9CONPbQXibaaN1Z4kLTv4ZL0GMK8ccgFwlU0rw== X-Google-Smtp-Source: AGRyM1uVWvrb4IXygUd65Y+kY1dU2ZwtZuFkSL9fpmq231//uhPOK4lhHFwTlTPtnvJnJtKWWkVIYbE3hZI1p86BQvY= X-Received: by 2002:a05:6102:3198:b0:354:2d44:5927 with SMTP id c24-20020a056102319800b003542d445927mr4086222vsh.44.1656323678173; Mon, 27 Jun 2022 02:54:38 -0700 (PDT) MIME-Version: 1.0 References: <7fb2f97f1bd0dacf2eab76849412c1dcda42874f.camel@xry111.site> In-Reply-To: <7fb2f97f1bd0dacf2eab76849412c1dcda42874f.camel@xry111.site> From: Eric Gallager Date: Mon, 27 Jun 2022 05:54:27 -0400 Message-ID: Subject: Re: [PATCH v2 2/7] fixincludes: use grep instead of egrep/fgrep To: Xi Ruoyao Cc: gcc-patches , Bernhard Reutner-Fischer , Jonathan Wakely Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Mon, 27 Jun 2022 09:54:40 -0000 On Mon, Jun 27, 2022 at 2:10 AM Xi Ruoyao via Gcc-patches wrote: > > egrep/fgrep has been deprecated in favor of grep -E/-F for a long time, > and the next grep release (3.8 or 4.0) will print a warning if egrep or > fgrep is used. Stop using egrep and fgrep so we won't see the warning. > > But, we can't simply replace egrep to grep -E or fgrep to grep -F or the > build will break with some non-GNU grep implementations (lacking -E or > -F support). autoconf documentation suggests to use AC_PROG_EGREP and > $EGREP or AC_PROG_FGREP and FGREP, but doing so is too complicated for > fixincludes. > > So we simply adjust the patterns for a plain grep, instead of relying on > the behavior of grep -E/-F. > > Q: Why "[ \t][ \t]*" instead of "[ \t]\\+"? > A: POSIX does not allow escaping + in BRE. > > fixincludes/ChangeLog: > > * fixinc.in: Use grep instead of egrep. > * inclhack.def: Use grep instead of egrep, and adjust an > regular expression to make it a BRE. > * genfixes: Use grep instead of egrep, and escape "." in the > pattern. > * fixincl.x: Regenerate. > --- > fixincludes/fixinc.in | 2 +- > fixincludes/fixincl.x | 10 +++++----- > fixincludes/genfixes | 2 +- > fixincludes/inclhack.def | 6 +++--- > 4 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/fixincludes/fixinc.in b/fixincludes/fixinc.in > index 0bd8027a554..a4cd3d0fbb4 100755 > --- a/fixincludes/fixinc.in > +++ b/fixincludes/fixinc.in > @@ -448,7 +448,7 @@ while [ $# != 0 ]; do > chmod a+r $3 2>/dev/null > if test $VERBOSE -gt 2 > then echo Copied $2 ; fi > - for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | > + for include in `grep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | > sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'` > do > dir=`echo $2 | sed -e s'|/[^/]*$||'` > diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x > index bad490453b7..c9b4cf504f2 100644 > --- a/fixincludes/fixincl.x > +++ b/fixincludes/fixincl.x > @@ -2,11 +2,11 @@ > * > * DO NOT EDIT THIS FILE (fixincl.x) > * > - * It has been AutoGen-ed February 27, 2022 at 07:47:03 PM by AutoGen 5.18.16 > + * It has been AutoGen-ed June 25, 2022 at 12:44:14 PM by AutoGen 5.18.16 > * From the definitions inclhack.def > * and the template file fixincl > */ > -/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Feb 27 19:47:03 UTC 2022 > +/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jun 25 12:44:14 CST 2022 So, this is kind of a tangent, but since GCC has migrated from SVN to git, perhaps it's time to update this comment? > * > * You must regenerate it. Use the ./genfixes script. > * > @@ -6547,7 +6547,7 @@ static tTestDesc aMath_Huge_Val_From_Dbl_MaxTests[] = { > * Fix Command Arguments for Math_Huge_Val_From_Dbl_Max > */ > static const char* apzMath_Huge_Val_From_Dbl_MaxPatch[] = { "sh", "-c", > - "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\ > + "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h | sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n\ > \tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n\ > \tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/s@DBL_MAX@'\"$dbl_max_def@\"\n\ > \telse cat\n\ > @@ -10402,9 +10402,9 @@ tSCC zVxworks_Needs_VxworksSelect0[] = > tSCC zVxworks_Needs_VxworksTest0[] = > " -r types/vxTypesOld.h"; > tSCC zVxworks_Needs_VxworksTest1[] = > - " -n \"`egrep '#include' $file`\""; > + " -n \"`grep '#include' $file`\""; > tSCC zVxworks_Needs_VxworksTest2[] = > - " -n \"`egrep ULONG $file`\""; > + " -n \"`grep ULONG $file`\""; > > #define VXWORKS_NEEDS_VXWORKS_TEST_CT 4 > static tTestDesc aVxworks_Needs_VxworksTests[] = { > diff --git a/fixincludes/genfixes b/fixincludes/genfixes > index 47aad01289d..3a4c05c832b 100755 > --- a/fixincludes/genfixes > +++ b/fixincludes/genfixes > @@ -58,7 +58,7 @@ done > AG="autogen $AG" > set -e > > -if [ -z "`${AG} -v | fgrep ' 5.'`" ] > +if [ -z "`${AG} -v | grep ' 5\.'`" ] > then > echo "AutoGen appears to be out of date or not correctly installed." > echo "Please download and install from:" > diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def > index 7605ac89aa2..080bbc010dc 100644 > --- a/fixincludes/inclhack.def > +++ b/fixincludes/inclhack.def > @@ -3274,7 +3274,7 @@ fix = { > * If we do, we will replace the one in math.h with that one. > */ > > - "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " > + "\tdbl_max_def=`grep 'define[ \t][ \t]*DBL_MAX[ \t][ \t]*.*' float.h " > "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n" > > "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n" > @@ -5266,8 +5266,8 @@ fix = { > hackname = vxworks_needs_vxworks; > files = sys/stat.h; > test = " -r types/vxTypesOld.h"; > - test = " -n \"`egrep '#include' $file`\""; > - test = " -n \"`egrep ULONG $file`\""; > + test = " -n \"`grep '#include' $file`\""; > + test = " -n \"`grep ULONG $file`\""; > select = "#[ \t]define[ \t]+__INCstath"; > > sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" > -- > 2.36.1 > >