[net.unix-wizards] 4.?bsd

ado@elsie.UUCP (Arthur David Olson) (09/25/84)

Bugged:	/usr/bin/lint

Bugs:	lint sometimes wrongly believes you've used a "-n" or "-p" option;
	it gives a dumb error message if you use "-O";
	it mishandles cases where "-p" is used with "-l".

Repeat by:
	First bug:
		cat << EOF > file.c
		#include <stdio.h>

		main()
		{
			printf("%s\n", "Hello");
			printf("Goodbye\n");
		}
		EOF
		lint -DNONSENSE file.c
		lint -Dnonsense file.c

		...and note that the two lint runs give different results.

	Second bug:
		echo 'main(){}' > file.c
		lint -O file.c

		...and note the spurious diagnostic.

	Third bug:
		cat << EOF > file.c
		#include <stdio.h>
		#include <curses.h>

		main()
		{
			werase(stdscr);
		}
		EOF
		lint file.c -lcurses
		lint -p file.c -lcurses

		...and note the spurious complaint about argument use
		   from the second lint run.

Analysis:
	First bug:
		The "/usr/bin/lint" script mistakes any argument of the form
		"-*n*", even something like "-Dnonsense", for "-n".

	Second bug:
		The "/usr/bin/lint" script passes any "-O" argument to
		"/lib/cpp", which has no idea what to do with it.

	Third bug:
		While two "pre-compiled" versions of "lint library files"
		are maintained for "stdio" functions--one version to be used
		when you say "lint -p", the other to be used when you leave
		off the "-p"--there's only one version of such files for things
		like the "curses" library.

Fix:		I recommend copying "/usr/bin/lint" to "/usr/local/lint"
		(or whatever your "local" directory is), then applying these
		edits.  The trade secret status of "/usr/bin/lint" precludes
		posting things in a clearer way.

		ed - lint << EOF
		/-\*n\*/i
			-[IDU]*) ;;
			-l*)	;;
		.
		/IDOU/s//IDU/
		/-l.*cat/c
			-l*)	case \$P in
				port)	( /lib/cpp \$O \$LL/llib\$A |
					\${L}1 -v\$X >> \$T ) 2>&1 ;;
				*)	cat \$LL/llib\$A.ln >> \$T ;;
				esac ;;
		.
		/\*\.ln)/m/-\*)/
		w
		q
		EOF
--
UNIX and Bugs are AT&T Bell Laboratories and Warner Brothers trademarks.
--
	...decvax!seismo!umcp-cs!elsie!ado	(301) 496-5688
	DEC, VAX and Elsie are Digital Equipment Corp. and Borden's trademarks.