[haiku-gsoc] Re: Updated patch

  • From: "Ryan C. Gordon" <icculus@xxxxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Wed, 22 Jun 2011 15:51:31 -0400


Is there a coding style for SDL as well?  If so is it documented
somewhere?  Is the commit message netiquette also described there?  Just
wondering for future reference.

95% of the time, you can get away with just making your code look like the code around it instead of being really anal about following a coding convention, but we _do_ actually have one.

Running "make indent" will reformat code to our coding standards, and uses the GNU indent command line tool with these switches:

   -i4 -nut -nsc -br -ce -cdw -npcs

Specifically:
- 4 spaces for indentation
- use spaces, not tabs
- Do not put the '*' character at the left of comments.
- Put braces on line with if, etc.
- Cuddle else and preceding '}'.
- Cuddle while of do {} while; and preceding '}'.
- Do not put space after the function in function calls.

"make indent" is a bit of a carpet bomb, and can have unintended consequences. It's better to write correctly yourself (and use some common sense to know when breaking the rules produces a more asthetically pleasing result...it's a fine art). Occasionally we'll run this, and clean up a bunch of minor things by hand, based on what GNU indent changes. But if you want to reformat your stuff before committing, you can use "make indent" and "hg record" and piece together your commit as appropriate.


The first line of the commit being terse is standard style for git and Mercurial (as they both use "shortlogs"). The rest is just in the name of being clear and concise, so it owes more to Strunk and White than it does to us. :)

--ryan.


Other related posts: