[GRASS5] Code Formatting

Glynn Clements glynn at gclements.plus.com
Sat Apr 22 08:25:51 EDT 2006


Hamish wrote:

> > > This has been added to the SUBMITTING file not long ago:
> > > 
> > > 14. To promote a consistent coding style, please use the "indent" program
> > >     on all new C modules using the following switches:
> > >     
> > >      $ indent -nbad -bap -bbb -nbbo -nbc -br -bli1 -bls -cbi0 -ncdb -nce \
> > >         -ci4 -cli0 -ncs -d0 -di0 -fc1 -nfca -hnl -i4 -ip4 -l80 -lc80 -lp \
> > > 	-npcs -pi4 -nprs -npsl -sbi0 -sc -nsob -ss -ts8  main.c
> > 
> > Any objections to changing:
> > 
> > 	-bli1	->	-bli0
> > 	-br	->	-bl
> 
> translation:
>   '{' comes on next line after if,for etc instead of "if {"
>   Structs, functions already do this (-bls)

That's the -br -> -bl change.

Changing -bli1 -> -bli0 means that braces are aligned with the command
rather than being an extra space in, i.e.

        if (...)
        {
                ...
        }

rather than:

        if (...)
         {
                ...
         }

Having braces aligned makes it easier to do manual alignment, as
everything is then aligned to a multiple of 4 columns. It's also
easier in terms of configuring Emacs' auto-formatting, which expects
everything to be specified as multiples of the indentation step.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list