> - Code style.  We should have one.  I mean, we already have one, we
>   just also have another one, and another one, and about 30 more.  Not
>   counting the minor variations.  Or swathes of code that _don't_ have
>   one.

There's a point of view that says not to do mass reformattings, since
it messes with outstanding branches and patches, as well as
complicating excursions through the code history.  Not weak arguments.
Instead, code should just be reformatted when it's being worked on.

But I think we should ignore that.  It's no less disruptive
reformatting a pile of code when a small section is being worked on,
reformatting just the section being worked on tends to leave things
even more inconsistent, and the general state of things makes it
discouraging to look at.  Given a programmatic way of handling things,
it can easily be reproduced on outstanding branches and locally
patched copies, so it shouldn't cause massive disruptions in ongoing
work.  And while it does slightly complicate digging through history
across the formattings, well, it's just a couple extra steps in the
VCS.  I think it adds up to "worth it".


I've been experimenting a little bit with using Artistic Style
<http://astyle.sourceforge.net/> for formatting.  It doesn't give
quite all the flexibility I'd like, but it's OK.  Past experiences
with using indent(1) have led me to automatically like anything other
than it   :)

I've attached 2 strawman control files with moderately alternate
outputs.  The major variance between them is bracing and indenting.
One does Allman (which I prefer) and tabs (which I strongly prefer),
the other KNF and 4-space.  Some additional minor differences falling
out from those.

To try them out, use invocations like

% astyle -n --options=../fullermd.astyle *.h *.c


Of course, let's don't _commit_ any output of this, for the moment.
I'm open to discussion of alternate tools, maybe even indent for a big
enough bribe.  I'd like to get some set of tool/options we can all
live with the output of, that we can integrate into a standard
workflow, so arbitrarily-timed 'make indent'-like things can keep
things in good shape without a bunch of churn (beyond the initial
transition).


-- 
Matthew Fuller     (MF4839)   |  [email protected]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.
style=allman

# With tabs.  Existing code uses tab=8sp, so this converts things
# properly.  Not to be read as defining tab size going forward; result
# should yield code that works with any reasonable tabstop.
indent=tab=8

# Indent switch() and case's.
indent-switches
indent-cases

# Space around operators
pad-oper

# Get rid of spaces around parens (I actually wish this were a little
# more discriminating, but this is an improvement on the current state)
unpad-paren

# Align * and & and such to the name
align-pointer=name
align-reference=name

# Use tabs only for indent levels, spaces for alignment below that
convert-tabs

# 80 char lines
max-code-length=80

# \n
lineend=linux
style=knf

# 4 spaces
indent=spaces=4

# Indent switch() and case's.
indent-switches
indent-cases

# Space around operators
pad-oper

# Get rid of spaces around parens (I actually wish this were a little
# more discriminating, but this is an improvement on the current state)
unpad-paren

# Align * and & and such to the name
align-pointer=name
align-reference=name

# Don't cuddle elses
break-closing-brackets

# Use tabs only for indent levels, spaces for alignment below that
convert-tabs

# 80 char lines
max-code-length=80

# \n
lineend=linux

Reply via email to