X coding style

Kevin E Martin kem at freedesktop.org
Mon May 8 08:19:50 PDT 2006


On Mon, May 08, 2006 at 07:58:55AM -0700, Keith Packard wrote:
> On Mon, 2006-05-08 at 10:04 -0400, Adam Jackson wrote:
> 
> > But if you want the brief summary, it's K&R, and the rationale is that it's
> > _the_ common style.
> 
> No, it's not K&R; at a minimum, we use a mixture of spaces and tabs to
> achieve 4-character cell indentation almost everywhere.

True.

>                                                         Plus, in the X
> server, the general format is:
> 
>     if (foo)
>     {
> 	indented body
>     }
>     else
>     {
> 	indented else
>     }
> 
> while K&R uses
> 
> 	if (foo) {
> 		indented body
> 	} else {
> 		indented else
> 	}

Unfortunately, it's become a mixture of both.  The predominant style
appears to be the former in dix, mi and fb.  While the latter is the
predominant style used in many of the DDXs.  Note that the CODING doc
was originally intended for only the XFree86 DDX.

> I don't care which you use in your own code, but do try to precisely
> match the code in which you are working when making changes.

Definitely.  This should be added to the top of the CodingStyle wiki
page.

Kevin



More information about the xorg mailing list