Skip to content

Instantly share code, notes, and snippets.

@yuq-1s
Created November 24, 2018 07:52
Show Gist options
  • Save yuq-1s/3ca9053de3b619581b037235f500c789 to your computer and use it in GitHub Desktop.
Save yuq-1s/3ca9053de3b619581b037235f500c789 to your computer and use it in GitHub Desktop.
Compile Junhui Deng's DSA code on a linux machine
#! /bin/bash
find -name '*.cpp' | sed -i 's/typeinfo\.h/typeinfo/g'
find -name '*.h' | sed -i 's/typeinfo\.h/typeinfo/g'
find -name '*.cpp' | python patch.py
find -name '*.h' | python patch.py
imps=$(find -name '*_implementation.h')
for imp in $imps; do
for file in $(echo $imp | cut -d'/' -f3 | sed 's/implementation\.h/\*\.h/g' \
| xargs -l find -name); do
if [[ ! $file =~ _implementation.h ]] && [[ ! $file =~ _test.h ]]; then
cat <(echo) $file | sed '1,10d' >> ${imp}
echo $file asdf
> $file
fi
done
done
#! /usr/bin/env python3
import re
import sys
for filename in sys.stdin:
filename = filename.strip()
if not filename:
continue
if not (filename.endswith('.cpp') or filename.endswith('.h') or filename.endswith('.c')):
print(filename)
print("bad")
sys.exit(1)
print(filename)
with open(filename, 'r', encoding='gb18030') as f:
lines = f.readlines();
with open(filename, 'w', encoding='gb18030') as f:
for line in lines:
if '/*DSA*/' in line:
line = ''.join(line.split('/*DSA*/'))
if re.match(r'\s*#include "(\.\.\\)*(\w+\\)*\w+\.h"', line):
f.write(re.sub(r'\\', '/', line.lower()))
elif re.match(r'\s*#include "(\.\.\/)*(\w+\/)*\w+\.h"', line):
f.write(line.lower())
else:
f.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment