ascii: Get rid of the idea of pages.
[pspp] / src / output / driver.c
index 94bc2411c97878781980a455818e326357e7bb6e..bb5aa3a8b9e2ec7cf0256dd44e96a7f3a40dee95 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "data/file-handle-def.h"
 #include "data/settings.h"
 #include "libpspp/array.h"
 #include "libpspp/assertion.h"
@@ -138,9 +139,13 @@ flush_deferred_syntax (struct output_engine *e)
 {
   if (!ds_is_empty (&e->deferred_syntax))
     {
-      char *syntax = ds_steal_cstr (&e->deferred_syntax);
-      output_submit__ (e, text_item_super (
-                         text_item_create_nocopy (TEXT_ITEM_SYNTAX, syntax)));
+      ds_trim (&e->deferred_syntax, ss_cstr ("\n"));
+      if (!ds_is_empty (&e->deferred_syntax))
+        {
+          char *syntax = ds_steal_cstr (&e->deferred_syntax);
+          output_submit__ (e, text_item_super (text_item_create_nocopy (
+                                                 TEXT_ITEM_SYNTAX, syntax)));
+        }
     }
 }
 
@@ -158,6 +163,9 @@ output_submit (struct output_item *item)
 {
   struct output_engine *e = engine_stack_top ();
 
+  if (item == NULL)
+    return;
+
   if (is_syntax_item (item))
     {
       ds_put_cstr (&e->deferred_syntax, text_item_get_text (to_text_item (item)));
@@ -283,9 +291,7 @@ extern const struct output_driver_factory txt_driver_factory;
 extern const struct output_driver_factory list_driver_factory;
 extern const struct output_driver_factory html_driver_factory;
 extern const struct output_driver_factory csv_driver_factory;
-#ifdef ODF_WRITE_SUPPORT
 extern const struct output_driver_factory odt_driver_factory;
-#endif
 #ifdef HAVE_CAIRO
 extern const struct output_driver_factory pdf_driver_factory;
 extern const struct output_driver_factory ps_driver_factory;
@@ -298,9 +304,7 @@ static const struct output_driver_factory *factories[] =
     &list_driver_factory,
     &html_driver_factory,
     &csv_driver_factory,
-#ifdef ODF_WRITE_SUPPORT
     &odt_driver_factory,
-#endif
 #ifdef HAVE_CAIRO
     &pdf_driver_factory,
     &ps_driver_factory,
@@ -375,7 +379,9 @@ output_driver_create (struct string_map *options)
       device_type = default_device_type (file_name);
     }
 
-  driver = f->create (file_name, device_type, options);
+  struct file_handle *fh = fh_create_file (NULL, file_name, NULL, fh_default_properties ());
+
+  driver = f->create (fh, device_type, options);
   if (driver != NULL)
     {
       const struct string_map_node *node;