gui: Factor out duplicated code for executing and pasting syntax.
[pspp-builds.git] / src / ui / gui / executor.c
index aa2fae51ce127b95cfe6c607da50c2da95fe406f..24b80db2443d3163ee5978ba02b8417341fac102 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2009  Free Software Foundation
+   Copyright (C) 2007, 2009, 2010  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <config.h>
 
-#include "executor.h"
-#include "psppire-data-store.h"
-#include <data/lazy-casereader.h>
-#include <data/procedure.h>
-#include <libpspp/getl.h>
-#include <language/lexer/lexer.h>
-#include <language/command.h>
-#include <output/manager.h>
-#include "psppire-output-window.h"
+#include "ui/gui/executor.h"
+
+#include "data/lazy-casereader.h"
+#include "data/procedure.h"
+#include "language/command.h"
+#include "language/lexer/lexer.h"
+#include "language/syntax-string-source.h"
+#include "libpspp/cast.h"
+#include "libpspp/getl.h"
+#include "output/driver.h"
+#include "ui/gui/psppire-data-store.h"
+#include "ui/gui/psppire-output-window.h"
 
 extern struct dataset *the_dataset;
 extern struct source_stream *the_source_stream;
@@ -95,6 +98,8 @@ execute_syntax (struct getl_interface *sss)
 
   lex_destroy (lexer);
 
+  proc_execute (the_dataset);
+
   psppire_dict_replace_dictionary (the_data_store->dict,
                                   dataset_dict (the_dataset));
 
@@ -102,7 +107,23 @@ execute_syntax (struct getl_interface *sss)
   if (!lazy_casereader_destroy (reader, lazy_serial))
     psppire_data_store_set_reader (the_data_store, reader);
 
-  som_flush ();
+  output_flush ();
 
   return retval;
 }
+
+/* Executes null-terminated string SYNTAX as syntax.
+   Returns SYNTAX. */
+gchar *
+execute_syntax_string (gchar *syntax)
+{
+  execute_const_syntax_string (syntax);
+  return syntax;
+}
+
+/* Executes null-terminated string SYNTAX as syntax. */
+void
+execute_const_syntax_string (const gchar *syntax)
+{
+  execute_syntax (create_syntax_string_source (syntax));
+}