From patchwork Mon Jul 21 06:25:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Gribov X-Patchwork-Id: 372000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A7B4B140181 for ; Mon, 21 Jul 2014 18:15:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=vzbtCgB+MMDTVcab0w/ng0jxeWoQ6ivU7vRy9dv7KLA UWMSatOvI5rhfnyC8Xd+xfOEjixUDQ83RqPxJc39ju8mV/WDD2+LLBFduna/m+r+ IFl79meEWhyT+nFvUm4gywPh0RLAbIbWgRM7d0dqieXdGGYSL1HSqIouRDDwQj1A = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=sIiE+qJkIcvrrAYQXGlTnEuNWWQ=; b=s6KKXT8DbL0khStc5 kl/m05mEEMLc7vQj0O0AcL2ynnPWyOrmosa48hL0Uq4kcEE4Mota678FeyrhW6QA o6R3vEaRZ6UysFknniQfDbMrF7LnOvXVE/vmkMGUiz7fsqQgtwE06p0XvW4/vvkb 1kpO4m3vPvNVp5ZVJQE+8/qr8M= Received: (qmail 18676 invoked by alias); 21 Jul 2014 06:25:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 18659 invoked by uid 89); 21 Jul 2014 06:25:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham version=3.3.2 X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Mon, 21 Jul 2014 06:25:36 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9100J37TUEGH30@mailout1.w1.samsung.com> for gcc-patches@gcc.gnu.org; Mon, 21 Jul 2014 07:25:26 +0100 (BST) Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 7E.75.27902.B52BCC35; Mon, 21 Jul 2014 07:25:31 +0100 (BST) Received: from [106.109.9.145] by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N9100G3JTUG9Z50@eusync3.samsung.com>; Mon, 21 Jul 2014 07:25:31 +0100 (BST) Message-id: <53CCB258.6050905@samsung.com> Date: Mon, 21 Jul 2014 10:25:28 +0400 From: Yury Gribov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-version: 1.0 To: GCC Patches Cc: Sebastian Pop , Christophe Lyon Subject: [PATCH] New check and updates in check_GNU_style script Content-type: multipart/mixed; boundary=------------090101040204030304000205 X-IsSubscribed: yes Hi all, Attached patch adds new check (all blocks of 8 spaces are replaced with tabs) to contrib/check_GNU_style.sh. It also changes the script to allow reading patches from stdin and improves the "Dot, space, space, new sentence." check. -Y commit 4bc624dcd778e8317a4de620b266c05b55577aad Author: Yury Gribov Date: Mon Jul 21 10:12:24 2014 +0400 2014-07-21 Yury Gribov check_GNU_style.sh: Support patches coming from stdin, check that spaces are converted to tabs and make double-space check more precice. diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh index ef8fdda..d61dc96 100755 --- a/contrib/check_GNU_style.sh +++ b/contrib/check_GNU_style.sh @@ -23,6 +23,8 @@ usage() { check_GNU_style.sh [patch]... Checks the patches for some of the GNU style formatting problems. + When FILE is -, read standard input. + Please note that these checks are not always accurate, and complete. The reference documentation of the GNU Coding Standards can be found here: http://www.gnu.org/prep/standards_toc.html @@ -35,19 +37,22 @@ EOF test $# -eq 0 && usage +inp=check_GNU_style.inp tmp=check_GNU_style.tmp # Remove $tmp on exit and various signals. -trap "rm -f $tmp" 0 -trap "rm -f $tmp ; exit 1" 1 2 3 5 9 13 15 +trap "rm -f $inp $tmp" 0 +trap "rm -f $inp $tmp ; exit 1" 1 2 3 5 9 13 15 + +grep -nH '^+' $* \ + | grep -v ':+++' \ + > $inp # Grep g (){ msg="$1" arg="$2" - shift 2 - grep -nH '^+' $* \ - | grep -v ':+++' \ + cat $inp \ | egrep --color=always -- "$arg" \ > $tmp && printf "\n$msg\n" cat $tmp @@ -58,9 +63,7 @@ ag (){ msg="$1" arg1="$2" arg2="$3" - shift 3 - grep -nH '^+' $* \ - | grep -v ':+++' \ + cat $inp \ | egrep --color=always -- "$arg1" \ | egrep --color=always -- "$arg2" \ > $tmp && printf "\n$msg\n" @@ -72,9 +75,7 @@ vg (){ msg="$1" varg="$2" arg="$3" - shift 3 - grep -nH '^+' $* \ - | grep -v ':+++' \ + cat $inp \ | egrep -v -- "$varg" \ | egrep --color=always -- "$arg" \ > $tmp && printf "\n$msg\n" @@ -83,9 +84,7 @@ vg (){ col (){ msg="$1" - shift 1 - grep -nH '^+' $* \ - | grep -v ':+++' \ + cat $inp \ | cut -f 2 -d '+' \ | awk '{ if (length ($0) > 80) print $0 }' \ > $tmp @@ -95,30 +94,32 @@ col (){ fi } -col 'Lines should not exceed 80 characters.' $* +col 'Lines should not exceed 80 characters.' + +g 'Blocks of 8 spaces should be replaced with tabs.' \ + ' {8}' g 'Trailing whitespace.' \ - '[[:space:]]$' $* + '[[:space:]]$' g 'Space before dot.' \ - '[[:alnum:]][[:blank:]]+\.' $* + '[[:alnum:]][[:blank:]]+\.' g 'Dot, space, space, new sentence.' \ - '[[:alnum:]]\.([[:blank:]]|[[:blank:]]{3,})[[:alnum:]]' $* + '[[:alnum:]]\.([[:blank:]]|[[:blank:]]{3,})[A-Z0-9]' g 'Dot, space, space, end of comment.' \ - '[[:alnum:]]\.([[:blank:]]{0,1}|[[:blank:]]{3,})\*/' $* + '[[:alnum:]]\.([[:blank:]]{0,1}|[[:blank:]]{3,})\*/' g 'Sentences should end with a dot. Dot, space, space, end of the comment.' \ - '[[:alnum:]][[:blank:]]*\*/' $* + '[[:alnum:]][[:blank:]]*\*/' vg 'There should be exactly one space between function name and parentheses.' \ - '\#define' '[[:alnum:]]([^[:blank:]]|[[:blank:]]{2,})\(' $* + '\#define' '[[:alnum:]]([^[:blank:]]|[[:blank:]]{2,})\(' g 'There should be no space before closing parentheses.' \ - '[[:graph:]][[:blank:]]+\)' $* + '[[:graph:]][[:blank:]]+\)' ag 'Braces should be on a separate line.' \ - '\{' 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\(' $* - + '\{' 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\('