On Sun 18 May 2014 at 18:27:15 -0500, Matthew D. Fuller wrote: > > - 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.
I agree that this very much needs to be improved. > VCS. I think it adds up to "worth it". I tend to agree there. > 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 :) For practical reasons, it helps a lot if one's editor (vim in my case) can be made to apply (at least some aspects of) the style automatically. Especially tabs-vs-spaces since often you don't see if you get them wrong. > 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 Hmmm the part which removes spaces around parentheses is rather too agressive: I get lots of if(expr) foo(); while(expr) foo(); which I find really really ugly. () should be tight after function names but loose after keywords. And no return (expr). After applying first allman and then knf (which is really more my taste) on events.c, I got something like if(...) { ... } else { ... } which is another strange hybrid. I'd expect a reformatter to get that consistent... A disadvantage of 8-wide tabs and double indenting for switches is that those get really wide. There is lots of code that easily runs over the right-hand margin that way. Bool StashEventTime(register XEvent *ev) { switch(ev->type) { case KeyPress: case KeyRelease: lastTimestamp = ev->xkey.time; return True; this already indents nearly half the available width. I suppose that can be compensated by setting tabsize to 4 in the editor, but that causes lots of trouble when external tools touch the file. That's why I typically keep tabs at the standard 8 and let the editor handle indentation (4) in mixed tab and spaces. Although on the other hand some other people hate such mixing and prefer to do everything with spaces... (I don't mind that, myself) Can astyle reformat if(Tmp_win->AutoSqueeze && Tmp_win->squeezed) AutoSqueeze(Tmp_win); to if (Tmp_win->AutoSqueeze && Tmp_win->squeezed) { AutoSqueeze(Tmp_win); } i.e. including the braces? I think that needs doing on a mass scale, too. At least Allman style isn't GNU or Whitesmiths styles, they are really headache-inducing... (Oops, that remark may start a holy war after all, and that after being so careful to try and avoid that...) -Olaf. -- ___ Olaf 'Rhialto' Seibert -- The Doctor: No, 'eureka' is Greek for \X/ rhialto/at/xs4all.nl -- 'this bath is too hot.'
pgpBAA9iof2gn.pgp
Description: PGP signature
