[ros-kernel] Coding style/indentation (again!?)

Gunnar André Dalsnes hardon at online.no
Sat Jan 31 06:03:22 CET 2004


Hi,

ROS' lack of coding style is still bugging me, so here we go again:

First we have to agree on a coding style.

Here's my suggestion: indent <file> -gnu -nut -bli0 -cbi0 -cli3 -bfda -i3
-l100 -npcs -cdw

Have a look at the attached example code to see if there's something you
don't like, and try to find an indent option that fix the issue. 

Note that indent can't fix everything. For example, it doesn't seem to have
an option to break the line after all arguments in a function call (we could
implement this in indent thou).

indent manual: http://2robots.com/man/index.php?indent
indent for win32 (included in unxutil package):
http://unxutils.sourceforge.net/

Short desc:
-gnu		gnu presets (basis)
-nut  	no tabs (use space)
-bliX		indent braces X spaces
-cbiX		indent braces X spaces after case labels
-cliX		indent X spaces after case labels
-bfda		break the line before all arguments in a declaration
-iX		indent X spaces
-lX		break line at col X 
-npcs		do not put space after the function in function calls 
-cdw		cuddle while of do {} while; and preceeding `}'


OPTIONS ON HOW TO INDENT:

1) Everyone run indent locally before commiting. We should have something
like "make indent" or maybe indent as a part of the regular "make" process
(the latter will bring unaceptable? overhead to the make process thou). If
people don't want to run "make indent" they may create faster, home-made
solutions: I've created a shotcut to a indent.bat in the right-click->"Send
To" context-menu.
Pros: Simple
Cons: Impossible to verify that people actually obey the rulez

2) Everyone does as in 1) BUT the cvs-server revokes the commit it it
doesn't follow the rulez.
Pros: Simple and secure. I have tested this and it works great.
Cons: Jason didn't like this...

3) The cvs-server run indent on affected files after each commit
I have tested this solution:
http://www.loria.fr/~molli/fom-serve/cache/347.html
Pros: Sounds good...
Cons: If you commit changes to a file, the indented changes will not be
reflected locally. You'll have to delete the file and update to get the
indented changes. So if you make several commits without deleting and
updating the file after each commit you will sometimes get errors when
commiting (i got errors when i tested it). Diff will produce strange results
in this case also. Most of the time it works fine without deleting and
updating, but not allways...

4) ???

-Gunnar




More information about the Ros-kernel mailing list