source: grass/trunk/tools/grass_indent.sh

Last change on this file was 74017, checked in by hcho, 6 years ago

grass_indent.sh: Handle multiple files and filenames with spaces properly

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:mime-type set to text/x-sh
File size: 1.0 KB
Line 
1#!/bin/sh
2
3# Indent source code according to GRASS GIS submitting rules
4
5# Should be in sync with:
6# https://trac.osgeo.org/grass/wiki/Submitting/C
7# http://grasswiki.osgeo.org/wiki/Development#Explanation_of_C_indentation_rules
8
9# Dependencies:
10# indent
11
12# Changes and their reasons:
13# -ts8 -ut -> --no-tabs
14# Do not use 8 space wide tabs when indent level is 4
15
16# TODO: replace short flags by long ones to improve readability
17
18
19if [ $# -lt 1 ] ; then
20 echo "No files specified (give file name(s) as parameter)"
21 exit 1
22else
23 indent -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
24 -nbbo -nbc -nbfda -nbfde -ncdb -ncdw -nce -nfca -npcs -nprs \
25 -npsl -nsc -nsob -saf -sai -saw -sbi0 -ss --no-tabs "$@"
26
27 # fix broken gettext macros:
28 grep -l '\<_$' "$@" | \
29 while read file ; do sed -i -e '/[( \t]_$/{;N;s/\n[ \t]*//;}' "$file" ; done
30
31 # restore original file with timestamp if indent did not change anything
32 for file in "$@" ; do
33 cmp "$file"~ "$file" > /dev/null && mv -f "$file"~ "$file"
34 done
35fi
Note: See TracBrowser for help on using the repository browser.