diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-08-16 18:27:12 (GMT) | 
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-08-16 22:13:30 (GMT) | 
| commit | 9ed3516fc091010637b7eba3678a1566507c59eb (patch) | |
| tree | d6a0e3d4b1eba0fed78b8e4d70cbc4d01854b2c9 | |
| parent | 2c9b7fc6753f7595c7208161d1809d5f97f7ffa7 (diff) | |
| download | swift-contrib-9ed3516fc091010637b7eba3678a1566507c59eb.zip swift-contrib-9ed3516fc091010637b7eba3678a1566507c59eb.tar.bz2 | |
Ported CheckTabs script to Python.
| -rwxr-xr-x | BuildTools/CheckTabs.py | 36 | ||||
| -rwxr-xr-x | tools/syntax/CheckTabs.sh | 8 | 
2 files changed, 36 insertions, 8 deletions
| diff --git a/BuildTools/CheckTabs.py b/BuildTools/CheckTabs.py new file mode 100755 index 0000000..3dac977 --- /dev/null +++ b/BuildTools/CheckTabs.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import os, sys + +for (path, dirs, files) in os.walk(".") : +	if not "3rdParty" in path : +		for filename in [os.path.join(path, file) for file in files if file.endswith(".cpp") or file.endswith(".h")] : +			file = open(filename, "r") +			contents = [] +			contentsChanged = False +			for line in file.readlines() : +				newline = "" +				previousChar = None +				pastInitialSpace = False +				for char in line : +					if not pastInitialSpace : +						if char == ' ' and previousChar == ' ' : +							contentsChanged = True +							previousChar = '\t' +							continue +						pastInitialSpace = (char != ' ') +					if previousChar : +						newline += previousChar +					previousChar = char +				if previousChar : +					newline += previousChar +				contents.append(newline) +			file.close() +			if contentsChanged : +				if len(sys.argv) > 1 and sys.argv[1] == "--fix" : +					print "Fixing tabs in " + filename +					file = open(filename, "w") +					file.write(''.join(contents)) +					file.close() +				else : +					print filename + " contains expanded tabs" diff --git a/tools/syntax/CheckTabs.sh b/tools/syntax/CheckTabs.sh deleted file mode 100755 index 0c11c49..0000000 --- a/tools/syntax/CheckTabs.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh - -FAILING_FILES=`grep -r "^ " * | grep -E "^(\w|/)+\.(cpp|h):" | grep -E -v "^(src/(Swift/)?)?3rdParty" | grep -v "^.*moc_" | sed -e "s/:.*//" | uniq` - -if [ "$FAILING_FILES" ]; then -	echo "ERROR: Found whitespace instead of tabs in the following files:" -	echo "$FAILING_FILES" -fi | 
 Swift
 Swift