From d18d7a08733079d840b50cd52500703dd9dff4be Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 31 Dec 2020 20:46:56 -0800 Subject: [PATCH] pspp-output: New feature for retrieving the default look. --- doc/pspp-output.texi | 3 +++ utilities/pspp-output.1 | 3 +++ utilities/pspp-output.c | 28 +++++++++++++++++++--------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/doc/pspp-output.texi b/doc/pspp-output.texi index f8b7931d73..b580690dc5 100644 --- a/doc/pspp-output.texi +++ b/doc/pspp-output.texi @@ -136,6 +136,9 @@ selected object, extracts the TableLook from that table, and writes it to @var{destination} (typically with an @file{.stt} extension) in the TableLook XML format. +Use @samp{-} for @var{source} to instead write the default look to +@var{destination}. + The user may use the TableLook file to change the style of tables in other files, by passing it to the @option{--table-look} option on the @code{convert} command. diff --git a/utilities/pspp-output.1 b/utilities/pspp-output.1 index 55f47b574a..5fd913789c 100644 --- a/utilities/pspp-output.1 +++ b/utilities/pspp-output.1 @@ -111,6 +111,9 @@ extracts the TableLook from that table, and writes it to \fIdestination\fR (typically with an \fB.stt\fR extension) in the TableLook XML format. .PP +Use \fB\-\fR for \fIsource\fR to instead write the default look to +\fIdestination\fR. +.PP The user may use the TableLook file to change the style of tables in other files, by passing it to the \fB\-\-table\-look\fR option on the \fBconvert\fR command. diff --git a/utilities/pspp-output.c b/utilities/pspp-output.c index f9f149bd63..59c915dd44 100644 --- a/utilities/pspp-output.c +++ b/utilities/pspp-output.c @@ -346,20 +346,30 @@ get_first_table (const struct spv_reader *spv) static void run_get_table_look (int argc UNUSED, char **argv) { - struct spv_reader *spv; - char *err = spv_open (argv[1], &spv); - if (err) - error (1, 0, "%s", err); + struct pivot_table_look *look; + if (strcmp (argv[1], "-")) + { + struct spv_reader *spv; + char *err = spv_open (argv[1], &spv); + if (err) + error (1, 0, "%s", err); - const struct pivot_table *table = get_first_table (spv); - if (!table) - error (1, 0, "%s: no tables found", argv[1]); + const struct pivot_table *table = get_first_table (spv); + if (!table) + error (1, 0, "%s: no tables found", argv[1]); - err = spv_table_look_write (argv[2], pivot_table_get_look (table)); + look = pivot_table_look_ref (pivot_table_get_look (table)); + + spv_close (spv); + } + else + look = pivot_table_look_ref (pivot_table_look_builtin_default ()); + + char *err = spv_table_look_write (argv[2], look); if (err) error (1, 0, "%s", err); - spv_close (spv); + pivot_table_look_unref (look); } static void -- 2.30.2