Personal style -vs- Standards

Chris Torek chris at mimsy.UUCP
Fri Dec 23 16:54:31 AEST 1988


>In article <519 at midgard.Midgard.MN.ORG> dal at midgard.Midgard.MN.ORG
>(Dale Schumacher) writes:
>>... the 'cb' type programs I've seen have the major disadvantage that
>>the formatting rules are hard coded and even at that, don't seem to do
>>a very good job of fully converting to a consistent style.

In article <88Dec21.213900est.10762 at ephemeral.ai.toronto.edu>
bradb at ai.toronto.edu (Brad Brown) writes:
>cb from Polytron can be given flags that tell it when to break lines. ...
>
>The C-DOC package from Software Blacksmith's Inc. is a complete documentation
>package that handles reformatting and cross references and a whole bunch of
>things. ...

C-DOC may do more; but there is a program supplied with 4.3BSD called
`indent' that (while it has some nontrivial bugs) does a fairly good
job.  It has over 15 boolean options alone:

Boolean:
( on |  off )		(if on)
-bad | -nbad		force blank line after block of declarations
-bap | -nbap		force blank line after procedure body
-bbb | -nbbb		force blank line before block comment
-bc  | -nbc		force newline after each comma in declarations
-ce  | -nce		force `} else {' format (vs }\nelse)
-dj  | -ndj		left-justify declarations
-ei  | -nei		handle `else if' as a unit (vs else\n\tif)
-fc1 | -nfc1		enable formatting comments starting in col 1
-ip  | -nip		do indent parameter declarations
-lp  | -nlp		line up continuations under unclosed parentheses
-pcs | -npcs		put space after procedure call: `fn (arg1, arg2)'
-ps  | -nps		put spaces around `->': `p -> field'
-psl | -npsl		put procedure names on col 1 (int\nfoo())
-sc  | -nsc		put stars `*' at left edge of multi-line comments
-sob | -nsob		swallow (eat) certain optional blank lines
				(this is basically to undo -bad above)
-v   | -nv		be verbose (to stderr)

Numeric:
(name)			(function)
-c			column for comments on code lines
-cd			column for comments on declaration lines
-ci			continuation line (extra) indentation
-cli			case label indent (in `tab stops'; can be 0.0<n<1.0)
-d			comment dedentation (in tab stops)
-di			identifier (extra) indent after decl keyword (in chars)
-i			width of a tab (also affects, e.g., -cli)
-l			max output line length (soft; may sometimes exceed it)

Other:
-br | -bl		brace style (needs more options)
-cdb | -ncdb		block comment style (`delimited' or not)
-npro			ignore ./.indent.pro and ~/.indent.pro
-st			read stdin, write stdout
-T typename		make `typename' a type keyword a la int, long, etc
-troff			generate troff commands to pretty-print a la vgrind

And, from the `bugs' section of the manual:

	Indent has even more switches than \fIls\fR.

(Indent is *not* public domain: it carries a copyright notice from
the University of Illinois Board of Trustees.  I imagine it is
redistributable, but it would be wise to ask UI first.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list