From 75f854584d6294cc94071229cf0f898f45de128b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Feb 2011 19:18:31 +0100 Subject: Fixed wrong nethash creation with Python 3 --- scripts/cmd5.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/cmd5.py b/scripts/cmd5.py index 5f08e1d2..929c05a7 100644 --- a/scripts/cmd5.py +++ b/scripts/cmd5.py @@ -1,6 +1,6 @@ import hashlib, sys, re -alphanum = "0123456789abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ_" +alphanum = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_".encode() def cstrip(lines): d = "".encode() @@ -12,15 +12,15 @@ def cstrip(lines): d = d.replace("\t".encode(), " ".encode()) # tab to space d = re.sub(" *".encode(), " ".encode(), d) # remove double spaces d = re.sub("".encode(), "".encode(), d) # remove /* */ comments - + d = d.strip() - + # this eats up cases like 'n {' i = 1 while i < len(d)-2: - if d[i:i + 1] == " ": - if not (d[i-1:i] in alphanum and d[i+1:i + 2] in alphanum): - d = d[:i] + d[i+1:] + if d[i:i + 1] == " ".encode(): + if not (d[i - 1:i] in alphanum and d[i+1:i + 2] in alphanum): + d = d[:i] + d[i + 1:] i += 1 return d -- cgit 1.4.1