Add support for reading and writing SPV files.
[pspp] / src / ui / gui / psppire.c
index ddfdfbcb8101055db588a73c2e1ba1081ccb0521..2d5c185e018edb41ac603daec7d60f883b1fc702 100644 (file)
@@ -39,6 +39,7 @@
 #include "output/driver.h"
 #include "output/journal.h"
 #include "output/message-item.h"
+#include "output/spv/spv.h"
 
 #include "ui/gui/dict-display.h"
 #include "ui/gui/executor.h"
@@ -160,6 +161,7 @@ handle_msg (const struct msg *m_, void *lexer_)
       m.first_column = lex_get_first_column (lexer, 0);
       m.last_column = lex_get_last_column (lexer, 0);
     }
+  m.command_name = CONST_CAST (char *, output_get_command_name ());
 
   message_item_submit (message_item_create (&m));
 }
@@ -175,13 +177,13 @@ GtkWindow *
 psppire_preload_file (const gchar *file)
 {
   const gchar *local_encoding = "UTF-8";
-  
+
   struct file_handle *fh = fh_create_file (NULL,
                                           file,
                                           local_encoding,
                                           fh_default_properties ());
   const char *filename = fh_get_file_name (fh);
-  
+
   int retval = any_reader_detect (fh, NULL);
 
   GtkWindow *w = NULL;
@@ -191,8 +193,15 @@ psppire_preload_file (const gchar *file)
     w = open_data_window (NULL, filename, NULL, NULL);
   else if (retval == 0)
     {
-      create_data_window ();
-      w = open_syntax_window (filename, NULL);
+      char *error = spv_detect (filename);
+      if (!error)
+        read_spv_file (filename);
+      else
+        {
+          free (error);
+          create_data_window ();
+          open_syntax_window (filename, NULL);
+        }
     }
 
   fh_unref (fh);