X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Foutput%2Frender-test.c;h=460f456e45fa4811aad2c915adfa7e36189a85fd;hb=ad9cdafa0bf554a921cc4db09dd8437b67baa0ca;hp=0376e5b49b08ed60ada321424f241ab54fdaeb7a;hpb=faa1da8f10b1e22c7b1ec37e9cbcb94cbd8b4260;p=pspp diff --git a/tests/output/render-test.c b/tests/output/render-test.c index 0376e5b49b..460f456e45 100644 --- a/tests/output/render-test.c +++ b/tests/output/render-test.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2009, 2010, 2011, 2012, 2013 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 @@ -47,6 +47,9 @@ static char *box; /* --draw-mode: special ASCII driver test mode. */ static int draw_mode; +/* --pdf: Also render PDF output. */ +static int render_pdf; + /* ASCII driver, for ASCII driver test mode. */ static struct output_driver *ascii_driver; @@ -135,18 +138,20 @@ configure_drivers (int width, int length) output_driver_register (driver); #ifdef HAVE_CAIRO - /* Render to render.pdf. */ - string_map_insert (&options, "output-file", "render.pdf"); - string_map_insert (&options, "top-margin", "0"); - string_map_insert (&options, "bottom-margin", "0"); - string_map_insert (&options, "left-margin", "0"); - string_map_insert (&options, "right-margin", "0"); - string_map_insert_nocopy (&options, xstrdup ("paper-size"), - xasprintf ("%dx%dpt", width * 5, length * 8)); - driver = output_driver_create (&options); - if (driver == NULL) - exit (EXIT_FAILURE); - output_driver_register (driver); + if (render_pdf) + { + string_map_insert (&options, "output-file", "render.pdf"); + string_map_insert (&options, "top-margin", "0"); + string_map_insert (&options, "bottom-margin", "0"); + string_map_insert (&options, "left-margin", "0"); + string_map_insert (&options, "right-margin", "0"); + string_map_insert_nocopy (&options, xstrdup ("paper-size"), + xasprintf ("%dx%dpt", width * 5, length * 8)); + driver = output_driver_create (&options); + if (driver == NULL) + exit (EXIT_FAILURE); + output_driver_register (driver); + } #endif string_map_insert (&options, "output-file", "render.odt"); @@ -181,6 +186,7 @@ parse_options (int argc, char **argv) {"emphasis", required_argument, NULL, OPT_EMPHASIS}, {"box", required_argument, NULL, OPT_BOX}, {"draw-mode", no_argument, &draw_mode, 1}, + {"pdf", no_argument, &render_pdf, 1}, {"help", no_argument, NULL, OPT_HELP}, {NULL, 0, NULL, 0}, }; @@ -361,6 +367,7 @@ draw (FILE *stream) while (fgets (buffer, sizeof buffer, stream)) { char text[sizeof buffer]; + int length; int emph; int x, y; @@ -368,9 +375,11 @@ draw (FILE *stream) if (strchr ("#\r\n", buffer[0])) continue; - if (sscanf (buffer, "%d %d %d %[^\n]", &x, &y, &emph, text) != 4) + if (sscanf (buffer, "%d %d %d %[^\n]", &x, &y, &emph, text) == 4) + ascii_test_write (ascii_driver, text, x, y, emph ? TAB_EMPH : 0); + else if (sscanf (buffer, "set-length %d %d", &y, &length) == 2) + ascii_test_set_length (ascii_driver, y, length); + else error (1, 0, "line %d has invalid format", line); - - ascii_test_write (ascii_driver, text, x, y, emph ? TAB_EMPH : 0); } }