contrib/removetrailingwhitespace: sed the python
authorNils Gillmann <ng0@n0.is>
Thu, 17 May 2018 16:38:30 +0000 (16:38 +0000)
committerNils Gillmann <ng0@n0.is>
Thu, 17 May 2018 16:38:30 +0000 (16:38 +0000)
Signed-off-by: Nils Gillmann <ng0@n0.is>
contrib/Makefile.am
contrib/removetrailingwhitespace [deleted file]
contrib/removetrailingwhitespace.py.in [new file with mode: 0755]
pre-commit

index 1db5b3091b86d96286c3318d79538268bdf2afd5..40e6d3e92be49837b64e5b240ecb46810a7dd839 100644 (file)
@@ -19,6 +19,7 @@ endif
 noinst_SCRIPTS = \
  terminate.py \
  pydiffer.py \
+ removetrailingwhitespace.py \
  gnunet_pyexpect.py \
  gnunet_janitor.py \
  gnunet-chk.py
@@ -52,6 +53,7 @@ EXTRA_DIST = \
  gnunet_pyexpect.py.in \
  gnunet_janitor.py.in \
  gnunet-chk.py.in \
+ removetrailingwhitespace.py.in \
  pydiffer.py.in \
  gnunet-gns-import.sh \
  openvpn-tap32/tapw32/tap0901.sys \
diff --git a/contrib/removetrailingwhitespace b/contrib/removetrailingwhitespace
deleted file mode 100755 (executable)
index 9e620cb..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/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))
diff --git a/contrib/removetrailingwhitespace.py.in b/contrib/removetrailingwhitespace.py.in
new file mode 100755 (executable)
index 0000000..5824fb5
--- /dev/null
@@ -0,0 +1,15 @@
+#!@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))
index 5213f2cf4520930e21b1f2df302c145dd9ac6f30..777728a6bbb417cd76596ceb765094cb4c149caa 100755 (executable)
@@ -12,8 +12,8 @@ find $PATHS -name "*.c" -exec indent {} \;
 find $PATHS -name "*.h" -exec indent {} \;
 find $PATHS -name "*.c" -exec indent {} \;
 find $PATHS -name "*.h" -exec indent {} \;
-find $PATHS -name "*.c" -exec contrib/removetrailingwhitespace {} \;
-find $PATHS -name "*.h" -exec contrib/removetrailingwhitespace {} \;
+find $PATHS -name "*.c" -exec contrib/removetrailingwhitespace.py {} \;
+find $PATHS -name "*.h" -exec contrib/removetrailingwhitespace.py {} \;
 if test -x "`which 'dos2unix'`"
 then
   find $PATHS -name "*.c" -exec dos2unix {} \;