X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=tests%2Foutput%2Fpivot-table-test.c;h=8bed7550ebb0cc3d7143d04b8b2ac6e7a1d1875f;hb=d7c0b284ec4dee676bd1817c64720aecc7a72992;hp=98336b2563f3aefd89d42ee6de5838b0cdd6df51;hpb=478f1bffcdec0b01391b8297e2df1a1f6aa7d4cf;p=pspp
diff --git a/tests/output/pivot-table-test.c b/tests/output/pivot-table-test.c
index 98336b2563..8bed7550eb 100644
--- a/tests/output/pivot-table-test.c
+++ b/tests/output/pivot-table-test.c
@@ -53,7 +53,7 @@ static const char *output_base = "render";
static const char *parse_options (int argc, char **argv);
static void usage (void) NO_RETURN;
static void read_table (struct lexer *);
-static void output_msg (const struct msg *, void *);
+static void output_msg (const struct msg *, struct lexer *);
int
main (int argc, char **argv)
@@ -68,13 +68,13 @@ main (int argc, char **argv)
settings_init ();
struct lex_reader *reader = lex_reader_for_file (input_file_name, NULL,
- LEX_SYNTAX_AUTO,
+ SEG_MODE_AUTO,
LEX_ERROR_CONTINUE);
if (!reader)
exit (1);
struct lexer *lexer = lex_create ();
- msg_set_handler (output_msg, lexer);
+ lex_set_message_handler (lexer, output_msg);
lex_include (lexer, reader);
lex_get (lexer);
@@ -137,12 +137,18 @@ configure_drivers (int width, int length UNUSED, int min_break)
string_map_insert (&options, "trim", "true");
register_driver (&options, "%s.pdf", output_base);
+ /* Render to -paged.pdf. */
+ register_driver (&options, "%s-paged.pdf", output_base);
+
+ /* Render to .txt. */
string_map_insert (&options, "box", "unicode");
register_driver (&options, "%s.txt", output_base);
+ /* Render to -ascii.txt. */
string_map_insert (&options, "box", "ascii");
register_driver (&options, "%s-ascii.txt", output_base);
+ /* Render additional versions. */
register_driver (&options, "%s.csv", output_base);
register_driver (&options, "%s.odt", output_base);
register_driver (&options, "%s.spv", output_base);
@@ -598,16 +604,16 @@ read_value_option (struct lexer *lexer, const struct pivot_table *pt,
if (lex_match_id (lexer, "SUBSCRIPTS"))
{
lex_match (lexer, T_EQUALS);
- size_t allocated_subscripts = value->n_subscripts;
+
+ struct pivot_value_ex *ex = pivot_value_ex_rw (value);
+ size_t allocated_subscripts = ex->n_subscripts;
while (lex_token (lexer) == T_STRING)
{
- if (value->n_subscripts >= allocated_subscripts)
- value->subscripts = x2nrealloc (value->subscripts,
- &allocated_subscripts,
- sizeof *value->subscripts);
+ if (ex->n_subscripts >= allocated_subscripts)
+ ex->subscripts = x2nrealloc (ex->subscripts, &allocated_subscripts,
+ sizeof *ex->subscripts);
- value->subscripts[value->n_subscripts++] = xstrdup (
- lex_tokcstr (lexer));
+ ex->subscripts[ex->n_subscripts++] = xstrdup (lex_tokcstr (lexer));
lex_get (lexer);
}
return;
@@ -617,12 +623,13 @@ read_value_option (struct lexer *lexer, const struct pivot_table *pt,
{
lex_match (lexer, T_EQUALS);
- if (!value->font_style)
+ struct pivot_value_ex *ex = pivot_value_ex_rw (value);
+ if (!ex->font_style)
{
- value->font_style = xmalloc (sizeof *value->font_style);
- font_style_copy (NULL, value->font_style, &base_style->font_style);
+ ex->font_style = xmalloc (sizeof *ex->font_style);
+ font_style_copy (NULL, ex->font_style, &base_style->font_style);
}
- read_font_style (lexer, value->font_style);
+ read_font_style (lexer, ex->font_style);
return;
}
@@ -630,12 +637,13 @@ read_value_option (struct lexer *lexer, const struct pivot_table *pt,
{
lex_match (lexer, T_EQUALS);
- if (!value->cell_style)
+ struct pivot_value_ex *ex = pivot_value_ex_rw (value);
+ if (!ex->cell_style)
{
- value->cell_style = xmalloc (sizeof *value->cell_style);
- *value->cell_style = base_style->cell_style;
+ ex->cell_style = xmalloc (sizeof *ex->cell_style);
+ *ex->cell_style = base_style->cell_style;
}
- read_cell_style (lexer, value->cell_style);
+ read_cell_style (lexer, ex->cell_style);
return;
}
@@ -659,7 +667,7 @@ read_value_option (struct lexer *lexer, const struct pivot_table *pt,
return;
}
- lex_error (lexer, "Expecting valid value option");
+ lex_error (lexer, "Syntax error expecting valid value option.");
exit (1);
}
@@ -824,7 +832,7 @@ read_stroke (struct lexer *lexer)
if (lex_match_id (lexer, table_stroke_to_string (stroke)))
return stroke;
- lex_error (lexer, "expecting stroke");
+ lex_error (lexer, "Syntax error expecting stroke.");
exit (1);
}
@@ -1222,27 +1230,27 @@ read_table (struct lexer *lexer)
if (!displayed)
pivot_table_submit (pt);
else
- pivot_table_unshare (pt);
+ pivot_table_unref (pt);
force_match (lexer, T_ENDCMD);
}
static void
-output_msg (const struct msg *m_, void *lexer_)
+output_msg (const struct msg *m_, struct lexer *lexer)
{
- struct lexer *lexer = lexer_;
- struct msg m = *m_;
-
- if (m.file_name == NULL)
- {
- m.file_name = CONST_CAST (char *, lex_get_file_name (lexer));
- m.first_line = lex_get_first_line_number (lexer, 0);
- m.last_line = lex_get_last_line_number (lexer, 0);
- }
-
- m.command_name = output_get_uppercase_command_name ();
+ struct msg m = {
+ .category = m_->category,
+ .severity = m_->severity,
+ .location = (m_->location ? m_->location
+ : lexer ? lex_get_location (lexer, 0, 0)
+ : NULL),
+ .command_name = output_get_uppercase_command_name (),
+ .text = m_->text,
+ };
output_item_submit (message_item_create (&m));
free (m.command_name);
+ if (m.location != m_->location)
+ msg_location_destroy (m.location);
}