X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fjournal.c;h=2dd1925843c84a595a6c247292014a9b2229fcbe;hb=29917c4f5908454803e663d2ad78bca4bc35e805;hp=9cab78805177592a00b0ca92041ab6cf0fc99f92;hpb=96994a54e60e9c95b8bba54c2281acf7059b1203;p=pspp diff --git a/src/output/journal.c b/src/output/journal.c index 9cab788051..2dd1925843 100644 --- a/src/output/journal.c +++ b/src/output/journal.c @@ -28,8 +28,7 @@ #include "libpspp/message.h" #include "libpspp/str.h" #include "output/driver-provider.h" -#include "output/message-item.h" -#include "output/text-item.h" +#include "output/output-item.h" #include "gl/fwriteerror.h" #include "gl/xalloc.h" @@ -85,17 +84,19 @@ journal_destroy (struct output_driver *driver) } static void -journal_output (struct journal_driver *j, const char *s) +journal_output (struct journal_driver *j, char *s) { - if (j->file == NULL) - return; + if (j->file) + { + fprintf (j->file, "%s\n", s); - fprintf (j->file, "%s\n", s); + /* Flush the journal in case the syntax we're about to write + causes a crash. Having the syntax already written to disk + makes postmortem analysis of the problem possible. */ + fflush (j->file); + } - /* Flush the journal in case the syntax we're about to write - causes a crash. Having the syntax already written to disk - makes postmortem analysis of the problem possible. */ - fflush (j->file); + free (s); } static void @@ -103,20 +104,25 @@ journal_submit (struct output_driver *driver, const struct output_item *item) { struct journal_driver *j = journal_driver_cast (driver); - if (is_text_item (item)) - { - const struct text_item *text_item = to_text_item (item); - enum text_item_type type = text_item_get_type (text_item); - - if (type == TEXT_ITEM_SYNTAX) - journal_output (j, text_item_get_text (text_item)); - } - else if (is_message_item (item)) + switch (item->type) { - const struct message_item *message_item = to_message_item (item); - char *s = msg_to_string (message_item_get_msg (message_item)); - journal_output (j, s); - free (s); + case OUTPUT_ITEM_MESSAGE: + journal_output (j, msg_to_string (item->message)); + break; + + case OUTPUT_ITEM_TEXT: + if (item->text.subtype == TEXT_ITEM_SYNTAX) + journal_output (j, text_item_get_plain_text (item)); + break; + + case OUTPUT_ITEM_CHART: + case OUTPUT_ITEM_GROUP_OPEN: + case OUTPUT_ITEM_GROUP_CLOSE: + case OUTPUT_ITEM_IMAGE: + case OUTPUT_ITEM_PAGE_BREAK: + case OUTPUT_ITEM_PAGE_SETUP: + case OUTPUT_ITEM_TABLE: + break; } }