script to remove whitespace at the end of a line
authorChristian Grothoff <christian@grothoff.org>
Mon, 29 Aug 2011 10:15:57 +0000 (10:15 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 29 Aug 2011 10:15:57 +0000 (10:15 +0000)
contrib/removetrailingwhitespace [new file with mode: 0755]

diff --git a/contrib/removetrailingwhitespace b/contrib/removetrailingwhitespace
new file mode 100755 (executable)
index 0000000..9e620cb
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+
+import sys
+import re
+
+for fileName in sys.argv[1:]:
+   f = open(fileName, 'r+')
+   fileString = f.read()
+
+   fileString = re.sub(r'[ ]+\n', r'\n', fileString)
+   fileString = re.sub(r'\r', r'', fileString)
+   f.seek(0)
+   f.write(fileString)
+   f.truncate(len(fileString))