[net.lang.c] Style filters

larry@jpl-vlsi.arpa (01/16/86)

On a large project here we've decided to use C.  Management is talking about 
imposing a style standard, and I don't like the idea of using someone else's.
Anyone have a tailorable filter program that programmers can use to 



















convert from one style to another?  That way each of us could use our own 
style but deliver what the bosses require.

Also, I'm not sure if EMACS will be availble on the systems we'll use (at least till I port GNU EMACS to them).  Is there some way to add an electric-C to VI?

Please answer directly to me since I'm not yet on the INFO-C distribution list.

				Larry @ jpl-vlsi

chris@maryland.arpa (Chris Torek) (01/20/86)

4.3BSD will come with a program called `indent', which is a rewrite
of James Gosling's rewrite of the program from the University of
Illinois.  The program has an amazing number of options to control
its output (48, to be exact, though one of those is not output
control); default plus two options and it emits `Joy normal form'
code (4.2/4.3 kernel style).

As most people seem to be concerned with brace style, I will describe
indent's treatment of braces.  It currently handles the following two
styles:

	if (...)
	{
		code
	}

or

	if (...) {
		code
	}


It does not do

	if (...)
		{
		code
		}

which is somewhat unfortunate; I almost added it but gave up since
I myself do not use it, and since that particular translation can
be accomplished with a `sed' script in emergencies.

It *is*, however, able to produce code formatted almost the same
as the `indent' that came with Gosling Emacs.  I felt that this
was important enough for us diff-listing-people that I added two
or three of those options just to make it possible.

Oh yes, one final note:  Unless someone has changed it or the
program recently, the manual really is correct.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

wjm@teddy.UUCP (01/22/86)

In article <1748@brl-tgr.ARPA> chris@maryland.arpa (Chris Torek) writes:
>4.3BSD will come with a program called `indent', which is a rewrite

4.2BSD already comes with the indent program.

>of James Gosling's rewrite of the program from the University of
>Illinois.  The program has an amazing number of options to control
>its output (48, to be exact, though one of those is not output
>control); default plus two options and it emits `Joy normal form'
>code (4.2/4.3 kernel style).
>
>As most people seem to be concerned with brace style, I will describe
>indent's treatment of braces.  It currently handles the following two
>styles:
>
>	if (...)
>	{
>		code
>	}
>
>or
>
>	if (...) {
>		code
>	}
>
>
>It does not do
>
>	if (...)
>		{
>		code
>		}
>
>which is somewhat unfortunate; I almost added it but gave up since
>I myself do not use it, and since that particular translation can
>be accomplished with a `sed' script in emergencies.

I have modified indent to support the third bracket/indentation
style.  I have posted a copy of the diff's to indent to net.sources.

						Enjoy
						bill masek

chris@mit-bugs-bunny.arpa (01/25/86)

In article <1970@teddy.UUCP> wjm@teddy.UUCP writes:
>> In article <1748@brl-tgr.ARPA> chris@maryland.arpa (Chris Torek) writes:
>> 4.3BSD will come with a program called `indent', which is a rewrite
> 4.2BSD already comes with the indent program.

The most recent rewrite was done between 4.2 and 4.3.  It fixes a
number of glitches and makes the program able to generate kernel
style code (previously it always put space around the `->' operator,
for example).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

earle@smeagol.UUCP (Greg Earle) (01/30/86)

> 4.3BSD will come with a program called `indent', which is a rewrite
> of James Gosling's rewrite of the program from the University of
> Illinois.  The program has an amazing number of options to control
> its output (48, to be exact, though one of those is not output
> control); default plus two options and it emits `Joy normal form'
> code (4.2/4.3 kernel style).

My Sun-2 running 4.2 has indent(1).  I counted 13 total command line
options (some of which are either/or, however).  Is the 4.3 version the
same program, only a newer superset?  Is indent(1) in normal 4.2BSD
distributions?  In other words, do we have it because J.G. is now with Sun?

> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
> UUCP:	seismo!umcp-cs!chris
> CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

	Greg Earle
	JPL Spacecraft Data Systems group
	sdcrdcf!smeagol!earle (UUCP)
	ia-sun21smeagol!earle@csvax.caltech.edu (ARPA)