SysV lint -> BSD lint format filter

Mark Moraes moraes at csri.toronto.edu
Fri Sep 8 10:29:04 AEST 1989


Maybe it's just that I'm used to BSD lint, but I find SysV lint output
rather hard to read.

- rather than the one line per error format that my editor could
parse, that I could grep and grep -v through, SysV lint now provides
several lines per error in the simpler cases, and even worse, a tabular
format for some cases.

The following is a quick awk filter to transform lint errors to
something close to BSD format. (Alas, you can't use 4.3 lint on the
Iris because some of the header files have prototypes. Has anyone made
pcc (the mip/ part) understand prototypes?)  The script probably
doesn't cover all the cases but it did work on several examples I
tried. The irrationality of the lint error message format should be
evident from the amount of awk needed to "sanitize" it.

The other useful trick is to use -u, -x and -h. The first two stop it
from complaining about all the external variables that there aren't a
lint library for, and aren't in your source. The -h stops it from
complaining about every use of malloc, or every pointer cast. (the
meaning of -h is the reverse of BSD lint)

#!/bin/sh
# To unbundle, sh this file
echo mungelint 1>&2
Adding file mungelint
sed 's/^-//' >mungelint <<'!'
-#! /bin/sh
-# Takes the absolutely horrendous mess that System V lint outputs and tries
-# to make it semi-parsable - i.e. more like the V7/BSD lint.
-# At least, Jove can now understand some of the error patterns.
-# If you ever see the '** Unmatched pattern' message, it means that this
-# script has exhausted its limited heuristic knowledge. Please try to come up
-# with a good rule for it and let me know. Thanks.
-# Mark Moraes, University of Toronto <moraes at cs.toronto.edu>
awk 'NF == 1 && $0 ~ /^[^ ]+/ && $1 != "==============" {
-	# print "*** pat1: " $0
-	maybefile = $1;
-	err="";
-	next;
-    }
-    NF == 1 && $1 == "==============" {
-	# print "*** pat2: " $0
-	file=maybefile;
-	err="";
-	next;
-    }
-    NF == 0 {
-	# print "*** pat3: " $0
-	maybefile = "";
-	file="XXXX";
-	err="";
-	next;
-    }
-    NF > 1 && $0 ~ /^[^:]+:[^()]+$/ {
-	# print "*** pat4: " $0
-	err=$0;
-	next;
-    }
-    NF > 1 && $0 ~ /^[^:]+: \([0-9]+\)/ {
-	line=$2;
-	$2="";
-	printf "%s%s: %s\n", file, line, $0;
-	next;
-    }
-    file != "" && $0 ~ /^ +\([0-9]+\)/ {
-	for(i = 1; i <= NF; i++) {
-	    printf "%s%s: %s\n", file, $i, err;
-	}
-	next;
-    }
-    file == "" && $0 ~ /^[^ ]/ {
-	err=$0;
-	next;
-    }
-    file == "" && NF > 0 && $0 ~ /^ +.*\([0-9]+\)/ {
-	proc=$1;
-	$1 = "";
-	printf "%s, %s  %s\n", proc, err, $0;
-	next;
-    }
-    file == "" && NF > 0 && $0 ~ /^ +[^ ]+/ {
-	for(i = 1; i <= NF; i++) {
-	    printf "%s %s\n", $i, err;
-	}
-	next;
-    }
-    { printf "Unmatched pattern: %s\n", $0}
-'
!
chmod +x mungelint
echo shar unpacked fully
exit





More information about the Comp.sys.sgi mailing list