-
Notifications
You must be signed in to change notification settings - Fork 192
/
format.sh
executable file
·79 lines (67 loc) · 2.89 KB
/
format.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# For the special case "if", we nees to update the astyle/ASFormatter.cpp, in this way, we bypass the for, while and switch.
# if (shouldPadHeader
# && (!isNonParenHeader
# || (currentHeader == &AS_CASE && peekNextChar() == '(')
# || (currentHeader == &AS_CATCH && peekNextChar() == '('))
# && charNum < (int) currentLine.length() - 1
# && !isWhiteSpace(currentLine[charNum + 1]))
#+ {
#+ if (currentHeader != &AS_SWITCH
# && currentHeader != &AS_WHILE
# && currentHeader != &AS_FOR)
# {
#+ appendSpacePad();
# }
#+ }
#
#void ASFormatter::padParens(void)
# ...
# if (shouldPadHeader
# && prevWord.length() > 0
# && isCharPotentialHeader(prevWord, 0))
# {
# prevWordH = ASBeautifier::findHeader(prevWord, 0, headers);
# }
# if (prevWordH != NULL)
#+ {
#+ //We treat while and for and switch not a header
#+ if ( prevWordH != &AS_SWITCH && prevWordH != &AS_WHILE && prevWordH != &AS_FOR )
# prevIsParenHeader = true;
#+ }
# else if (prevWord == "return") // don't unpad
#
#
#
createFileList()
{
FILENAME=$1
rm -rf $FILENAME
find . -iname "*.c" | grep -v UnitTest++ | grep -v build/ | grep -v modules/pagespeed/psol > $FILENAME
find . -iname "*.cpp" | grep -v UnitTest++ | grep -v build/ | grep -v modules/pagespeed/psol >> $FILENAME
find . -iname "*.h" | grep -v UnitTest++ | grep -v build/ | grep -v modules/pagespeed/psol >> $FILENAME
}
dealFile()
{
local FILENAME=$1
echo "Dealing with file: $FILENAME"
astyle -A1 -s4 -K -w -m0 -p -H -U -k3 -W3 -xj -c -xC75 -n -O -q "$FILENAME"
astyle -A1 -s4 -K -w -m0 -p -H -U -k3 -W3 -xj -c -xC75 -n -O -q "$FILENAME"
# /usr/bin/sed -i -r -e "s/[(][ ]((const[ ])?(unsigned[ ])?(struct[ ])?\w+[ ][*])[ ][)]/(\1)/" -e "s/[(][ ]((const[ ])?(unsigned[ ])?(struct[ ])?\w+[ ][*])[ ][)]/(\1)/" "$FILENAME"
# /usr/bin/sed -i -e "s/( int )/(int)/" -e "s/( short )/(short)/" -e "s/( unsigned long )/(unsigned long)/" -e "s/( long )/(long)/" -e "s/( long long )/(long long)/" "$FILENAME"
# /usr/bin/sed -i -e "s/( ( /(( /" -e "s/) ) )/) ))/" -e "s/ ) )/ ))/" -e "s/ ) )/ ))/" -e "s/())/() )/" -e "s/return ;/return;/" "$FILENAME"
}
if [ "x$1" != "x" ] ; then
if [ -f $1 ] ; then
dealFile $1
else
echo "File $1 does not exist".
echo
fi
else
createFileList ./todolist
for FILENAME in `cat ./todolist`; do dealFile $FILENAME ; done
fi
echo "Done."
echo