X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Foutput%2Fpivot-table-test.c;h=f1944c3237bf828a5f29f44ee0f3e7f954085c74;hb=37cf21cfd0754b6fd196098968df3bdc1c2473a9;hp=d7d63fd39456d25d0ed8b0becc323eb020cf1673;hpb=16420b87c39a3a27071fde7727db49bd577ea58e;p=pspp diff --git a/tests/output/pivot-table-test.c b/tests/output/pivot-table-test.c index d7d63fd394..f1944c3237 100644 --- a/tests/output/pivot-table-test.c +++ b/tests/output/pivot-table-test.c @@ -32,10 +32,9 @@ #include "libpspp/i18n.h" #include "libpspp/string-map.h" #include "output/driver.h" -#include "output/message-item.h" #include "output/options.h" +#include "output/output-item.h" #include "output/pivot-table.h" -#include "output/table-item.h" #include "gl/error.h" #include "gl/progname.h" @@ -69,7 +68,7 @@ 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); @@ -599,16 +598,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; @@ -618,12 +617,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; } @@ -631,12 +631,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; } @@ -678,8 +679,10 @@ read_value (struct lexer *lexer, const struct pivot_table *pt, { value = xmalloc (sizeof *value); *value = (struct pivot_value) { - .type = PIVOT_VALUE_STRING, - .string = { .s = xstrdup (lex_tokcstr (lexer)) }, + .string = { + .type = PIVOT_VALUE_STRING, + .s = xstrdup (lex_tokcstr (lexer)) + }, }; lex_get (lexer); } @@ -687,8 +690,10 @@ read_value (struct lexer *lexer, const struct pivot_table *pt, { value = xmalloc (sizeof *value); *value = (struct pivot_value) { - .type = PIVOT_VALUE_VARIABLE, - .variable = { .var_name = xstrdup (lex_tokcstr (lexer)) }, + .variable = { + .type = PIVOT_VALUE_VARIABLE, + .var_name = xstrdup (lex_tokcstr (lexer)) + }, }; lex_get (lexer); } @@ -1228,18 +1233,19 @@ static void output_msg (const struct msg *m_, void *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, + }; - message_item_submit (message_item_create (&m)); + output_item_submit (message_item_create (&m)); free (m.command_name); + if (m.location != m_->location) + msg_location_destroy (m.location); }