const char *newline;
const char *line;
size_t line_len;
+ char *syntax;
line = &src->buffer[src->journal_pos - src->tail];
newline = rawmemchr (line, '\n');
if (line_len > 0 && line[line_len - 1] == '\r')
line_len--;
- text_item_submit (text_item_create_nocopy (TEXT_ITEM_SYNTAX,
- xmemdup0 (line, line_len)));
+ syntax = malloc (line_len + 2);
+ memcpy (syntax, line, line_len);
+ syntax[line_len] = '\n';
+ syntax[line_len + 1] = '\0';
+
+ text_item_submit (text_item_create_nocopy (TEXT_ITEM_SYNTAX, syntax));
src->journal_pos += newline - line + 1;
}
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
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
/* Drivers currently registered with output_driver_register(). */
static struct llx_list drivers = LLX_INITIALIZER (drivers);
+/* TEXT_ITEM_SYNTAX being accumulated until another kind of output arrives. */
+static struct string deferred_syntax = DS_EMPTY_INITIALIZER;
+
void
output_close (void)
{
string_set_insert (formats, (*fp)->extension);
}
-/* Submits ITEM to the configured output drivers, and transfers ownership to
- the output subsystem. */
-void
-output_submit (struct output_item *item)
+static void
+output_submit__ (struct output_item *item)
{
struct llx *llx, *next;
output_item_unref (item);
}
+static void
+flush_deferred_syntax (void)
+{
+ if (!ds_is_empty (&deferred_syntax))
+ {
+ char *syntax = ds_steal_cstr (&deferred_syntax);
+ output_submit__ (text_item_super (
+ text_item_create_nocopy (TEXT_ITEM_SYNTAX, syntax)));
+ }
+}
+
+static bool
+is_syntax_item (const struct output_item *item)
+{
+ return (is_text_item (item)
+ && text_item_get_type (to_text_item (item)) == TEXT_ITEM_SYNTAX);
+}
+
+/* Submits ITEM to the configured output drivers, and transfers ownership to
+ the output subsystem. */
+void
+output_submit (struct output_item *item)
+{
+ if (is_syntax_item (item))
+ {
+ ds_put_cstr (&deferred_syntax, text_item_get_text (to_text_item (item)));
+ output_item_unref (item);
+ return;
+ }
+
+ flush_deferred_syntax ();
+ output_submit__ (item);
+}
+
/* Flushes output to screen devices, so that the user can see
output that doesn't fill up an entire page. */
void
{
struct llx *llx;
+ flush_deferred_syntax ();
for (llx = llx_head (&drivers); llx != llx_null (&drivers);
llx = llx_next (llx))
{
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
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
char *command_name;
FILE *file;
size_t chart_cnt;
-
- bool in_syntax;
};
static const struct output_driver_class html_driver_class;
if (html->file != NULL)
{
- if (html->in_syntax)
- {
- fprintf (html->file, "</PRE>\n");
- html->in_syntax = false;
- }
fprintf (html->file,
"</BODY>\n"
"</HTML>\n"
free (html);
}
-static bool
-is_syntax_item (const struct output_item *item)
-{
- return (is_text_item (item)
- && text_item_get_type (to_text_item (item)) == TEXT_ITEM_SYNTAX);
-}
-
static void
html_submit (struct output_driver *driver,
const struct output_item *output_item)
output_driver_track_current_command (output_item, &html->command_name);
- if (html->in_syntax && !is_syntax_item (output_item))
- {
- fprintf (html->file, "</PRE>\n");
- html->in_syntax = false;
- }
-
if (is_table_item (output_item))
{
struct table_item *table_item = to_table_item (output_item);
break;
case TEXT_ITEM_SYNTAX:
- if (!html->in_syntax)
- {
- fprintf (html->file, "<PRE class=\"syntax\">");
- html->in_syntax = true;
- }
- else
- putc ('\n', html->file);
+ fprintf (html->file, "<PRE class=\"syntax\">");
escape_string (html->file, s, strlen (s), " ");
+ fprintf (html->file, "</PRE>\n");
break;
case TEXT_ITEM_PARAGRAPH:
╰─┴───╯
])
AT_CLEANUP
+
+AT_SETUP([ASCII driver syntax printback])
+AT_DATA([ascii.sps], [dnl
+SET PRINTBACK=ON.
+DATA LIST LIST /x * y * a (a23).
+BEGIN DATA.
+1 11 One
+2 22 Two
+3 33 Three
+END DATA.
+
+REGRESSION
+/VARIABLES= a
+/DEPENDENT= x y
+/STATISTICS=COEFF R ANOVA.
+])
+AT_CHECK([pspp ascii.sps], [1], [dnl
+SET PRINTBACK=ON.
+
+DATA LIST LIST /x * y * a (a23).
+
+Reading free-form data from INLINE.
++--------+------+
+|Variable|Format|
+#========#======#
+|x |F8.0 |
+|y |F8.0 |
+|a |A23 |
++--------+------+
+
+BEGIN DATA.
+1 11 One
+2 22 Two
+3 33 Three
+END DATA.
+
+REGRESSION
+/VARIABLES= a
+/DEPENDENT= x y
+/STATISTICS=COEFF R ANOVA.
+
+ascii.sps:12: error: REGRESSION: REGRESSION requires numeric variables.
+])
+AT_CLEANUP