1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2013, 2014, 2015 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"
51 #include "output/pivot-table.h"
56 #else /* !HAVE_TERMCAP_H */
57 int tgetent (char *, const char *);
58 int tgetnum (const char *);
59 #endif /* !HAVE_TERMCAP_H */
60 #endif /* !HAVE_LIBTERMCAP */
65 #define _(msgid) gettext (msgid)
72 case=size:upper/uplow;
78 compression=compress:on/off;
80 decimal=dec:dot/comma;
85 headers=headers:no/yes/blank;
93 lowres=lores:auto/on/off;
95 menus=menus:standard/extended;
100 mprint=mprint:on/off;
107 rib=rib:msbfirst/lsbfirst/vax/native;
108 rrb=rrb:native/isl/isb/idl/idb/vf/vd/vg/zs/zl;
110 scompression=scompress:on/off;
119 undefined=undef:warn/nowarn;
120 wib=wib:msbfirst/lsbfirst/vax/native;
121 wrb=wrb:native/isl/isb/idl/idb/vf/vd/vg/zs/zl;
133 static enum integer_format stc_to_integer_format (int stc);
134 static enum float_format stc_to_float_format (int stc);
137 cmd_set (struct lexer *lexer, struct dataset *ds)
141 if (!parse_set (lexer, ds, &cmd, NULL))
147 settings_set_cc ( cmd.s_cca, FMT_CCA);
149 settings_set_cc ( cmd.s_ccb, FMT_CCB);
151 settings_set_cc ( cmd.s_ccc, FMT_CCC);
153 settings_set_cc ( cmd.s_ccd, FMT_CCD);
155 settings_set_cc ( cmd.s_cce, FMT_CCE);
158 settings_set_decimal_char (cmd.dec == STC_DOT ? '.' : ',');
159 if (cmd.sbc_fuzzbits)
161 int fuzzbits = cmd.n_fuzzbits[0];
162 if (fuzzbits >= 0 && fuzzbits <= 20)
163 settings_set_fuzzbits (fuzzbits);
165 msg (SE, _("%s must be between 0 and 20."), "FUZZBITS");
169 settings_set_include (cmd.inc == STC_ON);
172 if (cmd.n_mxerrs[0] >= 1)
173 settings_set_max_messages (MSG_S_ERROR, cmd.n_mxerrs[0]);
175 msg (SE, _("%s must be at least 1."), "MXERRS");
179 if (cmd.n_mxloops[0] >= 1)
180 settings_set_mxloops (cmd.n_mxloops[0]);
182 msg (SE, _("%s must be at least 1."), "MXLOOPS");
186 if (cmd.n_mxwarns[0] >= 0)
187 settings_set_max_messages (MSG_S_WARNING, cmd.n_mxwarns[0]);
189 msg (SE, _("%s must not be negative."), "MXWARNS");
192 settings_set_input_integer_format (stc_to_integer_format (cmd.rib));
194 settings_set_input_float_format (stc_to_float_format (cmd.rrb));
196 settings_set_safer_mode ();
197 if (cmd.sbc_scompression)
198 settings_set_scompression (cmd.scompress == STC_ON);
200 settings_set_small (cmd.n_small[0]);
201 if (cmd.sbc_undefined)
202 settings_set_undefined (cmd.undef == STC_WARN);
204 settings_set_output_integer_format (stc_to_integer_format (cmd.wib));
206 settings_set_output_float_format (stc_to_float_format (cmd.wrb));
207 if (cmd.sbc_workspace)
209 if ( cmd.n_workspace[0] < 1024 && ! settings_get_testing_mode ())
210 msg (SE, _("%s must be at least 1MB"), "WORKSPACE");
211 else if (cmd.n_workspace[0] <= 0)
212 msg (SE, _("%s must be positive"), "WORKSPACE");
214 settings_set_workspace (cmd.n_workspace[0] * 1024L);
218 msg (SW, _("%s is obsolete."), "BLOCK");
219 if (cmd.sbc_boxstring)
220 msg (SW, _("%s is obsolete."), "BOXSTRING");
222 msg (SW, _("%s is obsolete."), "CPI");
223 if (cmd.sbc_histogram)
224 msg (SW, _("%s is obsolete."), "HISTOGRAM");
226 msg (SW, _("%s is obsolete."), "LPI");
228 msg (SW, _("%s is obsolete."), "MENUS");
230 msg (SW, _("%s is obsolete."), "XSORT");
231 if (cmd.sbc_mxmemory)
232 msg (SE, _("%s is obsolete."), "MXMEMORY");
233 if (cmd.sbc_scripttab)
234 msg (SE, _("%s is obsolete."), "SCRIPTTAB");
236 msg (SW, _("%s is obsolete."), "TBFONTS");
237 if (cmd.sbc_tb1 && cmd.s_tb1)
238 msg (SW, _("%s is obsolete."), "TB1");
241 msg (SW, _("%s is not yet implemented."), "CASE");
243 if (cmd.sbc_compression)
244 msg (SW, _("Active file compression is not implemented."));
251 /* Returns the integer_format value corresponding to STC,
252 which should be the value of cmd.rib or cmd.wib. */
253 static enum integer_format
254 stc_to_integer_format (int stc)
256 return (stc == STC_MSBFIRST ? INTEGER_MSB_FIRST
257 : stc == STC_LSBFIRST ? INTEGER_LSB_FIRST
258 : stc == STC_VAX ? INTEGER_VAX
262 /* Returns the float_format value corresponding to STC,
263 which should be the value of cmd.rrb or cmd.wrb. */
264 static enum float_format
265 stc_to_float_format (int stc)
270 return FLOAT_NATIVE_DOUBLE;
273 return FLOAT_IEEE_SINGLE_LE;
275 return FLOAT_IEEE_SINGLE_BE;
277 return FLOAT_IEEE_DOUBLE_LE;
279 return FLOAT_IEEE_DOUBLE_BE;
289 return FLOAT_Z_SHORT;
298 set_output_routing (struct lexer *lexer, enum settings_output_type type)
300 enum settings_output_devices devices;
302 lex_match (lexer, T_EQUALS);
303 if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "BOTH"))
304 devices = SETTINGS_DEVICE_LISTING | SETTINGS_DEVICE_TERMINAL;
305 else if (lex_match_id (lexer, "TERMINAL"))
306 devices = SETTINGS_DEVICE_TERMINAL;
307 else if (lex_match_id (lexer, "LISTING"))
308 devices = SETTINGS_DEVICE_LISTING;
309 else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NONE"))
313 lex_error (lexer, NULL);
317 settings_set_output_routing (type, devices);
322 /* Parses the BLANKS subcommand, which controls the value that
323 completely blank fields in numeric data imply. X, Wnd: Syntax is
324 SYSMIS or a numeric value. */
326 stc_custom_blanks (struct lexer *lexer,
327 struct dataset *ds UNUSED,
328 struct cmd_set *cmd UNUSED, void *aux UNUSED)
330 lex_match (lexer, T_EQUALS);
331 if (lex_match_id (lexer, "SYSMIS"))
334 settings_set_blanks (SYSMIS);
338 if (!lex_force_num (lexer))
340 settings_set_blanks (lex_number (lexer));
347 stc_custom_tnumbers (struct lexer *lexer,
348 struct dataset *ds UNUSED,
349 struct cmd_set *cmd UNUSED, void *aux UNUSED)
351 lex_match (lexer, T_EQUALS);
353 if (lex_match_id (lexer, "VALUES"))
354 settings_set_show_values (SETTINGS_VALUE_SHOW_VALUE);
355 else if (lex_match_id (lexer, "LABELS"))
356 settings_set_show_values (SETTINGS_VALUE_SHOW_LABEL);
357 else if (lex_match_id (lexer, "BOTH"))
358 settings_set_show_values (SETTINGS_VALUE_SHOW_BOTH);
361 lex_error_expecting (lexer, "VALUES", "LABELS", "BOTH");
370 stc_custom_tvars (struct lexer *lexer,
371 struct dataset *ds UNUSED,
372 struct cmd_set *cmd UNUSED, void *aux UNUSED)
374 lex_match (lexer, T_EQUALS);
376 if (lex_match_id (lexer, "NAMES"))
377 settings_set_show_variables (SETTINGS_VALUE_SHOW_VALUE);
378 else if (lex_match_id (lexer, "LABELS"))
379 settings_set_show_variables (SETTINGS_VALUE_SHOW_LABEL);
380 else if (lex_match_id (lexer, "BOTH"))
381 settings_set_show_variables (SETTINGS_VALUE_SHOW_BOTH);
384 lex_error_expecting (lexer, "NAMES", "LABELS", "BOTH");
392 stc_custom_tlook (struct lexer *lexer,
393 struct dataset *ds UNUSED,
394 struct cmd_set *cmd UNUSED, void *aux UNUSED)
396 lex_match (lexer, T_EQUALS);
398 if (lex_match_id (lexer, "NONE"))
399 pivot_table_look_set_default (pivot_table_look_builtin_default ());
400 else if (lex_is_string (lexer))
402 struct pivot_table_look *look;
403 char *error = pivot_table_look_read (lex_tokcstr (lexer), &look);
408 msg (SE, "%s", error);
413 pivot_table_look_set_default (look);
414 pivot_table_look_unref (look);
420 /* Parses the EPOCH subcommand, which controls the epoch used for
421 parsing 2-digit years. */
423 stc_custom_epoch (struct lexer *lexer,
424 struct dataset *ds UNUSED,
425 struct cmd_set *cmd UNUSED, void *aux UNUSED)
427 lex_match (lexer, T_EQUALS);
428 if (lex_match_id (lexer, "AUTOMATIC"))
429 settings_set_epoch (-1);
430 else if (lex_is_integer (lexer))
432 int new_epoch = lex_integer (lexer);
434 if (new_epoch < 1500)
436 msg (SE, _("%s must be 1500 or later."), "EPOCH");
439 settings_set_epoch (new_epoch);
443 lex_error (lexer, _("expecting %s or year"), "AUTOMATIC");
451 stc_custom_errors (struct lexer *lexer, struct dataset *ds UNUSED,
452 struct cmd_set *cmd UNUSED, void *aux UNUSED)
454 return set_output_routing (lexer, SETTINGS_OUTPUT_ERROR);
458 stc_custom_length (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
462 lex_match (lexer, T_EQUALS);
463 if (lex_match_id (lexer, "NONE"))
467 if (!lex_force_int (lexer))
469 if (lex_integer (lexer) < 1)
471 msg (SE, _("%s must be at least %d."), "LENGTH", 1);
474 page_length = lex_integer (lexer);
478 if (page_length != -1)
479 settings_set_viewlength (page_length);
485 stc_custom_locale (struct lexer *lexer, struct dataset *ds UNUSED,
486 struct cmd_set *cmd UNUSED, void *aux UNUSED)
490 lex_match (lexer, T_EQUALS);
492 if ( !lex_force_string (lexer))
495 s = lex_tokcstr (lexer);
497 /* First try this string as an encoding name */
498 if ( valid_encoding (s))
499 set_default_encoding (s);
501 /* Now try as a locale name (or alias) */
502 else if (set_encoding_from_locale (s))
507 msg (ME, _("%s is not a recognized encoding or locale name"), s);
517 stc_custom_messages (struct lexer *lexer, struct dataset *ds UNUSED,
518 struct cmd_set *cmd UNUSED, void *aux UNUSED)
520 return set_output_routing (lexer, SETTINGS_OUTPUT_NOTE);
524 stc_custom_printback (struct lexer *lexer, struct dataset *ds UNUSED,
525 struct cmd_set *cmd UNUSED, void *aux UNUSED)
527 return set_output_routing (lexer, SETTINGS_OUTPUT_SYNTAX);
531 stc_custom_results (struct lexer *lexer, struct dataset *ds UNUSED,
532 struct cmd_set *cmd UNUSED, void *aux UNUSED)
534 return set_output_routing (lexer, SETTINGS_OUTPUT_RESULT);
538 stc_custom_seed (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
540 lex_match (lexer, T_EQUALS);
541 if (lex_match_id (lexer, "RANDOM"))
545 if (!lex_force_num (lexer))
547 set_rng (lex_number (lexer));
555 stc_custom_width (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
557 lex_match (lexer, T_EQUALS);
558 if (lex_match_id (lexer, "NARROW"))
559 settings_set_viewwidth (79);
560 else if (lex_match_id (lexer, "WIDE"))
561 settings_set_viewwidth (131);
564 if (!lex_force_int (lexer))
566 if (lex_integer (lexer) < 40)
568 msg (SE, _("%s must be at least %d."), "WIDTH", 40);
571 settings_set_viewwidth (lex_integer (lexer));
578 /* Parses FORMAT subcommand, which consists of a numeric format
581 stc_custom_format (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
585 lex_match (lexer, T_EQUALS);
586 if (!parse_format_specifier (lexer, &fmt))
589 if (!fmt_check_output (&fmt))
592 if (fmt_is_string (fmt.type))
594 char str[FMT_STRING_LEN_MAX + 1];
595 msg (SE, _("%s requires numeric output format as an argument. "
596 "Specified format %s is of type string."),
598 fmt_to_string (&fmt, str));
602 settings_set_format (&fmt);
607 stc_custom_journal (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
609 lex_match (lexer, T_EQUALS);
610 if (lex_match_id (lexer, "ON") || lex_match_id (lexer, "YES"))
612 else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO"))
614 else if (lex_is_string (lexer) || lex_token (lexer) == T_ID)
616 char *filename = utf8_to_filename (lex_tokcstr (lexer));
617 journal_set_file_name (filename);
624 lex_error (lexer, NULL);
631 stc_custom_log (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_set *cmd UNUSED, void *aux UNUSED)
633 return stc_custom_journal (lexer, ds, cmd, aux);
637 show_output_routing (enum settings_output_type type)
639 enum settings_output_devices devices;
642 devices = settings_get_output_routing (type);
643 if (devices & SETTINGS_DEVICE_LISTING)
644 s = devices & SETTINGS_DEVICE_TERMINAL ? "BOTH" : "LISTING";
645 else if (devices & SETTINGS_DEVICE_TERMINAL)
654 show_blanks (const struct dataset *ds UNUSED)
656 return (settings_get_blanks () == SYSMIS
658 : xasprintf ("%.*g", DBL_DIG + 1, settings_get_blanks ()));
662 show_cc (enum fmt_type type)
664 return fmt_number_style_to_string (fmt_settings_get_style (
665 settings_get_fmt_settings (), type));
669 show_cca (const struct dataset *ds UNUSED)
671 return show_cc (FMT_CCA);
675 show_ccb (const struct dataset *ds UNUSED)
677 return show_cc (FMT_CCB);
681 show_ccc (const struct dataset *ds UNUSED)
683 return show_cc (FMT_CCC);
687 show_ccd (const struct dataset *ds UNUSED)
689 return show_cc (FMT_CCD);
693 show_cce (const struct dataset *ds UNUSED)
695 return show_cc (FMT_CCE);
699 show_decimals (const struct dataset *ds UNUSED)
701 return xasprintf ("`%c'", settings_get_fmt_settings ()->decimal);
705 show_errors (const struct dataset *ds UNUSED)
707 return show_output_routing (SETTINGS_OUTPUT_ERROR);
711 show_format (const struct dataset *ds UNUSED)
713 char str[FMT_STRING_LEN_MAX + 1];
714 return xstrdup (fmt_to_string (settings_get_format (), str));
718 show_fuzzbits (const struct dataset *ds UNUSED)
720 return xasprintf ("%d", settings_get_fuzzbits ());
724 show_journal (const struct dataset *ds UNUSED)
726 return (journal_is_enabled ()
727 ? xasprintf ("\"%s\"", journal_get_file_name ())
728 : xstrdup ("disabled"));
732 show_length (const struct dataset *ds UNUSED)
734 return xasprintf ("%d", settings_get_viewlength ());
738 show_locale (const struct dataset *ds UNUSED)
740 return xstrdup (get_default_encoding ());
744 show_messages (const struct dataset *ds UNUSED)
746 return show_output_routing (SETTINGS_OUTPUT_NOTE);
750 show_printback (const struct dataset *ds UNUSED)
752 return show_output_routing (SETTINGS_OUTPUT_SYNTAX);
756 show_results (const struct dataset *ds UNUSED)
758 return show_output_routing (SETTINGS_OUTPUT_RESULT);
762 show_mxerrs (const struct dataset *ds UNUSED)
764 return xasprintf ("%d", settings_get_max_messages (MSG_S_ERROR));
768 show_mxloops (const struct dataset *ds UNUSED)
770 return xasprintf ("%d", settings_get_mxloops ());
774 show_mxwarns (const struct dataset *ds UNUSED)
776 return xasprintf ("%d", settings_get_max_messages (MSG_S_WARNING));
779 /* Returns a name for the given INTEGER_FORMAT value. */
781 show_integer_format (enum integer_format integer_format)
783 return xasprintf ("%s (%s)",
784 (integer_format == INTEGER_MSB_FIRST ? "MSBFIRST"
785 : integer_format == INTEGER_LSB_FIRST ? "LSBFIRST"
787 integer_format == INTEGER_NATIVE ? "NATIVE" : "nonnative");
790 /* Returns a name for the given FLOAT_FORMAT value. */
792 show_float_format (enum float_format float_format)
794 const char *format_name = "";
796 switch (float_format)
798 case FLOAT_IEEE_SINGLE_LE:
799 format_name = _("ISL (32-bit IEEE 754 single, little-endian)");
801 case FLOAT_IEEE_SINGLE_BE:
802 format_name = _("ISB (32-bit IEEE 754 single, big-endian)");
804 case FLOAT_IEEE_DOUBLE_LE:
805 format_name = _("IDL (64-bit IEEE 754 double, little-endian)");
807 case FLOAT_IEEE_DOUBLE_BE:
808 format_name = _("IDB (64-bit IEEE 754 double, big-endian)");
812 format_name = _("VF (32-bit VAX F, VAX-endian)");
815 format_name = _("VD (64-bit VAX D, VAX-endian)");
818 format_name = _("VG (64-bit VAX G, VAX-endian)");
822 format_name = _("ZS (32-bit IBM Z hexadecimal short, big-endian)");
825 format_name = _("ZL (64-bit IBM Z hexadecimal long, big-endian)");
833 return xasprintf ("%s (%s)", format_name,
834 (float_format == FLOAT_NATIVE_DOUBLE
835 ? "NATIVE" : "nonnative"));
839 show_rib (const struct dataset *ds UNUSED)
841 return show_integer_format (settings_get_input_integer_format ());
845 show_rrb (const struct dataset *ds UNUSED)
847 return show_float_format (settings_get_input_float_format ());
851 show_scompression (const struct dataset *ds UNUSED)
853 return xstrdup (settings_get_scompression () ? "ON" : "OFF");
857 show_undefined (const struct dataset *ds UNUSED)
859 return xstrdup (settings_get_undefined () ? "WARN" : "NOWARN");
863 show_weight (const struct dataset *ds)
865 const struct variable *var = dict_get_weight (dataset_dict (ds));
866 return xstrdup (var != NULL ? var_get_name (var) : "OFF");
870 show_wib (const struct dataset *ds UNUSED)
872 return show_integer_format (settings_get_output_integer_format ());
876 show_wrb (const struct dataset *ds UNUSED)
878 return show_float_format (settings_get_output_float_format ());
882 show_width (const struct dataset *ds UNUSED)
884 return xasprintf ("%d", settings_get_viewwidth ());
888 show_workspace (const struct dataset *ds UNUSED)
890 size_t ws = settings_get_workspace () / 1024L;
891 return xasprintf ("%zu", ws);
895 show_current_directory (const struct dataset *ds UNUSED)
904 buf = xrealloc (buf, len);
906 while (NULL == (wd = getcwd (buf, len)));
912 show_tempdir (const struct dataset *ds UNUSED)
914 return strdup (temp_dir_name ());
918 show_version (const struct dataset *ds UNUSED)
920 return strdup (announced_version);
924 show_system (const struct dataset *ds UNUSED)
926 return strdup (host_system);
930 show_n (const struct dataset *ds)
935 const struct casereader *reader = dataset_source (ds);
938 return strdup (_("Unknown"));
940 n = casereader_count_cases (reader);
942 return asnprintf (NULL, &l, "%ld", n);
949 char *(*function) (const struct dataset *);
952 const struct show_sbc show_table[] =
954 {"BLANKS", show_blanks},
960 {"DECIMALS", show_decimals},
961 {"DIRECTORY", show_current_directory},
962 {"ENVIRONMENT", show_system},
963 {"ERRORS", show_errors},
964 {"FORMAT", show_format},
965 {"FUZZBITS", show_fuzzbits},
966 {"JOURNAL", show_journal},
967 {"LENGTH", show_length},
968 {"LOCALE", show_locale},
969 {"MESSAGES", show_messages},
970 {"MXERRS", show_mxerrs},
971 {"MXLOOPS", show_mxloops},
972 {"MXWARNS", show_mxwarns},
974 {"PRINTBACk", show_printback},
975 {"RESULTS", show_results},
978 {"SCOMPRESSION", show_scompression},
979 {"TEMPDIR", show_tempdir},
980 {"UNDEFINED", show_undefined},
981 {"VERSION", show_version},
982 {"WEIGHT", show_weight},
985 {"WIDTH", show_width},
986 {"WORKSPACE", show_workspace},
990 do_show (const struct dataset *ds, const struct show_sbc *sbc)
992 char *value = sbc->function (ds);
993 msg (SN, _("%s is %s."), sbc->name, value);
998 show_all (const struct dataset *ds)
1002 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
1003 do_show (ds, &show_table[i]);
1007 show_all_cc (const struct dataset *ds)
1011 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
1013 const struct show_sbc *sbc = &show_table[i];
1014 if (!strncmp (sbc->name, "CC", 2))
1020 show_warranty (const struct dataset *ds UNUSED)
1022 fputs (lack_of_warranty, stdout);
1026 show_copying (const struct dataset *ds UNUSED)
1028 fputs (copyleft, stdout);
1033 cmd_show (struct lexer *lexer, struct dataset *ds)
1035 if (lex_token (lexer) == T_ENDCMD)
1043 if (lex_match (lexer, T_ALL))
1045 else if (lex_match_id (lexer, "CC"))
1047 else if (lex_match_id (lexer, "WARRANTY"))
1049 else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE"))
1051 else if (lex_token (lexer) == T_ID)
1055 for (i = 0; i < sizeof show_table / sizeof *show_table; i++)
1057 const struct show_sbc *sbc = &show_table[i];
1058 if (lex_match_id (lexer, sbc->name))
1064 lex_error (lexer, NULL);
1071 lex_error (lexer, NULL);
1075 lex_match (lexer, T_SLASH);
1077 while (lex_token (lexer) != T_ENDCMD);
1082 #define MAX_SAVED_SETTINGS 5
1084 static struct settings *saved_settings[MAX_SAVED_SETTINGS];
1085 static int n_saved_settings;
1088 cmd_preserve (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
1090 if (n_saved_settings < MAX_SAVED_SETTINGS)
1092 saved_settings[n_saved_settings++] = settings_get ();
1097 msg (SE, _("Too many %s commands without a %s: at most "
1098 "%d levels of saved settings are allowed."),
1099 "PRESERVE", "RESTORE",
1100 MAX_SAVED_SETTINGS);
1101 return CMD_CASCADING_FAILURE;
1106 cmd_restore (struct lexer *lexer UNUSED, struct dataset *ds UNUSED)
1108 if (n_saved_settings > 0)
1110 struct settings *s = saved_settings[--n_saved_settings];
1112 settings_destroy (s);
1117 msg (SE, _("%s without matching %s."), "RESTORE", "PRESERVE");