Parcourir la source

do not use tabs which are 8 spaces wide when indent level is 4 spaces

Indent script was creating source code with 4 spaces for indent level 1,
1 tab for indent level 2, 1 tab and 4 spaces for indent level 3, 2 tabs
for indent level 4 etc. This is style which is hard to do manually
and cannot be easily guessed and supported by a text editor because it
mixes spaces and tabs
(http://lists.osgeo.org/pipermail/grass-dev/2014-September/070653.html).

The indent rules are still the same, each level must be in multiplies
of 4 spaces (columns) as specified in
http://lists.osgeo.org/pipermail/grass-dev/2014-August/070497.html.

No backwards compatibility is needed because just small portion of the
current code has no diff after applying the (original version of) indent
script. Now tested with v.external, i.segment and r.slope.aspect.

The -ut (--use-tabs) was in the list at
https://trac.osgeo.org/grass/wiki/Submitting/C.
But it was not in the list at
http://grasswiki.osgeo.org/w/index.php?title=Development&oldid=21058#Explanation_of_C_indentation_rules.
And tabs are explicitly forbidden in instructions for Emacs users at
http://grasswiki.osgeo.org/w/index.php?title=GRASS_Programming_Howto&oldid=20573#Emacs.

See also https://trac.osgeo.org/grass/ticket/1663 (Tabs in C source code) and grass-dev Tabs and spaces in C code
(http://lists.osgeo.org/pipermail/grass-dev/2014-August/070484.html).


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64658 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras il y a 10 ans
Parent
commit
7567b22e5a
1 fichiers modifiés avec 16 ajouts et 2 suppressions
  1. 16 2
      tools/grass_indent.sh

+ 16 - 2
tools/grass_indent.sh

@@ -1,6 +1,20 @@
 #!/bin/sh
 
-# Indent source code according to GRASS SUBMITTING rules
+# Indent source code according to GRASS GIS submitting rules
+
+# Should be in sync with:
+#     https://trac.osgeo.org/grass/wiki/Submitting/C
+#     http://grasswiki.osgeo.org/wiki/Development#Explanation_of_C_indentation_rules
+
+# Dependencies:
+#     indent
+
+# Changes and their reasons:
+#    -ts8 -ut -> --no-tabs
+#        Do not use 8 space wide tabs when indent level is 4
+
+# TODO: replace short flags by long ones to improve readability
+
 
 if [ $# -lt 1 ] ; then
  echo "No files specified (give file name(s) as parameter)"
@@ -8,7 +22,7 @@ if [ $# -lt 1 ] ; then
 else
  indent -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
       -nbbo -nbc -nbfda -nbfde -ncdb -ncdw -nce -nfca -npcs -nprs \
-      -npsl -nsc -nsob -saf -sai -saw -sbi0 -ss -ts8 -ut "$@"
+      -npsl -nsc -nsob -saf -sai -saw -sbi0 -ss --no-tabs "$@"
 
  # fix broken gettext macros:
  grep -l '\<_$' "$@" | \