1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 #include "gl/vasnprintf.h"
28 #include "data/casereader.h"
29 #include "data/data-in.h"
30 #include "data/data-out.h"
31 #include "data/dataset.h"
32 #include "data/dictionary.h"
33 #include "data/format.h"
34 #include "data/settings.h"
35 #include "data/value.h"
36 #include "data/variable.h"
37 #include "language/command.h"
38 #include "language/lexer/format-parser.h"
39 #include "language/lexer/lexer.h"
40 #include "libpspp/compiler.h"
41 #include "libpspp/copyleft.h"
42 #include "libpspp/temp-file.h"
43 #include "libpspp/version.h"
44 #include "libpspp/float-format.h"
45 #include "libpspp/i18n.h"
46 #include "libpspp/integer-format.h"
47 #include "libpspp/message.h"
48 #include "math/random.h"
49 #include "output/driver.h"
50 #include "output/journal.h"
55 #else /* !HAVE_TERMCAP_H */
56 int tgetent (char *, const char *);
57 int tgetnum (const char *);
58 #endif /* !HAVE_TERMCAP_H */
59 #endif /* !HAVE_LIBTERMCAP */
64 #define _(msgid) gettext (msgid)
71 case=size:upper/uplow;
77 compression=compress:on/off;
79 decimal=dec:dot/comma;
83 headers=headers:no/yes/blank;
91 lowres=lores:auto/on/off;
93 menus=menus:standard/extended;
105 rib=rib:msbfirst/lsbfirst/vax/native;
106 rrb=rrb:native/isl/isb/idl/idb/vf/vd/vg/zs/zl;
108 scompression=scompress:on/off;
115 undefined=undef:warn/nowarn;
116 wib=wib:msbfirst/lsbfirst/vax/native;
117 wrb=wrb:native/isl/isb/idl/idb/vf/vd/vg/zs/zl;
129 static enum integer_format stc_to_integer_format (int stc);
130 static enum float_format stc_to_float_format (int stc);
133 cmd_set (struct lexer *lexer, struct dataset *ds)
137 if (!parse_set (lexer, ds, &cmd, NULL))
144 settings_set_cc ( cmd.s_cca, FMT_CCA);
146 settings_set_cc ( cmd.s_ccb, FMT_CCB);
148 settings_set_cc ( cmd.s_ccc, FMT_CCC);
150 settings_set_cc ( cmd.s_ccd, FMT_CCD);
152 settings_set_cc ( cmd.s_cce, FMT_CCE);
155 settings_set_decimal_char (cmd.dec == STC_DOT ? '.' : ',');
158 settings_set_include (cmd.inc == STC_ON);
161 if (cmd.n_mxerrs[0] >= 1)
162 settings_set_max_messages (MSG_S_ERROR, cmd.n_mxerrs[0]);
164 msg (SE, _("%s must be at least 1."), "MXERRS");
168 if (cmd.n_mxloops[0] >= 1)
169 settings_set_mxloops (cmd.n_mxloops[0]);
171 msg (SE, _("%s must be at least 1."), "MXLOOPS");
175 if (cmd.n_mxwarns[0] >= 0)
176 settings_set_max_messages (MSG_S_WARNING, cmd.n_mxwarns[0]);
178 msg (SE, _("%s must not be negative."), "MXWARNS");
181 settings_set_input_integer_format (stc_to_integer_format (cmd.rib));
183 settings_set_input_float_format (stc_to_float_format (cmd.rrb));
185 settings_set_safer_mode ();
186 if (cmd.sbc_scompression)
187 settings_set_scompression (cmd.scompress == STC_ON);
188 if (cmd.sbc_undefined)
189 settings_set_undefined (cmd.undef == STC_WARN);
191 settings_set_output_integer_format (stc_to_integer_format (cmd.wib));
193 settings_set_output_float_format (stc_to_float_format (cmd.wrb));
194 if (cmd.sbc_workspace)
196 if ( cmd.n_workspace[0] < 1024 && ! settings_get_testing_mode ())
197 msg (SE, _("%s must be at least 1MB"), "WORKSPACE");
198 else if (cmd.n_workspace[0] <= 0)
199 msg (SE, _("%s must be positive"), "WORKSPACE");
201 settings_set_workspace (cmd.n_workspace[0] * 1024L);
205 msg (SW, _("%s is obsolete."), "BLOCK");
206 if (cmd.sbc_boxstring)
207 msg (SW, _("%s is obsolete."), "BOXSTRING");
209 msg (SW, _("%s is obsolete."), "CPI");
210 if (cmd.sbc_histogram)
211 msg (SW, _("%s is obsolete."), "HISTOGRAM");
213 msg (SW, _("%s is obsolete."), "LPI");
215 msg (SW, _("%s is obsolete."), "MENUS");
217 msg (SW, _("%s is obsolete."), "XSORT");
218 if (cmd.sbc_mxmemory)
219 msg (SE, _("%s is obsolete."), "MXMEMORY");
220 if (cmd.sbc_scripttab)
221 msg (SE, _("%s is obsolete."), "SCRIPTTAB");
223 msg (SW, _("%s is obsolete."), "TBFONTS");
224 if (cmd.sbc_tb1 && cmd.s_tb1)
225 msg (SW, _("%s is obsolete."), "TB1");
228 msg (SW, _("%s is not yet implemented."), "CASE");
230 if (cmd.sbc_compression)
231 msg (SW, _("Active file compression is not implemented."));
238 /* Returns the integer_format value corresponding to STC,
239 which should be the value of cmd.rib or cmd.wib. */
240 static enum integer_format
241 stc_to_integer_format (int stc)
243 return (stc == STC_MSBFIRST ? INTEGER_MSB_FIRST
244 : stc == STC_LSBFIRST ? INTEGER_LSB_FIRST
245 : stc == STC_VAX ? INTEGER_VAX
249 /* Returns the float_format value corresponding to STC,
250 which should be the value of cmd.rrb or cmd.wrb. */
251 static enum float_format
252 stc_to_float_format (int stc)
257 return FLOAT_NATIVE_DOUBLE;
260 return FLOAT_IEEE_SINGLE_LE;
262 return FLOAT_IEEE_SINGLE_BE;
264 return FLOAT_IEEE_DOUBLE_LE;
266 return FLOAT_IEEE_DOUBLE_BE;
276 return FLOAT_Z_SHORT;
285 set_output_routing (struct lexer *lexer, enum settings_output_type type)
287 enum settings_output_devices devices;
289 lex_match (lexer, T_EQUALS);
290 if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "BOTH"))
291 devices = SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL;
292 else if (lex_match_id (lexer, "TERMINAL"))
293 devices = SETTINGS_DEVICE_TERMINAL;
294 else if (lex_match_id (lexer, "LISTING"))
295 devices = SETTINGS_DEVICE_LISTING;
296 else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NONE"))
300 lex_error (lexer, NULL);
304 settings_set_output_routing (type, devices);
309 /* Parses the BLANKS subcommand, which controls the value that
310 completely blank fields in numeric data imply. X, Wnd: Syntax is
311 SYSMIS or a numeric value. */
313 stc_custom_blanks (struct lexer *lexer,
314 struct dataset *ds UNUSED,
315 struct cmd_set *cmd UNUSED, void *aux UNUSED)
317 lex_match (lexer, T_EQUALS);
318 if (lex_match_id (lexer, "SYSMIS"))
321 settings_set_blanks (SYSMIS);
325 if (!lex_force_num (lexer))
327 settings_set_blanks (lex_number (lexer));
334 stc_custom_tnumbers (struct lexer *lexer,
335 struct dataset *ds UNUSED,
336 struct cmd_set *cmd UNUSED, void *aux UNUSED)
338 lex_match (lexer, T_EQUALS);
340 if (lex_match_id (lexer, "VALUES"))
342 settings_set_value_style (SETTINGS_VAL_STYLE_VALUES);
344 else if (lex_match_id (lexer, "LABELS"))
346 settings_set_value_style (SETTINGS_VAL_STYLE_LABELS);
348 else if (lex_match_id (lexer, "BOTH"))
350 settings_set_value_style (SETTINGS_VAL_STYLE_BOTH);
354 lex_error_expecting (lexer, "VALUES", "LABELS", "BOTH", NULL_SENTINEL);
363 stc_custom_tvars (struct lexer *lexer,
364 struct dataset *ds UNUSED,
365 struct cmd_set *cmd UNUSED, void *aux UNUSED)
367 lex_match (lexer, T_EQUALS);
369 if (lex_match_id (lexer, "NAMES"))
371 settings_set_var_style (SETTINGS_VAR_STYLE_NAMES);
373 else if (lex_match_id (lexer, "LABELS"))
375 settings_set_var_style (SETTINGS_VAR_STYLE_LABELS);
377 else if (lex_match_id (lexer, "BOTH"))
379 settings_set_var_style (SETTINGS_VAR_STYLE_BOTH);
383 lex_error_expecting (lexer, "NAMES", "LABELS", "BOTH", NULL_SENTINEL);
391 /* Parses the EPOCH subcommand, which controls the epoch used for
392 parsing 2-digit years. */
394 stc_custom_epoch (struct lexer *lexer,
395 struct dataset *ds UNUSED,
396 struct cmd_set *cmd UNUSED, void *aux UNUSED)
398 lex_match (lexer, T_EQUALS);
399 if (lex_match_id (lexer, "AUTOMATIC"))
400 settings_set_epoch (-1);
401 else if (lex_is_integer (lexer))
403 int new_epoch = lex_integer (lexer);
405 if (new_epoch < 1500)
407 msg (SE, _("%s must be 1500 or later."), "EPOCH");
410 settings_set_epoch (new_epoch);
414 lex_error (lexer, _("expecting %s or year"), "AUTOMATIC");
422 stc_custom_errors (struct lexer *lexer, struct dataset *ds UNUSED,
423 struct cmd_set *cmd UNUSED, void *aux UNUSED)
425 return set_output_routing (lexer, SETTINGS_OUTPUT_ERROR);
429 stc_custom_length (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
433 lex_match (lexer, T_EQUALS);
434 if (lex_match_id (lexer, "NONE"))
438 if (!lex_force_int (lexer))
440 if (lex_integer (lexer) < 1)
442 msg (SE, _("%s must be at least %d."), "LENGTH", 1);
445 page_length = lex_integer (lexer);
449 if (page_length != -1)
450 settings_set_viewlength (page_length);
456 stc_custom_locale (struct lexer *lexer, struct dataset *ds UNUSED,
457 struct cmd_set *cmd UNUSED, void *aux UNUSED)
461 lex_match (lexer, T_EQUALS);
463 if ( !lex_force_string (lexer))
466 s = lex_tokcstr (lexer);
468 /* First try this string as an encoding name */
469 if ( valid_encoding (s))
470 set_default_encoding (s);
472 /* Now try as a locale name (or alias) */
473 else if (set_encoding_from_locale (s))
478 msg (ME, _("%s is not a recognized encoding or locale name"), s);
488 stc_custom_messages (struct lexer *lexer, struct dataset *ds UNUSED,
489 struct cmd_set *cmd UNUSED, void *aux UNUSED)
491 return set_output_routing (lexer, SETTINGS_OUTPUT_NOTE);
495 stc_custom_printback (struct lexer *lexer, struct dataset *ds UNUSED,
496 struct cmd_set *cmd UNUSED, void *aux UNUSED)
498 return set_output_routing (lexer, SETTINGS_OUTPUT_SYNTAX);
502 stc_custom_results (struct lexer *lexer, struct dataset *ds UNUSED,
503 struct cmd_set *cmd UNUSED, void *aux UNUSED)
505 return set_output_routing (lexer, SETTINGS_OUTPUT_RESULT);
509 stc_custom_seed (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
511 lex_match (lexer, T_EQUALS);
512 if (lex_match_id (lexer, "RANDOM"))
516 if (!lex_force_num (lexer))
518 set_rng (lex_number (lexer));
526 stc_custom_width (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
528 lex_match (lexer, T_EQUALS);
529 if (lex_match_id (lexer, "NARROW"))
530 settings_set_viewwidth (79);
531 else if (lex_match_id (lexer, "WIDE"))
532 settings_set_viewwidth (131);
535 if (!lex_force_int (lexer))
537 if (lex_integer (lexer) < 40)
539 msg (SE, _("%s must be at least %d."), "WIDTH", 40);
542 settings_set_viewwidth (lex_integer (lexer));
549 /* Parses FORMAT subcommand, which consists of a numeric format
552 stc_custom_format (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
556 lex_match (lexer, T_EQUALS);
557 if (!parse_format_specifier (lexer, &fmt))
560 if (!fmt_check_output (&fmt))
563 if (fmt_is_string (fmt.type))
565 char str[FMT_STRING_LEN_MAX + 1];
566 msg (SE, _("%s requires numeric output format as an argument. "
567 "Specified format %s is of type string."),
569 fmt_to_string (&fmt, str));
573 settings_set_format (&fmt);
578 stc_custom_journal (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
580 lex_match (lexer, T_EQUALS);
581 if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "YES"))
583 else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO"))
585 else if (lex_is_string (lexer) || lex_token (lexer) == T_ID)
587 char *filename = utf8_to_filename (lex_tokcstr (lexer));
588 journal_set_file_name (filename);
595 lex_error (lexer, NULL);
602 stc_custom_log (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
604 return stc_custom_journal (lexer, ds, cmd, aux);
608 show_output_routing (enum settings_output_type type)
610 enum settings_output_devices devices;
613 devices = settings_get_output_routing (type);
614 if (devices & SETTINGS_DEVICE_LISTING)
615 s = devices & SETTINGS_DEVICE_TERMINAL ? "BOTH" : "LISTING";
616 else if (devices & SETTINGS_DEVICE_TERMINAL)
625 show_blanks (const struct dataset *ds UNUSED)
627 return (settings_get_blanks () == SYSMIS
629 : xasprintf ("%.*g", DBL_DIG + 1, settings_get_blanks ()));
633 format_cc (struct string *out, const char *in, char grouping)
638 if (c == grouping || c == '\'')
639 ds_put_byte (out, '\'');
641 ds_put_byte (out, '"');
642 ds_put_byte (out, c);
647 show_cc (enum fmt_type type)
649 const struct fmt_number_style *cc = settings_get_style (type);
652 ds_init_empty (&out);
653 format_cc (&out, cc->neg_prefix.s, cc->grouping);
654 ds_put_byte (&out, cc->grouping);
655 format_cc (&out, cc->prefix.s, cc->grouping);
656 ds_put_byte (&out, cc->grouping);
657 format_cc (&out, cc->suffix.s, cc->grouping);
658 ds_put_byte (&out, cc->grouping);
659 format_cc (&out, cc->neg_suffix.s, cc->grouping);
661 return ds_cstr (&out);
665 show_cca (const struct dataset *ds UNUSED)
667 return show_cc (FMT_CCA);
671 show_ccb (const struct dataset *ds UNUSED)
673 return show_cc (FMT_CCB);
677 show_ccc (const struct dataset *ds UNUSED)
679 return show_cc (FMT_CCC);
683 show_ccd (const struct dataset *ds UNUSED)
685 return show_cc (FMT_CCD);
689 show_cce (const struct dataset *ds UNUSED)
691 return show_cc (FMT_CCE);
695 show_decimals (const struct dataset *ds UNUSED)
697 return xasprintf ("`%c'", settings_get_decimal_char (FMT_F));
701 show_errors (const struct dataset *ds UNUSED)
703 return show_output_routing (SETTINGS_OUTPUT_ERROR);
707 show_format (const struct dataset *ds UNUSED)
709 char str[FMT_STRING_LEN_MAX + 1];
710 return xstrdup (fmt_to_string (settings_get_format (), str));
714 show_journal (const struct dataset *ds UNUSED)
716 return (journal_is_enabled ()
717 ? xasprintf ("\"%s\"", journal_get_file_name ())
718 : xstrdup ("disabled"));
722 show_length (const struct dataset *ds UNUSED)
724 return xasprintf ("%d", settings_get_viewlength ());
728 show_locale (const struct dataset *ds UNUSED)
730 return xstrdup (get_default_encoding ());
734 show_messages (const struct dataset *ds UNUSED)
736 return show_output_routing (SETTINGS_OUTPUT_NOTE);
740 show_printback (const struct dataset *ds UNUSED)
742 return show_output_routing (SETTINGS_OUTPUT_SYNTAX);
746 show_results (const struct dataset *ds UNUSED)
748 return show_output_routing (SETTINGS_OUTPUT_RESULT);
752 show_mxerrs (const struct dataset *ds UNUSED)
754 return xasprintf ("%d", settings_get_max_messages (MSG_S_ERROR));
758 show_mxloops (const struct dataset *ds UNUSED)
760 return xasprintf ("%d", settings_get_mxloops ());
764 show_mxwarns (const struct dataset *ds UNUSED)
766 return xasprintf ("%d", settings_get_max_messages (MSG_S_WARNING));
769 /* Returns a name for the given INTEGER_FORMAT value. */
771 show_integer_format (enum integer_format integer_format)
773 return xasprintf ("%s (%s)",
774 (integer_format == INTEGER_MSB_FIRST ? "MSBFIRST"
775 : integer_format == INTEGER_LSB_FIRST ? "LSBFIRST"
777 integer_format == INTEGER_NATIVE ? "NATIVE" : "nonnative");
780 /* Returns a name for the given FLOAT_FORMAT value. */
782 show_float_format (enum float_format float_format)
784 const char *format_name = "";
786 switch (float_format)
788 case FLOAT_IEEE_SINGLE_LE:
789 format_name = _("ISL (32-bit IEEE 754 single, little-endian)");
791 case FLOAT_IEEE_SINGLE_BE:
792 format_name = _("ISB (32-bit IEEE 754 single, big-endian)");
794 case FLOAT_IEEE_DOUBLE_LE:
795 format_name = _("IDL (64-bit IEEE 754 double, little-endian)");
797 case FLOAT_IEEE_DOUBLE_BE:
798 format_name = _("IDB (64-bit IEEE 754 double, big-endian)");
802 format_name = _("VF (32-bit VAX F, VAX-endian)");
805 format_name = _("VD (64-bit VAX D, VAX-endian)");
808 format_name = _("VG (64-bit VAX G, VAX-endian)");
812 format_name = _("ZS (32-bit IBM Z hexadecimal short, big-endian)");
815 format_name = _("ZL (64-bit IBM Z hexadecimal long, big-endian)");
823 return xasprintf ("%s (%s)", format_name,
824 (float_format == FLOAT_NATIVE_DOUBLE
825 ? "NATIVE" : "nonnative"));
829 show_rib (const struct dataset *ds UNUSED)
831 return show_integer_format (settings_get_input_integer_format ());
835 show_rrb (const struct dataset *ds UNUSED)
837 return show_float_format (settings_get_input_float_format ());
841 show_scompression (const struct dataset *ds UNUSED)
843 return xstrdup (settings_get_scompression () ? "ON" : "OFF");
847 show_undefined (const struct dataset *ds UNUSED)
849 return xstrdup (settings_get_undefined () ? "WARN" : "NOWARN");
853 show_weight (const struct dataset *ds)
855 const struct variable *var = dict_get_weight (dataset_dict (ds));
856 return xstrdup (var != NULL ? var_get_name (var) : "OFF");
860 show_wib (const struct dataset *ds UNUSED)
862 return show_integer_format (settings_get_output_integer_format ());
866 show_wrb (const struct dataset *ds UNUSED)
868 return show_float_format (settings_get_output_float_format ());
872 show_width (const struct dataset *ds UNUSED)
874 return xasprintf ("%d", settings_get_viewwidth ());
878 show_workspace (const struct dataset *ds UNUSED)
880 size_t ws = settings_get_workspace () / 1024L;
881 return xasprintf ("%zu", ws);
885 show_current_directory (const struct dataset *ds UNUSED)
894 buf = xrealloc (buf, len);
896 while (NULL == (wd = getcwd (buf, len)));
902 show_tempdir (const struct dataset *ds UNUSED)
904 return strdup (temp_dir_name ());
908 show_version (const struct dataset *ds UNUSED)
910 return strdup (version);
914 show_system (const struct dataset *ds UNUSED)
916 return strdup (host_system);
920 show_n (const struct dataset *ds)
925 const struct casereader *reader = dataset_source (ds);
928 return strdup (_("Unknown"));
930 n = casereader_count_cases (reader);
932 return asnprintf (NULL, &l, "%ld", n);
939 char *(*function) (const struct dataset *);
942 const struct show_sbc show_table[] =
944 {"BLANKS", show_blanks},
950 {"DECIMALS", show_decimals},
951 {"DIRECTORY", show_current_directory},
952 {"ENVIRONMENT", show_system},
953 {"ERRORS", show_errors},
954 {"FORMAT", show_format},
955 {"JOURNAL", show_journal},
956 {"LENGTH", show_length},
957 {"LOCALE", show_locale},
958 {"MESSAGES", show_messages},
959 {"MXERRS", show_mxerrs},
960 {"MXLOOPS", show_mxloops},
961 {"MXWARNS", show_mxwarns},
963 {"PRINTBACk", show_printback},
964 {"RESULTS", show_results},
967 {"SCOMPRESSION", show_scompression},
968 {"TEMPDIR", show_tempdir},
969 {"UNDEFINED", show_undefined},
970 {"VERSION", show_version},
971 {"WEIGHT", show_weight},
974 {"WIDTH", show_width},
975 {"WORKSPACE", show_workspace},
979 do_show (const struct dataset *ds, const struct show_sbc *sbc)
981 char *value = sbc->function (ds);
982 msg (SN, _("%s is %s."), sbc->name, value);
987 show_all (const struct dataset *ds)
991 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
992 do_show (ds, &show_table[i]);
996 show_all_cc (const struct dataset *ds)
1000 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
1002 const struct show_sbc *sbc = &show_table[i];
1003 if (!strncmp (sbc->name, "CC", 2))
1009 show_warranty (const struct dataset *ds UNUSED)
1011 fputs (lack_of_warranty, stdout);
1015 show_copying (const struct dataset *ds UNUSED)
1017 fputs (copyleft, stdout);
1022 cmd_show (struct lexer *lexer, struct dataset *ds)
1024 if (lex_token (lexer) == T_ENDCMD)
1032 if (lex_match (lexer, T_ALL))
1034 else if (lex_match_id (lexer, "CC"))
1036 else if (lex_match_id (lexer, "WARRANTY"))
1038 else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE"))
1040 else if (lex_token (lexer) == T_ID)
1044 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
1046 const struct show_sbc *sbc = &show_table[i];
1047 if (lex_match_id (lexer, sbc->name))
1053 lex_error (lexer, NULL);
1060 lex_error (lexer, NULL);
1064 lex_match (lexer, T_SLASH);
1066 while (lex_token (lexer) != T_ENDCMD);
1071 #define MAX_SAVED_SETTINGS 5
1073 static struct settings *saved_settings[MAX_SAVED_SETTINGS];
1074 static int n_saved_settings;
1077 cmd_preserve (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
1079 if (n_saved_settings < MAX_SAVED_SETTINGS)
1081 saved_settings[n_saved_settings++] = settings_get ();
1086 msg (SE, _("Too many %s commands without a %s: at most "
1087 "%d levels of saved settings are allowed."),
1088 "PRESERVE", "RESTORE",
1089 MAX_SAVED_SETTINGS);
1090 return CMD_CASCADING_FAILURE;
1095 cmd_restore (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
1097 if (n_saved_settings > 0)
1099 struct settings *s = saved_settings[--n_saved_settings];
1101 settings_destroy (s);
1106 msg (SE, _("%s without matching %s."), "RESTORE", "PRESERVE");