Skip to content
Snippets Groups Projects
Commit 6de5f588 authored by Fernando K's avatar Fernando K
Browse files

Arruma o hash

parent 2c3504c7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
import subprocess as sp, hashlib as hl, sys
process = lambda a: (a[0], ''.join(sp.run(['cpp', '-dD', '-P', '-fpreprocessed'],
input=a[1], text=True, capture_output=True).stdout.split()))
l, s = list(map(process, enumerate(sys.stdin))), []
for i, line in l:
for c in l[i]:
if c == '{': s.append(i)
elif c == '}': lp = s[-1]; s.pop()
print(hl.md5((process(' '.join(l[lp:][1])).encode()
if l[i] == '}' or l[i] == '};' else l[i][1].encode())).hexdigest()[0:3]
if l[i] else '', line[:-1])
while IFS="" read -r l; do
h=$(echo "$l" | sed '/^#w/d' |
cpp -dD -P -fpreprocessed |
tr -d '[:space:]' | md5sum | cut -c -3)
[ -z "$l" ] && h=""
echo "$h $l"
done
......@@ -5,5 +5,5 @@ for arq in fontes/*; do
echo "WARNING: $arq does not end with a newline"
fi
grep --color '.\{59\}' $arq
bash fontes/hash.sh <$arq >fontes-com-hash/$(basename $arq)
python3 fontes/hash.py <$arq >fontes-com-hash/$(basename $arq)
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment