about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-04-13 20:22:10 +0200
committeroy <Tom_Adams@web.de>2011-04-13 20:22:10 +0200
commite6f0318bdfa49bde503742c856c8415f9b2c8018 (patch)
tree5726e025088ea0173a28c44e9776f70203a8f413 /scripts
parentaeec62266b2f23a16b54dfe58b113efcd7adc83d (diff)
downloadzcatch-e6f0318bdfa49bde503742c856c8415f9b2c8018.tar.gz
zcatch-e6f0318bdfa49bde503742c856c8415f9b2c8018.zip
added "fixed some header guards and added a script to fix them all!" by Choupom
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_header_guards.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/check_header_guards.py b/scripts/check_header_guards.py
new file mode 100644
index 00000000..bece10e9
--- /dev/null
+++ b/scripts/check_header_guards.py
@@ -0,0 +1,35 @@
+import os
+
+
+PATH = "../src/"
+
+
+def check_file(filename):
+	file = open(filename)
+	while 1:
+		line = file.readline()
+		if len(line) == 0:
+			break
+		if line[0] == "/" or line[0] == "*" or line[0] == "\r" or line[0] == "\n" or line[0] == "\t":
+			continue
+		if line[:7] == "#ifndef":
+			hg = "#ifndef " + ("_".join(filename.split(PATH)[1].split("/"))[:-2]).upper() + "_H"
+			if line[:-1] != hg:
+				print "Wrong header guard in " + filename
+		else:
+			print "Missing header guard in " + filename
+		break
+	file.close()
+
+
+
+def check_dir(dir):
+	list = os.listdir(dir)
+	for file in list:
+		if os.path.isdir(dir+file):
+			if file != "external" and file != "generated":
+				check_dir(dir+file+"/")
+		elif file[-2:] == ".h" and file != "keynames.h":
+			check_file(dir+file)
+
+check_dir(PATH)