mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Some configure.py fixes from Guenter.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31985 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
90f392425f
commit
22eab2f2c9
@ -86,17 +86,6 @@ def error(message):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def trim_eol(line):
|
||||
" Remove end of line char(s)."
|
||||
if line[-2:-1] == '\r':
|
||||
return line[:-2]
|
||||
elif line[-1:] == '\r' or line[-1:] == '\n':
|
||||
return line[:-1]
|
||||
else:
|
||||
# file with no EOL in last line
|
||||
return line
|
||||
|
||||
|
||||
def trim_bom(line):
|
||||
" Remove byte order mark."
|
||||
if line[0:3] == "\357\273\277":
|
||||
@ -107,23 +96,14 @@ def trim_bom(line):
|
||||
|
||||
def read(source):
|
||||
" Read input file and strip lineendings."
|
||||
lines = list()
|
||||
first_line = 1
|
||||
while 1:
|
||||
line = source.readline()
|
||||
if not line:
|
||||
break
|
||||
if (first_line):
|
||||
line = trim_bom(line)
|
||||
first_line = 0
|
||||
lines.append(trim_eol(line))
|
||||
lines = source.read().splitlines()
|
||||
lines[0] = trim_bom(lines[0])
|
||||
return lines
|
||||
|
||||
|
||||
def write(output, lines):
|
||||
" Write output file with native lineendings."
|
||||
for line in lines:
|
||||
output.write(line + os.linesep)
|
||||
output.write(os.linesep.join(lines) + os.linesep)
|
||||
|
||||
|
||||
# Concatenates old and new in an intelligent way:
|
||||
|
Loading…
Reference in New Issue
Block a user