changeset 18963:4293f49795d9 stable

don't crash on empty script files (bug #42064) * lex.ll (<INPUT_FILE_START><<EOF>>): New pattern.
author John W. Eaton <jwe@octave.org>
date Fri, 23 May 2014 12:20:05 -0400
parents 5e99fd6ea758
children ac0c04e4d141
files libinterp/parse-tree/lex.ll
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll
+++ b/libinterp/parse-tree/lex.ll
@@ -280,6 +280,18 @@
     return curr_lexer->show_token (INPUT_FILE);
   }
 
+<INPUT_FILE_START><<EOF>> {
+    curr_lexer->lexer_debug ("<INPUT_FILE_START><<EOF>>");
+
+    // May be reset later if we see "function" or "classdef" appears
+    // as the first token.
+    curr_lexer->reading_script_file = true;
+
+    curr_lexer->pop_start_state ();
+
+    return curr_lexer->show_token (INPUT_FILE);
+  }
+
 %{
 // Help and other command-style functions.
 %}