X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Foutput%2Frender-test.c;h=8ce0697910537194d450a09809ef73a2fd3079e9;hb=58c0ae54e9ff110922aa41bb51c82baa9fb0bb3b;hp=fbc0f208484d973f4170b053abd694d8761fca68;hpb=93ec42221da8b677420bf11435e0d24d0503601b;p=pspp diff --git a/tests/output/render-test.c b/tests/output/render-test.c index fbc0f20848..8ce0697910 100644 --- a/tests/output/render-test.c +++ b/tests/output/render-test.c @@ -56,6 +56,9 @@ static int render_stdout = true; /* --pdf: Also render PDF output. */ static int render_pdf; +/* --csv: Also render CSV output. */ +static int render_csv; + /* ASCII driver, for ASCII driver test mode. */ static struct output_driver *ascii_driver; @@ -74,6 +77,7 @@ main (int argc, char **argv) FILE *input; set_program_name (argv[0]); + output_engine_push (); input_file_name = parse_options (argc, argv); if (!strcmp (input_file_name, "-")) @@ -111,7 +115,7 @@ main (int argc, char **argv) table = tables[n_tables - 1]; if (transpose) table = table_transpose (table); - table_item_submit (table_item_create (table, NULL)); + table_item_submit (table_item_create (table, NULL, NULL)); } else draw (input); @@ -119,7 +123,7 @@ main (int argc, char **argv) if (input != stdin) fclose (input); - output_close (); + output_engine_pop (); return 0; } @@ -205,6 +209,18 @@ configure_drivers (int width, int length, int min_break) } #endif + /* Render to .csv. */ + if (render_csv) + { + string_map_clear (&options); + string_map_insert_nocopy (&options, xstrdup ("output-file"), + xasprintf ("%s.csv", output_base)); + driver = output_driver_create (&options); + if (driver == NULL) + exit (EXIT_FAILURE); + output_driver_register (driver); + } + /* Render to .odt. */ string_map_replace_nocopy (&options, xstrdup ("output-file"), xasprintf ("%s.odt", output_base)); @@ -245,6 +261,7 @@ parse_options (int argc, char **argv) {"no-txt", no_argument, &render_txt, 0}, {"no-stdout", no_argument, &render_stdout, 0}, {"pdf", no_argument, &render_pdf, 1}, + {"csv", no_argument, &render_csv, 1}, {"output", required_argument, NULL, 'o'}, {"help", no_argument, NULL, OPT_HELP}, {NULL, 0, NULL, 0}, @@ -457,10 +474,22 @@ read_table (FILE *stream, struct table **tables, size_t n_tables) default: error (1, 0, "unexpected subtable modifier \"%c\"", *text); } - tab_subtable (tab, c, r, c + cs - 1, r + rs - 1, opt, table); + tab_subtable (tab, c, r, c + cs - 1, r + rs - 1, opt, + table_item_create (table, NULL, NULL)); } else - tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt, text); + { + char *pos = text; + char *content; + int i; + + for (i = 0; (content = strsep (&pos, "#")) != NULL; i++) + if (!i) + tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt, + content); + else + tab_footnote (tab, c, r, "%s", content); + } } return &tab->table;