about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-08-22 21:13:33 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-08-22 21:13:33 +0000
commit0320d20a477e2edbf15f3d961add7c9cd5be7f94 (patch)
tree589005b1e64381b5144cf3106c78befdc692deb2 /scripts
parent01fa2a14a22a4be0a735597902d1b136469604a0 (diff)
downloadzcatch-0320d20a477e2edbf15f3d961add7c9cd5be7f94.tar.gz
zcatch-0320d20a477e2edbf15f3d961add7c9cd5be7f94.zip
fixed network hash versioning
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cmd5.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/cmd5.py b/scripts/cmd5.py
new file mode 100644
index 00000000..2e20ff5b
--- /dev/null
+++ b/scripts/cmd5.py
@@ -0,0 +1,32 @@
+import md5, sys, re
+m = md5.new()
+
+alphanum = "0123456789abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ_"
+
+def cstrip(lines):
+	d = ""	
+	for l in lines:
+		l = re.sub("#.*", "", l)
+		l = re.sub("//.*", "", l)
+		d += l + " "
+	d = re.sub("\/\*.*?\*/", "", d) # remove /* */ comments
+	d = d.replace("\t", " ") # tab to space
+	d = re.sub("  *", " ", d) # remove double spaces
+	d = re.sub("", "", d) # remove /* */ comments
+	
+	d = d.strip()
+	
+	# this eats up cases like 'n {'
+	i = 1
+	while i < len(d)-2:
+		if d[i] == ' ':
+			if not (d[i-1] in alphanum and d[i+1] in alphanum):
+				d = d[:i] + d[i+1:]
+		i += 1
+	return d
+
+f = ""
+for filename in sys.argv[1:]:
+	f += cstrip([l.strip() for l in file(filename)])
+
+print '#define TEEWARS_NETVERSION_HASH "%s"' % md5.new(f).hexdigest().lower()[16:]