public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, 5/5] check_GNU_style.sh: Fix tab size in 80 characters check
Date: Tue, 12 May 2015 07:41:00 -0000	[thread overview]
Message-ID: <5551ABF1.7040908@mentor.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

Hi,

this patch fixes a problem in the 80 characters length check.

Currently tab width is not properly calculated.

The patch uses expand to interpret tabs properly.

OK for trunk?

Thanks,
- Tom


[-- Attachment #2: 0005-check_GNU_style.sh-Fix-tab-size-in-80-characters-che.patch --]
[-- Type: text/x-patch, Size: 1462 bytes --]

[PATCH 5/5] check_GNU_style.sh: Fix tab size in 80 characters check

2015-05-11  Tom de Vries  <tom@codesourcery.com>

	* check_GNU_style.sh (col): Fix tab size.
---
 contrib/check_GNU_style.sh | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 318eb6a..90c612f 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -116,13 +116,37 @@ vg (){
 
 col (){
     msg="$1"
-    cat $inp \
-	| awk -F':\\+' '{ if (length($2) > 80) print $0}' \
-	> $tmp
-    if [ -s $tmp ]; then
-	printf "\n$msg\n"
-	cat $tmp
-    fi
+    local first=true
+    local f
+    for f in $files; do
+	local prefix=""
+	if [ $nfiles -ne 1 ]; then
+	    prefix="$f:"
+	fi
+
+	# Don't reuse $inp, which may be generated using -H and thus contain a
+	# file prefix.
+	grep -n '^+' $f \
+	    | grep -v ':+++' \
+	    > $tmp
+
+	cat $tmp | while IFS= read -r line; do
+	    local longline
+	    # Filter out the line number prefix and the patch line modifier '+'
+	    # to obtain the bare line, before we use expand.
+	    longline=$(echo "$line" \
+		| sed 's/^[0-9]*:+//' \
+		| expand \
+		| awk '{ if (length($0) > 80) print $0}')
+	    if [ "$longline" != "" ]; then
+		if $first; then
+		    printf "\n$msg\n"
+		    first=false
+		fi
+		echo "$prefix$line"
+	    fi
+	done
+    done
 }
 
 col 'Lines should not exceed 80 characters.'
-- 
1.9.1



             reply	other threads:[~2015-05-12  7:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12  7:41 Tom de Vries [this message]
2015-05-12 15:18 ` Jeff Law
2015-05-18  8:14   ` Tom de Vries
2015-05-18 15:52     ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5551ABF1.7040908@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).