Logistical Regression Dialog: Automatically mark appropriate variables as categorical
[pspp] / src / ui / gui / executor.c
index 8fb4c2603e37662c0753041b1221a131a0ee52cf..9b4c4c91867744008484d3430af834f4faf7848b 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2007, 2009, 2010, 2011  Free Software Foundation
+   Copyright (C) 2007, 2009, 2010, 2011, 2012  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
@@ -26,7 +26,7 @@
 #include "libpspp/cast.h"
 #include "output/driver.h"
 #include "ui/gui/psppire-data-store.h"
-#include "ui/gui/psppire-output-window.h"
+#include "ui/gui/psppire.h"
 
 /* Lazy casereader callback function used by execute_syntax. */
 static struct casereader *
@@ -36,6 +36,20 @@ create_casereader_from_data_store (void *data_store_)
   return psppire_data_store_get_reader (data_store);
 }
 
+/* Ensures that dataset DS has a name, because some parts of the GUI insist
+   upon this. */
+static void
+name_dataset_cb (struct dataset *ds, void *aux UNUSED)
+{
+  if (dataset_name (ds)[0] == '\0')
+    {
+      struct session *session = dataset_session (ds);
+      char *dataset_name = session_generate_dataset_name (session);
+      dataset_set_name (ds, dataset_name);
+      free (dataset_name);
+    }
+}
+
 static void
 new_pdw_cb (struct dataset *ds, void *aux UNUSED)
 {
@@ -131,6 +145,8 @@ execute_syntax (PsppireDataWindow *window, struct lex_reader *lex_reader)
        break;
     }
 
+  session_for_each_dataset (the_session, name_dataset_cb, NULL);
+
   ll_for_each_safe (pdw, next_pdw, PsppireDataWindow, ll, &all_data_windows)
     {
       struct dataset *ds;
@@ -184,5 +200,5 @@ execute_syntax_string (PsppireDataWindow *window, gchar *syntax)
 void
 execute_const_syntax_string (PsppireDataWindow *window, const gchar *syntax)
 {
-  execute_syntax (window, lex_reader_for_string (syntax));
+  execute_syntax (window, lex_reader_for_string (syntax, "UTF-8"));
 }