[GRASS-dev] Tabs and spaces in C code

Vaclav Petras wenzeslaus at gmail.com
Wed Aug 20 20:43:38 PDT 2014

On Wed, Aug 20, 2014 at 7:10 PM, Paul Kelly <paul-grass at stjohnspoint.co.uk>

> * If you are using only tabs it really does not matter "how long" tab
>> (in spaces) is because indentation levels are defined in number of tabs
>> (not spaces) and the number is natural number (naturally).
> Well it would mean all developers would need to set the tab spacing in
> their editors to 4 spaces (in order for files to appear the same as now).
> So it would mean requiring extra effort on the part of the majority of
> people who use 8-character tabs, just to cater to the minority who like to
> use tabs of a different length.

You need to have 8 spaces tabs for the files to look correct. If we would
be using just tabs, any number of spaces for tab would be correct. The
style we are using is however this:

while (True) { // level 0
(four spaces) if (a == 5) { // level 1
(one tab) if (b == 6) { // level 2
(one tab)(four spaces) c = 5 // level 3
(one tab) } // level 2
(four spaces) } // level 1
} // level 0

Tell me if I'm looking to wrong files but this is the state of files
indented by the indent script. See attached screenshot of a file after
running grass_indent.sh in editor showing whitespace characters.

I'm just playing devil's advocate there of course, but if it had to be
> changed I definitely think all spaces (a la FFmpeg) is a better option than
> all tabs...

Or we can of course accept both but now we are not comforting anybody (by
the style standardized in the script) because we are mixing them, and not
only in one file but in the scope of one line. Third level of indentation
is one tab (to get you to the second level) and four spaces (to get one
level up). Now, what is the fourth level? From what I know, you replace the
four spaces by one tab and you are there.

To make myself clear, I don't care how tab is long. I'm even not stating
any preference about using spaces only or tabs only for one file or for the
whole project. What bothers me is that mixing spaces and tabs at one line
does not make any sense as well as one tab used to indent the second
indentation level. And I don't want to introduce this to new files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140820/ffb8e533/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grass_indent_result.png
Type: image/png
Size: 38007 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140820/ffb8e533/attachment-0001.png>

More information about the grass-dev mailing list