This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SPATCH] Add space after function call.


Hi, I wrote a small script that add space after function call.

I ran it on glibc and it fixed 11116 occurences of it.
Patch itself is rather large so I put it at

kam.mff.cuni.cz/~ondra/space_after_function.patch

Patch is easy to check, when I run git diff -w then 
diff is empty. OK to commit patch?

OK to commit generator?

	* scripts/fmt: New file.
	* scripts/fmt.c: New file.

---
 scripts/fmt   |    7 +++++++
 scripts/fmt.c |   23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100755 scripts/fmt
 create mode 100644 scripts/fmt.c

diff --git a/scripts/fmt b/scripts/fmt
new file mode 100755
index 0000000..715602c
--- /dev/null
+++ b/scripts/fmt
@@ -0,0 +1,7 @@
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+gcc $DIR/fmt.c -o /tmp/fmt
+for I in `find -regex ".*\.c"`; do
+cp $I $I.bak
+/tmp/fmt < $I.bak > $I
+rm $I.bak
+done
diff --git a/scripts/fmt.c b/scripts/fmt.c
new file mode 100644
index 0000000..bf4edeb
--- /dev/null
+++ b/scripts/fmt.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <ctype.h>
+int main ()
+{
+  char c,c2 = 0;
+  int disablestring = 0;
+  int disablecomment = 0;
+
+  int disabledefine = 0;
+  while ((c = getchar ()) != EOF)
+    {
+      if (c2 == '/' && c == '*') disablecomment = 1;
+      if (c2 == '*' && c == '/') disablecomment = 0;
+
+      if (c == '"' && c2 != '\\') disablestring = 1 - disablestring;
+      if (c == '#') disabledefine = 1;
+      if ((c == '\n' || c == '\r') && c2 != '\n' && c2 != '\r' && c2 != '\\') disabledefine=0;
+      if (c == '(' && (isalpha (c2)) && !disablestring && !disabledefine && !disablecomment)
+        putchar (' ');
+      putchar (c);
+      c2 = c;
+    }
+}
-- 
1.7.4.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]