more robust;
authorwenzelm
Tue, 13 Nov 2018 20:57:54 +0100
changeset 69300 085f31ae902d
parent 69299 72a9860f8602
child 69301 0fd23badd749
child 69305 b8b33ef47f40
child 69309 2fd070377c99
more robust;
src/Pure/Thy/bibtex.scala
--- a/src/Pure/Thy/bibtex.scala	Tue Nov 13 12:37:46 2018 +0100
+++ b/src/Pure/Thy/bibtex.scala	Tue Nov 13 20:57:54 2018 +0100
@@ -125,19 +125,22 @@
       val lines = if (log_file.is_file) Line.logical_lines(File.read(log_file)) else Nil
 
       val (errors, warnings) =
-        lines.zip(lines.tail ::: List("")).flatMap(
-          {
-            case (Error(msg, Value.Int(l)), _) =>
-              Some((true, (msg, get_line_pos(l))))
-            case (Warning_in_Chunk(msg, name), _) if chunk_pos.isDefinedAt(name) =>
-              Some((false, (Word.capitalize(msg + " in entry " + quote(name)), chunk_pos(name))))
-            case (Warning(msg), Warning_Line(Value.Int(l))) =>
-              Some((false, (Word.capitalize(msg), get_line_pos(l))))
-            case (Warning(msg), _) =>
-              Some((false, (Word.capitalize(msg), Position.none)))
-            case _ => None
-          }
-        ).partition(_._1)
+        if (lines.isEmpty) (Nil, Nil)
+        else {
+          lines.zip(lines.tail ::: List("")).flatMap(
+            {
+              case (Error(msg, Value.Int(l)), _) =>
+                Some((true, (msg, get_line_pos(l))))
+              case (Warning_in_Chunk(msg, name), _) if chunk_pos.isDefinedAt(name) =>
+                Some((false, (Word.capitalize(msg + " in entry " + quote(name)), chunk_pos(name))))
+              case (Warning(msg), Warning_Line(Value.Int(l))) =>
+                Some((false, (Word.capitalize(msg), get_line_pos(l))))
+              case (Warning(msg), _) =>
+                Some((false, (Word.capitalize(msg), Position.none)))
+              case _ => None
+            }
+          ).partition(_._1)
+        }
       (errors.map(_._2), warnings.map(_._2))
     })
   }