gui: Make syntax execution functions take a PsppireDataWindow argument.
[pspp-builds.git] / src / ui / gui / executor.c
index 6377107c85ee0a8ff82949ba81d55fb225c26f3a..584b13762744afe820572dcdd7f0044c4725b5a4 100644 (file)
@@ -39,7 +39,7 @@ create_casereader_from_data_store (void *data_store_)
 }
 
 gboolean
-execute_syntax (struct lex_reader *lex_reader)
+execute_syntax (PsppireDataWindow *window, struct lex_reader *lex_reader)
 {
   struct lexer *lexer;
   gboolean retval = TRUE;
@@ -90,9 +90,6 @@ execute_syntax (struct lex_reader *lex_reader)
        break;
     }
 
-  lex_destroy (lexer);
-  psppire_set_lexer (NULL);
-
   proc_execute (the_dataset);
 
   psppire_dict_replace_dictionary (the_data_store->dict,
@@ -102,6 +99,13 @@ execute_syntax (struct lex_reader *lex_reader)
   if (!lazy_casereader_destroy (reader, lazy_serial))
     psppire_data_store_set_reader (the_data_store, reader);
 
+  /* Destroy the lexer only after obtaining the dataset, because the dataset
+     might depend on the lexer, if the casereader specifies inline data.  (In
+     such a case then we'll always get an error message--the inline data is
+     missing, otherwise it would have been parsed in the loop above.) */
+  lex_destroy (lexer);
+  psppire_set_lexer (NULL);
+
   output_flush ();
 
   return retval;
@@ -110,15 +114,15 @@ execute_syntax (struct lex_reader *lex_reader)
 /* Executes null-terminated string SYNTAX as syntax.
    Returns SYNTAX. */
 gchar *
-execute_syntax_string (gchar *syntax)
+execute_syntax_string (PsppireDataWindow *window, gchar *syntax)
 {
-  execute_const_syntax_string (syntax);
+  execute_const_syntax_string (window, syntax);
   return syntax;
 }
 
 /* Executes null-terminated string SYNTAX as syntax. */
 void
-execute_const_syntax_string (const gchar *syntax)
+execute_const_syntax_string (PsppireDataWindow *window, const gchar *syntax)
 {
-  execute_syntax (lex_reader_for_string (syntax));
+  execute_syntax (window, lex_reader_for_string (syntax));
 }