Skip to content

Commit 3d44bfd

Browse files
PKEuSdanmar
authored andcommitted
Use AStyle not only for converting tabs to spaces, added runastyle.bat
1 parent c70bae0 commit 3d44bfd

6 files changed

Lines changed: 1359 additions & 1194 deletions

File tree

main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include <iostream>
66
#include <cstring>
77

8-
int main(int argc, char **argv) {
8+
int main(int argc, char **argv)
9+
{
910
const char *filename = NULL;
1011

1112
// Settings..

runastyle

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
#!/bin/bash
2+
# The version check in this script is used to avoid commit battles
3+
# between different developers that use different astyle versions as
4+
# different versions might have different output (this has happened in
5+
# the past).
26

3-
astyle --convert-tabs test.cpp
4-
astyle --convert-tabs simplecpp.cpp
5-
astyle --convert-tabs simplecpp.h
7+
# If project management wishes to take a newer astyle version into use
8+
# just change this string to match the start of astyle version string.
9+
ASTYLE_VERSION="Artistic Style Version 2.05.1"
10+
ASTYLE="astyle"
11+
12+
DETECTED_VERSION=`$ASTYLE --version 2>&1`
13+
if [[ "$DETECTED_VERSION" != ${ASTYLE_VERSION}* ]]; then
14+
echo "You should use: ${ASTYLE_VERSION}";
15+
echo "Detected: ${DETECTED_VERSION}"
16+
exit 1;
17+
fi
18+
19+
style="--style=stroustrup --indent=spaces=4 --indent-namespaces --lineend=linux --min-conditional-indent=0"
20+
options="--options=none --pad-header --unpad-paren --suffix=none --convert-tabs --attach-inlines"
21+
22+
$ASTYLE $style $options *.cpp
23+
$ASTYLE $style $options *.h

runastyle.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@REM Script to run AStyle on the sources
2+
3+
@SET STYLE=--style=stroustrup --indent=spaces=4 --indent-namespaces --lineend=linux --min-conditional-indent=0
4+
@SET OPTIONS=--pad-header --unpad-paren --suffix=none --convert-tabs --attach-inlines
5+
6+
astyle %STYLE% %OPTIONS% *.h
7+
astyle %STYLE% %OPTIONS% *.cpp

0 commit comments

Comments
 (0)