Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site turing.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!turing!aeb From: aeb@turing.UUCP Newsgroups: net.sources.bugs Subject: Re: C program checker - cchk Message-ID: <211@turing.UUCP> Date: Tue, 16-Oct-84 21:19:53 EDT Article-I.D.: turing.211 Posted: Tue Oct 16 21:19:53 1984 Date-Received: Thu, 18-Oct-84 00:41:34 EDT References: <1210@utah-gr.UUCP> Organization: CWI, Amsterdam Lines: 35 Apparently-To: rnews@mcvax.LOCAL It is a good idea to have a program checking layout just as lint checks syntax. But cchk is not what we need. Some trivial comments on cchk: - STACKSIZ is too small and should be increased to at least 100 - When reading stdin no line numbers are given. - When checking several files the error reporting for files after the one containing the first error is buggy. - It gets into an infinite loop when confronted with a non-closed comment. (Ha! A new contest - what is the shortest input making cchk loop or making it dump core?) - It does not complain about wrong indentation for lines not containing parentheses like break; or continue; - It complains about constructions like if(this_is_true && and_this_as_well && and_also_this && we_must_do_something) { do_something(); } where the closing brace is in the right place, but the open brace is not on the same line as the if it belongs to. I fixed the problems mentioned above (and some others) but found the resulting program still almost useless for checking large pieces of C code - most of the error messages are caused by cchk's misunderstanding and not by objectionable coding practices. Of course the true fault of cchk is that it doesnt understand what it is reading - it does not even treat lines starting with a # specially. Braces that occur in the initialization of an array of large structures are aligned in a different way than braces for flow control or block structure. Cchk as it is now cannot complain about unexpected increase in indentation level, for "expected" depends on the surrounding syntax. Let us hope somebody is active enough to do the real job and use lex/yacc plus a C grammar. -- Andries Brouwer -- CWI, Amsterdam -- {philabs,decvax}!mcvax!aeb