From 0ac89e99fc37e87d15170d3bfb5f60f8522d6d9a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 6 May 2023 09:25:45 -0700 Subject: [PATCH] pspp-output: Use page setup from command line by default. pspp-output was ignoring the page setup specified on the command line in favor of the one embedded in an SPV file. This is usually wrong, and in particular it screwed up the examples in the manual by causing them to be broken across multiple PNG output files, only the first of which was actually shown in the manual. --- doc/pspp-output.texi | 7 +++++++ utilities/pspp-output.1 | 6 ++++++ utilities/pspp-output.c | 13 ++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/pspp-output.texi b/doc/pspp-output.texi index b580690dc5..cb56d1ff84 100644 --- a/doc/pspp-output.texi +++ b/doc/pspp-output.texi @@ -121,6 +121,13 @@ the destination is written as best it can, even with errors. Reads a table style from @var{file} and applies it to all of the output tables. The file should be a TableLook @file{.stt} or @file{.tlo} file. + +@item --use-page-setup +By default, the @code{convert} command uses the default page setup +(for example, page size and margins) for @var{destination}, or the one +specified with @option{-O} options, if any. Specify this option to +ignore these sources of page setup in favor of the one embedded in the +SPV, if any. @end table @node The pspp-output get-table-look Command diff --git a/utilities/pspp-output.1 b/utilities/pspp-output.1 index 5fd913789c..4addb530c4 100644 --- a/utilities/pspp-output.1 +++ b/utilities/pspp-output.1 @@ -102,6 +102,12 @@ write the output as best it can, even with errors. Reads a table style from \fIfile\fR and applies it to all of the output tables. The file should a TableLook \fB.stt\fR or \fB.tlo\fR file. +.IP \fB\-\-use\-page\-setup\fR +By default, the \fBconvert\fR command uses the default page setup +(for example, page size and margins) for \fIdestination\fR, or the +one specified with \fB\-O\fR options, if any. Specify this option +to ignore these sources of page setup in favor of the one embedded +in the SPV, if any. .SS The \fBget\-table\-look\fR command When invoked as \fBpspp\-output get\-table\-look \fIsource destination\fR, \fBpspp\-output\fR reads SPV file \fIsource\fR, diff --git a/utilities/pspp-output.c b/utilities/pspp-output.c index 70d5d0bb7c..74e541aadf 100644 --- a/utilities/pspp-output.c +++ b/utilities/pspp-output.c @@ -89,6 +89,9 @@ static bool force; /* --table-look: TableLook to replace table style for conversion. */ static struct pivot_table_look *table_look; +/* --use-page-setup: Use page setup from .spv file rather than command line. */ +static bool use_page_setup; + /* Number of warnings issued. */ static size_t n_warnings; @@ -239,7 +242,8 @@ run_convert (int argc UNUSED, char **argv) if (ps) { - output_set_page_setup (ps); + if (use_page_setup) + output_set_page_setup (ps); page_setup_destroy (ps); } output_item_submit_children (root); @@ -1012,6 +1016,7 @@ parse_options (int argc, char *argv[]) OPT_NO_ASCII_ONLY, OPT_UTF8_ONLY, OPT_TABLE_LOOK, + OPT_USE_PAGE_SETUP, OPT_HELP_DEVELOPER, }; static const struct option long_options[] = @@ -1034,6 +1039,7 @@ parse_options (int argc, char *argv[]) /* "convert" command options. */ { "force", no_argument, NULL, 'f' }, { "table-look", required_argument, NULL, OPT_TABLE_LOOK }, + { "use-page-setup", no_argument, NULL, OPT_USE_PAGE_SETUP }, /* "dump-light-table" command options. */ { "sort", no_argument, NULL, OPT_SORT }, @@ -1118,6 +1124,10 @@ parse_options (int argc, char *argv[]) parse_table_look (optarg); break; + case OPT_USE_PAGE_SETUP: + use_page_setup = true; + break; + case OPT_NO_ASCII_ONLY: exclude_ascii_only = true; break; @@ -1194,6 +1204,7 @@ The following options override \"convert\" behavior:\n\ -O OPTION=VALUE set output option\n\ -f, --force keep output file even given errors\n\ --table-look=FILE override tables' style with TableLook from FILE\n\ + --use-page-setup use page setup from SOURCE\n\ Other options:\n\ --help display this help and exit\n\ --help-developer display help for developer commands and exit\n\ -- 2.30.2