From fd2cc135255fe4c37d8119867e3d0841f0b6af65 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 30 Dec 2020 16:49:41 -0800 Subject: [PATCH] work on pivot-table-test --- tests/output/pivot-table-test.c | 98 ++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/tests/output/pivot-table-test.c b/tests/output/pivot-table-test.c index 44347fb4f2..514ce7f8dc 100644 --- a/tests/output/pivot-table-test.c +++ b/tests/output/pivot-table-test.c @@ -376,6 +376,54 @@ parse_bool_setting (struct lexer *lexer, const char *name, return false; } +static bool +parse_settings_value_show (struct lexer *lexer, const char *name, + enum settings_value_show *show) +{ + if (lex_match_id (lexer, name)) + { + if (!lex_force_match (lexer, T_EQUALS)) + exit (1); + + if (lex_match_id (lexer, "DEFAULT")) + *show = SETTINGS_VALUE_SHOW_DEFAULT; + else if (lex_match_id (lexer, "VALUE")) + *show = SETTINGS_VALUE_SHOW_VALUE; + else if (lex_match_id (lexer, "LABEL")) + *show = SETTINGS_VALUE_SHOW_LABEL; + else if (lex_match_id (lexer, "BOTH")) + *show = SETTINGS_VALUE_SHOW_BOTH; + else + { + lex_error_expecting (lexer, "DEFAULT", "VALUE", "LABEL", "BOTH"); + exit (1); + } + + return true; + } + else + return false; +} + +static bool +parse_string_setting (struct lexer *lexer, const char *name, char **stringp) +{ + if (lex_match_id (lexer, name)) + { + lex_match (lexer, T_EQUALS); + if (!lex_force_string (lexer)) + exit (1); + + free (*stringp); + *stringp = xstrdup (lex_tokcstr (lexer)); + + lex_get (lexer); + return true; + } + else + return false; +} + static void read_look (struct lexer *lexer, struct pivot_table *pt) { @@ -419,7 +467,9 @@ read_look (struct lexer *lexer, struct pivot_table *pt) && !parse_bool_setting (lexer, "TOPCONTINUATION", "YES", "NO", &look->top_continuation) && !parse_bool_setting (lexer, "BOTTOMCONTINUATION", "YES", "NO", - &look->bottom_continuation)) + &look->bottom_continuation) + && !parse_string_setting (lexer, "CONTINUATION", + &look->continuation)) break; } pivot_table_set_look (pt, look); @@ -437,6 +487,23 @@ read_stroke (struct lexer *lexer) exit (1); } +static bool +parse_value_setting (struct lexer *lexer, const char *name, + struct pivot_value **valuep) +{ + if (lex_match_id (lexer, name)) + { + lex_match (lexer, T_EQUALS); + + pivot_value_destroy (*valuep); + *valuep = read_value (lexer); + + return true; + } + else + return false; +} + static void read_border (struct lexer *lexer, struct pivot_table *pt) { @@ -537,13 +604,30 @@ read_table (struct lexer *lexer) { lex_match (lexer, T_EQUALS); while (lex_token (lexer) == T_ID) - if (!parse_bool_setting (lexer, "GRID", "YES", "NO", - &pt->show_grid_lines) - && !parse_bool_setting (lexer, "CAPTION", "YES", "NO", - &pt->show_caption) - && !parse_bool_setting (lexer, "TITLE", "YES", "NO", - &pt->show_caption)) + { + if (parse_bool_setting (lexer, "GRID", "YES", "NO", + &pt->show_grid_lines) + || parse_bool_setting (lexer, "CAPTION", "YES", "NO", + &pt->show_caption) + || parse_bool_setting (lexer, "TITLE", "YES", "NO", + &pt->show_title)) + continue; + + if (parse_settings_value_show (lexer, "VALUES", &pt->show_values) + || parse_settings_value_show (lexer, "VARIABLES", + &pt->show_variables)) + continue; + break; + } + } + else if (parse_value_setting (lexer, "TITLE", &pt->title) + || parse_value_setting (lexer, "SUBTYPE", &pt->subtype) + || parse_value_setting (lexer, "CORNER", &pt->corner_text) + || parse_value_setting (lexer, "CAPTION", &pt->caption) + || parse_string_setting (lexer, "NOTES", &pt->notes)) + { + /* Nothing. */ } else if (lex_match_id (lexer, "BORDER")) read_border (lexer, pt); -- 2.30.2