You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1996/07/15 18:29:14 UTC

Oh no! Not that list again...

Yes, here it is again. Note that a new section, 15, has been added. Also note
that MANY people have not bothered to vote on the later sections. Get yer act
together, guys!

As usual, check your votes, and apologies if I've missed any.

Cheers,

Ben.



1. Function declarations
Note: Illustrated using 7a.

a) int
   main(...)
b) int main(...)

2. Commas

a)	f(a, b);
b)	f(a,b);

3. Braces
Note: Illustrated using 15a.

a1)	if(x) {
	    code;
	} else {
	    code;
	}
a2)	if(x) {
	    code;
	}
	else {
	    code;
	}
b)	if(x)
	{
	    code;
	}
	else
	{
	    code;
	}
c)	if(x)
	    {
	    code;
	    }
	else
	    {
	    code;
	    }

4. For statements

a)	for(a ; b ; c)
b)	for(a; b; c)

5. Comment indentation

a)	code;
	/* comment */
	code;
b)	code;
    /* comment */
	code;

6. Switches
Note: Illustrated using 3a.

a)	switch(x) {
	case a:
	    code;
	case b:
	    code;
	}
b)	switch(x) {
	    case a:
		code;
	    case b:
		code;
	}

7. Function declarations(2)
Note: Illustrated using 1b.

a) int main(...)
b) int main (...)

8. Assignment

a)	a=b
b)	a = b

9. Arithmetic operators

a)	a+b
b)	a + b

10. Logical operators

a)	a<b
b)	a < b

11. Incrementation

a)	++a
b)	++ a

12. Function declarations(3)
Note: Illustrated using 1b, 7a.

a) int main()
   {
	code;
   }
b) int main()
	{
	code;
	}
c) int main() {
   }

13. Null pointer tests

a) if(p == NULL)
b) if(!p)

14. Capitalisation of enums

a) enum x { ONE, TWO };
b) enum x { one, two };
c) No rule.

15. Spaces after keywords

a) if(x)
b) if (x)

	1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 DF

Chuck	b  a  b  b  b  b  a  b  b  b  a  a     a    4
Randy   a  a  a2 a  a  a  b  b  b  b  a  a          3
Paul    a  a  a1 b  a  b  a  b  b  b  a  a  a  a    4.5
Ben     b  b  c  a  b  a  a  a  a  b  a  b  b  c  a 7
RST     b  a  a2 b  a  a  b  b  b  b  a  a  b  c    1
Mark    b  b  a  b  a  b  a  b  b  b  a  a          2
David   a  a  b  a
Alexei  b  a  a2 b  a  a  b  b  b  b  a  a  b  c    1
Rasmus  b  a  a1 b  a  a  a  b  b  b  a  a          0.5
Jim     a  a  a2 b  a  a  a  b  b     a  a          1
Roy	b  a  b  b  a  b  a  b  b  b  a  a     b    2

Total   b  a  a2 b  a  a  a  b  b  b  a  a  b  c  a


-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.

Re: Oh no! Not that list again...

Posted by Tony Sanders <sa...@bsdi.com>.
Ben Laurie writes:
> Yes, here it is again. Note that a new section, 15, has been added. Also note
> that MANY people have not bothered to vote on the later sections. Get yer act
> together, guys!
Dunno if my vote counts or not but here are my preferences, based
on BSD KNF (Kernel Normal Form).

I'll even toss in a few "rationals" where my vote differs from the
current consensus.

> 	  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 DF
> 
> Chuck	  b  a  b  b  b  b  a  b  b  b  a  a     a    4
> Randy   a  a  a2 a  a  a  b  b  b  b  a  a          3
> Paul    a  a  a1 b  a  b  a  b  b  b  a  a  a  a    4.5
> Ben     b  b  c  a  b  a  a  a  a  b  a  b  b  c  a 7
> RST     b  a  a2 b  a  a  b  b  b  b  a  a  b  c    1
> Mark    b  b  a  b  a  b  a  b  b  b  a  a          2
> David   a  a  b  a
> Alexei  b  a  a2 b  a  a  b  b  b  b  a  a  b  c    1
> Rasmus  b  a  a1 b  a  a  a  b  b  b  a  a          0.5
> Jim     a  a  a2 b  a  a  a  b  b     a  a          1
> Roy	  b  a  b  b  a  b  a  b  b  b  a  a     b    2
> 
> Total   b  a  a2 b  a  a  a  b  b  b  a  a  b  c  a

  TWS     a  a  a2 b  a  *  a  b  b  b  a  a  b  *  b
                         c                       d   

* see comments

> 1. Function declarations
> a) int
>    main(...)

Rational:  grep ^main *.c

This is *highly* standard C style.  I am very surprised
that the group consensus is currently for `b' (yuck).

> 3. Braces
...
> a2)	if(x) {
> 	    code;
> 	}
> 	else {
> 	    code;
> 	}

Rational: easy to add code segments without screwing up and doesn't
	  waste too much white-space.
	  
> 5. Comment indentation
> 
> a)	code;
> 	/* comment */
> 	code;
> b)	code;
>     /* comment */
> 	code;

I actually like:

	/*
	 * Major section meta-information
	 */
	code;
	code;		/* micro-comment */


The large block comments should document the logic of each section of
code that you can search for `/*$' and follow the logic without having
to read the code.


> 6. Switches
> Note: Illustrated using 3a.
> 
> a)	switch(x) {
> 	case a:
> 	    code;
> 	case b:
> 	    code;
> 	}
> b)	switch(x) {
> 	    case a:
> 		code;
> 	    case b:
> 		code;
> 	}
Neither, I like to use half-dents for case and default:
	switch(x) {
	  case a:
	  case b:
	    code;
	}

> 14. Capitalisation of enums
> 
> a) enum x { ONE, TWO };
> b) enum x { one, two };
> c) No rule.
d) initial cap:  enum x { One, Two };

> 15. Spaces after keywords
> 
> a) if(x)
> b) if (x)

Rational:  Spaces after keywords, no spaces after functions.
           grep 'mysub(' *.c

e.g.:
	if (x)
	while (x)
	mysub(x)

Oh no! Not that list again...

Posted by Paul Richards <p....@elsevier.co.uk>.
 > 15. Spaces after keywords
 > 
 > a) if(x)
 > b) if (x)

15b

Style options with indent

Posted by Paul Richards <p....@elsevier.co.uk>.
Roy T. Fielding writes:
 > Ben, stop using TABs -- all your examples are screwed up every time
 > I try to include them in a message, which is pretty stupid when you
 > are trying to get consensus on whitespace style.
 > 
 > I still intend to run indent on the code before making any large
 > enhancements to a file -- it just isn't worth the effort of reading
 > the code in its current form [I did the same to NCSA httpd back in '93,
 > but wasn't able to commit back then :)].  Below are the indent options.

Well, I've been looking at the enhancements made to newer versions of the
cvs scripts and having cvs run indent is not actually much of a problem
anymore. We could therefore have cvs reformat code before it gets
committed transparently as far as the committer is concerned.

Re: Oh no! Not that list again...

Posted by Alexei Kosut <ak...@organic.com>.
On Mon, 15 Jul 1996, Ben Laurie wrote:

> 15. Spaces after keywords
> 
> a) if(x)
> b) if (x)

15b.

-- Alexei Kosut <ak...@organic.com>            The Apache HTTP Server 
   http://www.nueva.pvt.k12.ca.us/~akosut/      http://www.apache.org/