[GRASS-dev] [GRASS GIS] #1663: Tabs in C source code

#1663: Tabs in C source code
--------------------------------+-------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Default | Version: unspecified
Keywords: indent tabs spaces | Platform: All
      Cpu: All |
--------------------------------+-------------------------------------------
I assume that GRASS C source code should be indented with spaces, more
precisely with spaces only. And more over, mixing tabs and spaces is a bad
practice.

But C source files contains both spaces and tabs.

For example changeset r47676 "code layout fixes with indent" only adds
another tabs which are mixed with spaces. Here is a part of file worker.c
(http://trac.osgeo.org/grass/browser/grass/trunk/raster/r.li/r.li.daemon/worker.c):
{{{
(tab)case FCELL_TYPE:{
(tab)(tab)for (i = 0; i < ad->rl - used; i++) {
(tab)(tab)(4spaces)fm->cache[used + i] = Rast_allocate_f_buf();
(tab)(tab)}
(tab)(4spaces)}
}}}

Here is minimal working example which produces badly intended source code
(GRASS indent script, tested on Ubuntu 10.04 with GNU indent 2.2.10).

{{{
// file test.c
void test()
{
int a,b,i;
a =5;
if ( a==5 ){
for (i = 0; i < 10; i++) { b++; }
b= b*10;
}
}
}}}

{{{
./tools/grass_indent.sh test.c
}}}

{{{
// file test.c
void test()
{
(4spaces)int a, b, i;
(4spaces)a = 5;
(4spaces)if (a == 5) {
(tab)for (i = 0; i < 10; i++) {
(tab)(4spaces)b++;
(tab)}
(tab)b = b * 10;
(4spaces)}
}
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1663&gt;
GRASS GIS <http://grass.osgeo.org>

#1663: Tabs in C source code
-------------------------+--------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone:
Component: Default | Version: unspecified
Resolution: invalid | Keywords: indent tabs spaces
  Platform: All | Cpu: All
-------------------------+--------------------------------------------------
Changes (by glynn):

  * status: new => closed
  * resolution: => invalid

Comment:

Replying to [ticket:1663 wenzeslaus]:

> But C source files contains both spaces and tabs.

This is not a problem, so long as the code is indented correctly for
8-column tabs. Trying to enforce a spaces-only policy isn't worth the
trouble.

If you configure your text editor with something other than 8-column tabs,
you're on your own (just don't commit code which relies upon something
other than 8-column tabs).

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1663#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>