Thanks to Frans Houweling for reporting the issue.
return true;
}
+static char *
+show_TLOOK (const struct dataset *ds UNUSED)
+{
+ const struct pivot_table_look *look = pivot_table_look_get_default ();
+ return xstrdup (look->file_name ? look->file_name : "NONE");
+}
+
static bool
parse_UNDEFINED (struct lexer *lexer)
{
{ "TEMPDIR", NULL, show_TEMPDIR },
{ "TNUMBERS", parse_TNUMBERS, show_TNUMBERS },
{ "TVARS", parse_TVARS, show_TVARS },
- { "TLOOK", parse_TLOOK, NULL },
+ { "TLOOK", parse_TLOOK, show_TLOOK },
{ "UNDEFINED", parse_UNDEFINED, show_UNDEFINED },
{ "VERSION", NULL, show_VERSION },
{ "WEIGHT", NULL, show_WEIGHT },
\f
#define MAX_SAVED_SETTINGS 5
-static struct settings *saved_settings[MAX_SAVED_SETTINGS];
+struct preserved_settings
+ {
+ struct settings *settings;
+ struct pivot_table_look *look;
+ };
+
+static struct preserved_settings saved_settings[MAX_SAVED_SETTINGS];
static int n_saved_settings;
int
{
if (n_saved_settings < MAX_SAVED_SETTINGS)
{
- saved_settings[n_saved_settings++] = settings_get ();
+ struct preserved_settings *ps = &saved_settings[n_saved_settings++];
+ ps->settings = settings_get ();
+ ps->look = pivot_table_look_ref (pivot_table_look_get_default ());
return CMD_SUCCESS;
}
else
{
if (n_saved_settings > 0)
{
- struct settings *s = saved_settings[--n_saved_settings];
- settings_set (s);
- settings_destroy (s);
+ struct preserved_settings *ps = &saved_settings[--n_saved_settings];
+ settings_set (ps->settings);
+ settings_destroy (ps->settings);
+ pivot_table_look_set_default (ps->look);
+ pivot_table_look_unref (ps->look);
return CMD_SUCCESS;
}
else
struct pivot_table_look *new = xmemdup (old, sizeof *old);
new->ref_cnt = 1;
new->name = xstrdup_if_nonempty (old->name);
+ new->file_name = xstrdup_if_nonempty (old->name);
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
table_area_style_copy (NULL, &new->areas[i], &old->areas[i]);
new->continuation = xstrdup_if_nonempty (old->continuation);
if (!--look->ref_cnt)
{
free (look->name);
+ free (look->file_name);
for (size_t i = 0; i < PIVOT_N_AREAS; i++)
table_area_style_uninit (&look->areas[i]);
free (look->continuation);
int ref_cnt;
char *name; /* May be null. */
+ char *file_name; /* May be null. */
/* General properties.
char * WARN_UNUSED_RESULT
spv_table_look_decode (const struct spvsx_table_properties *in,
+ const char *file_name,
struct pivot_table_look **outp)
{
struct pivot_table_look *out = pivot_table_look_new_builtin_default ();
char *error = NULL;
out->name = xstrdup_if_nonnull (in->name);
+ out->file_name = xstrdup_if_nonnull (file_name);
const struct spvsx_general_properties *g = in->general_properties;
out->omit_empty = g->hide_empty_rows != 0;
char *error = spvxml_context_finish (&ctx, &tp->node_);
if (!error)
- error = spv_table_look_decode (tp, outp);
+ error = spv_table_look_decode (tp, filename, outp);
spvsx_free_table_properties (tp);
xmlFreeDoc (doc);
struct spvsx_table_properties;
char *spv_table_look_decode (const struct spvsx_table_properties *,
+ const char *file_name,
struct pivot_table_look **)
WARN_UNUSED_RESULT;
char *spv_table_look_read (const char *, struct pivot_table_look **)
{
struct pivot_table_look *look;
error = (table->table_properties
- ? spv_table_look_decode (table->table_properties, &look)
+ ? spv_table_look_decode (table->table_properties, NULL, &look)
: xstrdup ("Legacy table lacks tableProperties"));
if (!error)
{
FORMAT,F8.2
])
AT_CLEANUP
+
+AT_SETUP([PRESERVE and SHOW of TLOOK])
+cp $srcdir/output/look.stt lines.stt
+sed 's/solid/none/g
+s/thick/none/g' lines.stt > no-lines.stt
+AT_DATA([set.pspp], [dnl
+DATA LIST LIST NOTABLE/x.
+BEGIN DATA.
+1
+2
+3
+END DATA.
+
+SHOW TLOOK.
+SET TLOOK='lines.stt'.
+SHOW TLOOK.
+DESCRIPTIVES/x.
+
+PRESERVE.
+SET TLOOK='no-lines.stt'.
+SHOW TLOOK.
+DESCRIPTIVES/x.
+RESTORE.
+
+SHOW TLOOK.
+DESCRIPTIVES/x.
+])
+AT_CHECK([pspp -O box=unicode set.pspp], [0], [dnl
+ Settings
+╭─────┬────╮
+│TLOOK│NONE│
+╰─────┴────╯
+
+Settings
+╭─────┬─────────╮
+│TLOOK│lines.stt│
+╰─────┴─────────╯
+
+Descriptive Statistics
+╭────────────────────┬─┬────┬───────┬───────┬───────╮
+│ │N│Mean│Std Dev│Minimum│Maximum│
+├────────────────────┼─┼────┼───────┼───────┼───────┤
+│x │3│2.00│ 1.00│ 1.00│ 3.00│
+│Valid N (listwise) │3│ │ │ │ │
+│Missing N (listwise)│0│ │ │ │ │
+╰────────────────────┴─┴────┴───────┴───────┴───────╯
+
+Settings
+TLOOK no-lines.stt
+
+Descriptive Statistics
+ N Mean Std Dev Minimum Maximum
+x 3 2.00 1.00 1.00 3.00
+Valid N (listwise) 3
+Missing N (listwise) 0
+
+Settings
+╭─────┬─────────╮
+│TLOOK│lines.stt│
+╰─────┴─────────╯
+
+Descriptive Statistics
+╭────────────────────┬─┬────┬───────┬───────┬───────╮
+│ │N│Mean│Std Dev│Minimum│Maximum│
+├────────────────────┼─┼────┼───────┼───────┼───────┤
+│x │3│2.00│ 1.00│ 1.00│ 3.00│
+│Valid N (listwise) │3│ │ │ │ │
+│Missing N (listwise)│0│ │ │ │ │
+╰────────────────────┴─┴────┴───────┴───────┴───────╯
+])
+AT_CLEANUP
\ No newline at end of file