summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-12-10 10:32:29 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-12-10 10:32:29 -0200
commit5b66fb825576bc376413e7dc4f936b97ee5e5553 (patch)
tree45625d0c2b4a144375c9f5df5b11dbf461f44965
parent61e5a6aab4808f04a473de863f5a902dab216b93 (diff)
downloadmediapointer-dvb-s2-5b66fb825576bc376413e7dc4f936b97ee5e5553.tar.gz
mediapointer-dvb-s2-5b66fb825576bc376413e7dc4f936b97ee5e5553.tar.bz2
Improve check.pl to support gcc error style, and terse
From: Mauro Carvalho Chehab <mchehab@infradead.org> With "make checkpatch", all c-compilation error parsers will be able to handle the error codes, allowing the user to navigate inside codingstyle errors as if they where generated by gcc. "make terse" will produce error codes using terse syntax, also common on development tools. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--INSTALL9
-rw-r--r--v4l/Makefile7
-rwxr-xr-xv4l/scripts/check.pl77
3 files changed, 88 insertions, 5 deletions
diff --git a/INSTALL b/INSTALL
index 5812774d9..bad6ca80b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -108,3 +108,12 @@ commit - commits the change, asking for a commit msg
push - sends outgoing stuff to master repository
checkemacs - checks codingstyle and reports to emacs
+ using "make checkemacs" at emacs compile menu,
+ will report the lines with errors inside emacs.
+
+checkpatch - checks codingstyle and reports using the same
+ format as c. This way, c error parsers will
+ handle it.
+
+checkterse - checks codingstyle and reports using terse
+ syntax, used on several compilaton tools.
diff --git a/v4l/Makefile b/v4l/Makefile
index f78842c70..60bf0b317 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -43,6 +43,7 @@ default:: config-compat.h Makefile.media links oss
@echo Kernel build directory is $(OUTDIR)
$(MAKE) -C $(OUTDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules
./scripts/rmmod.pl check
+# $(MAKE) checkpatch
#################################################
# Object specific rules
@@ -399,6 +400,12 @@ push::
checkemacs::
scripts/check.pl
+checketerse::
+ scripts/check.pl -t
+
+checkpatch::
+ scripts/check.pl -c
+
#################################################
# Help
help::
diff --git a/v4l/scripts/check.pl b/v4l/scripts/check.pl
index 3e6eb6e47..4958e281b 100755
--- a/v4l/scripts/check.pl
+++ b/v4l/scripts/check.pl
@@ -1,14 +1,46 @@
#!/usr/bin/perl
+use Getopt::Std;
+use strict;
+
+my $c_syntax=0;
+my $fmt="--emacs";
+
+my %opt;
+
+sub usage ($)
+{
+ my $name = shift;
+ printf "Usage: %s [<args>] [<file>]\n".
+ "\t-c\tc style\n".
+ "\t-e\emacs style (default)\n".
+ "\t-t\terse style (default)\n".
+ "\t<file>\tfile name to open. If file not specified, uses hg diff\n\n", $name;
+
+ exit -1;
+}
+
+if (not getopts('cet',\%opt) or defined $opt{'h'}) {
+ usage($0);
+}
my $cmd=shift;
+if ($opt{'c'}) {
+ $c_syntax=1;
+}
+
+if ($opt{'t'}) {
+ $fmt="--terse";
+ $c_syntax=0;
+}
+
if ($cmd) {
$cmd="diff -upr /dev/null $cmd";
} else {
$cmd="hg diff";
}
-$checkpatch=$ENV{CHECKPATCH};
+my $checkpatch=$ENV{CHECKPATCH};
if (!$checkpatch) {
$checkpatch="/lib/modules/`uname -r`/build/scripts/checkpatch.pl";
@@ -43,9 +75,44 @@ while (<IN>) {
}
close IN;
-open IN,"$cmd | $checkpatch -q --nosignoff --emacs -|";
-while (<IN>) {
- s|#[\d]+:\s*FILE:\s*|../|;
- print "$_";
+open IN,"$cmd | $checkpatch -q --nosignoff $fmt -|";
+
+my $err="";
+my $errline="";
+my $file="";
+my $ln_numb;
+
+my $pwd=`pwd`;
+$pwd =~ s|/[^/]+\n$||;
+
+sub print_err()
+{
+ if ($err) {
+ printf STDERR "%s/%s: In '%s':\n", $pwd, $file, $errline;
+ printf STDERR "%s/%s:%d: %s\n", $pwd, $file, $ln_numb, $err;
+ $err="";
+ }
+}
+
+if ($c_syntax == 0) {
+ while (<IN>) {
+ s|^#[\d]+:\s*FILE:\s*|../|;
+ print "$_";
+ }
+} else {
+ while (<IN>) {
+ if (m/^\+(.*)\n/) {
+ $errline=$1;
+ } elsif (m/^\#\s*[\d]+\s*:\s*FILE:\s*([^\:]+)\:([\d]+)/) {
+ $file=$1;
+ $ln_numb=$2;
+ } elsif (m/^\-\s*\:\d+\:\s*(.*)\n/) {
+ print_err();
+ $err = $1;
+ $err =~ s/WARNING/warning/;
+ }
+# print "# $_";
+ }
}
close IN;
+print_err();