output: Improve comments.
[pspp] / src / output / driver.c
index e953d11a63ff0374a75b843ec3c8b78f3f4ecbea..cf0a535f3c059ce6ae9b05a084b76ea94925265c 100644 (file)
@@ -32,6 +32,7 @@
 #include "data/settings.h"
 #include "libpspp/array.h"
 #include "libpspp/assertion.h"
+#include "libpspp/i18n.h"
 #include "libpspp/message.h"
 #include "libpspp/llx.h"
 #include "libpspp/string-map.h"
@@ -193,7 +194,11 @@ defer_text (struct output_engine *e, struct output_item *item)
   if (!is_text_item (item))
     return false;
 
-  enum text_item_type type = text_item_get_type (to_text_item (item));
+  struct text_item *text_item = to_text_item (item);
+  if (text_item->markup)        /* XXX */
+    return false;
+
+  enum text_item_type type = text_item_get_type (text_item);
   if (type != TEXT_ITEM_SYNTAX && type != TEXT_ITEM_LOG)
     return false;
 
@@ -205,7 +210,7 @@ defer_text (struct output_engine *e, struct output_item *item)
   if (!ds_is_empty (&e->deferred_text))
     ds_put_byte (&e->deferred_text, '\n');
 
-  const char *text = text_item_get_text (to_text_item (item));
+  const char *text = text_item_get_text (text_item);
   ds_put_cstr (&e->deferred_text, text);
   output_item_unref (item);
 
@@ -250,7 +255,7 @@ output_submit (struct output_item *item)
       if (idx >= 1 && idx <= 4)
         {
           char *key = xasprintf ("Head%zu", idx);
-          string_map_find_and_delete (&e->heading_vars, key);
+          free (string_map_find_and_delete (&e->heading_vars, key));
           free (key);
         }
     }
@@ -273,16 +278,20 @@ output_submit (struct output_item *item)
   output_submit__ (e, item);
 }
 
-const char *
+/* Returns the name of the command currently being parsed, in all uppercase.
+   The caller must free the returned value.
+
+   Returns NULL if no command is being parsed. */
+char *
 output_get_command_name (void)
 {
   struct output_engine *e = engine_stack_top ();
   if (e == NULL)
     return NULL;
 
-  for (size_t i = e->n_groups; i-- > 0; )
+  for (size_t i = e->n_groups; i-- > 0;)
     if (e->groups[i])
-      return e->groups[i];
+      return utf8_to_upper (e->groups[i]);
 
   return NULL;
 }
@@ -426,11 +435,14 @@ 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;
 extern const struct output_driver_factory odt_driver_factory;
+extern const struct output_driver_factory spv_driver_factory;
 #ifdef HAVE_CAIRO
 extern const struct output_driver_factory pdf_driver_factory;
 extern const struct output_driver_factory ps_driver_factory;
 extern const struct output_driver_factory svg_driver_factory;
+extern const struct output_driver_factory png_driver_factory;
 #endif
+extern const struct output_driver_factory tex_driver_factory;
 
 static const struct output_driver_factory *factories[] =
   {
@@ -439,11 +451,14 @@ static const struct output_driver_factory *factories[] =
     &html_driver_factory,
     &csv_driver_factory,
     &odt_driver_factory,
+    &spv_driver_factory,
 #ifdef HAVE_CAIRO
     &pdf_driver_factory,
     &ps_driver_factory,
     &svg_driver_factory,
+    &png_driver_factory,
 #endif
+    &tex_driver_factory,
     NULL
   };
 
@@ -585,7 +600,7 @@ output_driver_substitute_heading_vars (const char *src, int page_number)
   struct output_engine *e = engine_stack_top ();
   struct string dst = DS_EMPTY_INITIALIZER;
   ds_extend (&dst, strlen (src));
-  for (const char *p = src; *p; )
+  for (const char *p = src; *p;)
     {
       if (!strncmp (p, "&amp;[", 6))
         {