From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 258173858D20; Wed, 9 Mar 2022 00:20:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 258173858D20 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7554] contrib: Fix non-portable sed commands in gcc-descr [PR102664/] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 8d038a841a6bb8e11c122d96e8f72b47ca3895c0 X-Git-Newrev: 17bffa0c9f90df49bde6671816bde04008b6c5af Message-Id: <20220309002058.258173858D20@sourceware.org> Date: Wed, 9 Mar 2022 00:20:58 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2022 00:20:58 -0000 https://gcc.gnu.org/g:17bffa0c9f90df49bde6671816bde04008b6c5af commit r12-7554-g17bffa0c9f90df49bde6671816bde04008b6c5af Author: Jonathan Wakely Date: Tue Mar 8 17:40:48 2022 +0000 contrib: Fix non-portable sed commands in gcc-descr [PR102664/] POSIX sed does not support \? or \+ in its Basic Regular Expression grammar. Replace the \(tags/\)\? part of the pattern with a substitution to remove ^tags/ before other substitutions. Replace \([0-9]\+\) with \([0-9][0-9]*\) or with \([1-9][0-9]*\) in release branch numbers, where a leading zero does not occur. contrib/ChangeLog: PR other/102664 * git-descr.sh: Use portable sed commands. * git-undescr.sh: Likewise. Diff: --- contrib/git-descr.sh | 6 +++--- contrib/git-undescr.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/git-descr.sh b/contrib/git-descr.sh index ba5d711f330..95363279d8c 100755 --- a/contrib/git-descr.sh +++ b/contrib/git-descr.sh @@ -18,11 +18,11 @@ do done if test x$short = xyes; then - r=$(git describe --all --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)-\([0-9]\+\)-g[0-9a-f]*$,r\2-\3,p;s,^\(tags/\)\?basepoints/gcc-\([0-9]\+\)$,r\2-0,p'); + r=$(git describe --all --match 'basepoints/gcc-[1-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-\([1-9][0-9]*\)-\([0-9][0-9]*\)-g[0-9a-f]*$,r\1-\2,p;s,^basepoints/gcc-\([1-9][0-9]*\)$,r\1-0,p'); elif test x$long = xyes; then - r=$(git describe --all --abbrev=40 --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^\(tags/\)\?basepoints/gcc-,r,p') + r=$(git describe --all --abbrev=40 --match 'basepoints/gcc-[1-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-,r,p') else - r=$(git describe --all --abbrev=14 --match 'basepoints/gcc-[0-9]*' $c | sed -n 's,^\(tags/\)\?basepoints/gcc-,r,p'); + r=$(git describe --all --abbrev=14 --match 'basepoints/gcc-[1-9]*' $c | sed -n 's,^tags/,,;s,^basepoints/gcc-,r,p') expr ${r:-no} : 'r[0-9]\+$' >/dev/null && r=${r}-0-g$(git rev-parse $c); fi; if test -n $r; then diff --git a/contrib/git-undescr.sh b/contrib/git-undescr.sh index 9d882a6814e..fd694077467 100755 --- a/contrib/git-undescr.sh +++ b/contrib/git-undescr.sh @@ -3,11 +3,11 @@ # Script to undescribe a GCC revision o=$(git config --get gcc-config.upstream); -r=$(echo $1 | sed -n 's,^r\([0-9]\+\)-[0-9]\+\(-g[0-9a-f]\+\)\?$,\1,p'); -n=$(echo $1 | sed -n 's,^r[0-9]\+-\([0-9]\+\)\(-g[0-9a-f]\+\)\?$,\1,p'); +r=$(echo $1 | sed -n 's,^r\([1-9][0-9]*\)-[0-9][0-9]*\(-g[0-9a-f]*\)*$,\1,p'); +n=$(echo $1 | sed -n 's,^r[1-9][0-9]*-\([0-9][0-9]*\)\(-g[0-9a-f]*\)*$,\1,p'); test -z $r && echo Invalid id $1 && exit 1; h=$(git rev-parse --verify --quiet ${o:-origin}/releases/gcc-$r); test -z $h && h=$(git rev-parse --verify --quiet ${o:-origin}/master); -p=$(git describe --all --match 'basepoints/gcc-'$r $h | sed -n 's,^\(tags/\)\?basepoints/gcc-[0-9]\+-\([0-9]\+\)-g[0-9a-f]*$,\2,p;s,^\(tags/\)\?basepoints/gcc-[0-9]\+$,0,p'); +p=$(git describe --all --match 'basepoints/gcc-'$r $h | sed -n 's,^tags/,,;s,^basepoints/gcc-[1-9][0-9]*-\([0-9][0-9]*\)-g[0-9a-f]*$,\1,p;s,^basepoints/gcc-[1-9][0-9]*$,0,p'); git rev-parse --verify $h~$(expr $p - $n);