From bb4fc4f4007988874f910d4de5492f9629301641 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 29 Aug 2011 10:15:57 +0000 Subject: script to remove whitespace at the end of a line --- contrib/removetrailingwhitespace | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 contrib/removetrailingwhitespace (limited to 'contrib') diff --git a/contrib/removetrailingwhitespace b/contrib/removetrailingwhitespace new file mode 100755 index 000000000..9e620cbb2 --- /dev/null +++ b/contrib/removetrailingwhitespace @@ -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)) -- cgit v1.2.3