X server source code re-indented

Daniel Stone daniel at fooishbar.org
Wed Mar 21 17:17:20 PDT 2012


Hi,

On 21 March 2012 22:27, Chase Douglas <chase.douglas at canonical.com> wrote:
> On 03/21/2012 02:25 PM, Keith Packard wrote:
>> I'll also happily take whitespace cleanup patches that recover from
>> mistakes made by "indent".
>
> I haven't made any attempt to learn the new style yet. Is there a guide
> somewhere?

The guide is just the indent script, but here's the rough digest:
  - four-space indents (and I do mean spaces)
  - braces on the following line for function declarations only,
everything else on the same line
  - ... but don't cuddle your elses: the correct form is if (foo) {\n
[...]\n}\nelse {\n [...]\n}
  - function name on a separate line from its return type
  - case labels have zero indentation relative to the switch
statement; the bodies of every case are indented four spaces as usual
  - if you need to wrap the parameters to a function call or
declaration, align the parameters on the next line to the opening
parenthesis, rather than just tabbing in once
  - same goes for conditionals

Aside from that, I don't think there's anything particularly new or surprising.

> At first I thought I'd just run my changes through the indent script
> before committing, but as soon as we start applying indent "fixes" this
> won't work.

The fixes are just to cover pretty daft indent corner cases; in
particular it does totally the wrong thing when faced with luddite
declarations of the form: void CloseDownClient(ClientPtr /* client
*/).  This confuses the poor thing massively and it spits its drink
out all over the source code.  The fix, of course, is to fix those
declarations.

In general, just follow those rules and you'll be grand.

Cheers,
Daniel


More information about the xorg-devel mailing list