#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>
GRASS GIS <http://grass.osgeo.org>