]> git.lyx.org Git - features.git/commitdiff
Improve comments and add missing decoding call
authorGeorg Baum <baum@lyx.org>
Sat, 11 Jun 2016 12:45:18 +0000 (14:45 +0200)
committerGeorg Baum <baum@lyx.org>
Sat, 11 Jun 2016 12:46:48 +0000 (14:46 +0200)
We do already fill the first line of the body in the first pass, so the body
has to be converted to the correct encoding as well.

lib/lyx2lyx/LyX.py

index fa2bbba6195a8b6010e07a2ac8459a29006e0f87..d98d7656674cb62f1b06479af30cefa8d5bf7c21 100644 (file)
@@ -280,17 +280,20 @@ class LyX_base:
         """Reads a file into the self.header and
         self.body parts, from self.input."""
 
+        # First pass: Read header to determine file encoding
         while True:
             line = self.input.readline()
             if not line:
-                self.error("Invalid LyX file.")
+                # eof found before end of header
+                self.error("Invalid LyX file: Missing body.")
 
             line = trim_eol(line)
             if check_token(line, '\\begin_preamble'):
                 while 1:
                     line = self.input.readline()
                     if not line:
-                        self.error("Invalid LyX file.")
+                        # eof found before end of header
+                        self.error("Invalid LyX file: Missing body.")
 
                     line = trim_eol(line)
                     if check_token(line, '\\end_preamble'):
@@ -345,6 +348,8 @@ class LyX_base:
             self.header[i] = self.header[i].decode(self.encoding)
         for i in range(len(self.preamble)):
             self.preamble[i] = self.preamble[i].decode(self.encoding)
+        for i in range(len(self.body)):
+            self.body[i] = self.body[i].decode(self.encoding)
 
         # Read document body
         while 1: