mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
fixing eol
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
00935cffd2
commit
276befb78e
|
@ -9,6 +9,7 @@
|
||||||
from mk_util import *
|
from mk_util import *
|
||||||
|
|
||||||
parse_options()
|
parse_options()
|
||||||
|
check_eol()
|
||||||
|
|
||||||
add_lib('util', [])
|
add_lib('util', [])
|
||||||
add_lib('polynomial', ['util'], 'math/polynomial')
|
add_lib('polynomial', ['util'], 'math/polynomial')
|
||||||
|
|
|
@ -13,6 +13,7 @@ import getopt
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
from mk_exception import *
|
from mk_exception import *
|
||||||
|
from fnmatch import fnmatch
|
||||||
|
|
||||||
BUILD_DIR='build'
|
BUILD_DIR='build'
|
||||||
REV_BUILD_DIR='..'
|
REV_BUILD_DIR='..'
|
||||||
|
@ -26,6 +27,48 @@ ONLY_MAKEFILES = False
|
||||||
PYTHON_DIR=None
|
PYTHON_DIR=None
|
||||||
VS_PROJ = False
|
VS_PROJ = False
|
||||||
|
|
||||||
|
def is_cr_lf(fname):
|
||||||
|
# Check whether text files use cr/lf
|
||||||
|
f = open(fname, 'r')
|
||||||
|
line = f.readline()
|
||||||
|
sz = len(line)
|
||||||
|
return sz >= 2 and line[sz-2] == '\r' and line[sz-1] == '\n'
|
||||||
|
|
||||||
|
# dos2unix in python
|
||||||
|
# cr/lf --> lf
|
||||||
|
def dos2unix(fname):
|
||||||
|
if is_cr_lf(fname):
|
||||||
|
fin = open(fname, 'r')
|
||||||
|
fname_new = '%s.new' % fname
|
||||||
|
fout = open(fname_new, 'w')
|
||||||
|
for line in fin:
|
||||||
|
line = line.rstrip('\r\n')
|
||||||
|
fout.write(line)
|
||||||
|
fout.write('\n')
|
||||||
|
fin.close()
|
||||||
|
fout.close()
|
||||||
|
shutil.move(fname_new, fname)
|
||||||
|
if is_verbose():
|
||||||
|
print "dos2unix '%s'" % fname
|
||||||
|
|
||||||
|
def dos2unix_tree_core(pattern, dir, files):
|
||||||
|
for filename in files:
|
||||||
|
if fnmatch(filename, pattern):
|
||||||
|
fname = os.path.join(dir, filename)
|
||||||
|
if not os.path.isdir(fname):
|
||||||
|
dos2unix(fname)
|
||||||
|
|
||||||
|
def dos2unix_tree():
|
||||||
|
os.path.walk('src', dos2unix_tree_core, '*')
|
||||||
|
|
||||||
|
def check_eol():
|
||||||
|
if not IS_WINDOW:
|
||||||
|
# Linux/OSX/BSD check if the end-of-line is cr/lf
|
||||||
|
if is_cr_lf('LICENSE.txt'):
|
||||||
|
if is_verbose():
|
||||||
|
print "Fixing end of line..."
|
||||||
|
dos2unix_tree()
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
IS_WINDOW=True
|
IS_WINDOW=True
|
||||||
# Visual Studio already displays the files being compiled
|
# Visual Studio already displays the files being compiled
|
||||||
|
|
Loading…
Reference in a new issue