Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(63571)

Side by Side Diff: Modules/_sha3/cleanup.py

Issue 16113: Add SHA-3 (Keccak) support
Patch Set: Created 7 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Modules/_hashopenssl.c ('k') | Modules/_sha3/keccak/KeccakF-1600-32.macros » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (C) 2012 Christian Heimes (christian@python.org)
3 # Licensed to PSF under a Contributor Agreement.
4 #
5 # cleanup Keccak sources
6
7 import os
8 import re
9
10 CPP1 = re.compile("^//(.*)")
11 CPP2 = re.compile("\ //(.*)")
12
13 STATICS = ("void ", "int ", "HashReturn ", "const UINT64 ", "UINT16 ")
14
15 HERE = os.path.dirname(os.path.abspath(__file__))
16 KECCAK = os.path.join(HERE, "keccak")
17
18 def getfiles():
19 for name in os.listdir(KECCAK):
20 name = os.path.join(KECCAK, name)
21 if os.path.isfile(name):
22 yield name
23
24 def cleanup(f):
25 buf = []
26 for line in f:
27 if line.startswith(STATICS):
28 buf.append("static " + line)
29 continue
30 if line.startswith("typedef unsigned long long int"):
31 buf.append("/* %s */\n" % line.strip())
32 continue
33 if "brg_endian.h" in line:
34 buf.append("/* %s */\n" % line.strip())
35 continue
36 line = CPP1.sub(r"/* \1 */", line)
37 line = CPP2.sub(r" /* \1 */", line)
38 buf.append(line)
39 return "".join(buf)
40
41 for name in getfiles():
42 with open(name) as f:
43 res = cleanup(f)
44 with open(name, "w") as f:
45 f.write(res)
46
OLDNEW
« no previous file with comments | « Modules/_hashopenssl.c ('k') | Modules/_sha3/keccak/KeccakF-1600-32.macros » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+