mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-19 22:40:26 +00:00
Do not corrupt documents without newline at EOF
trim_eol() assumes that a line always ends either with \n, \r, or \r\n. This assumption is always valid except for the last line of a document, since it may miss the trailing newline. LyX does not create such documents, bu they may result from automatic creation tools, and LyX can read them, so lyx2lyx should be able to read them as well.
This commit is contained in:
parent
0080201977
commit
c75c6e446a
@ -147,6 +147,9 @@ def get_backend(textclass):
|
||||
|
||||
def trim_eol(line):
|
||||
" Remove end of line char(s)."
|
||||
if line[-1] != '\n':
|
||||
# May happen for the last line of a document
|
||||
return line
|
||||
if line[-2:-1] == '\r':
|
||||
return line[:-2]
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user