X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Futilities%2Fset.q;h=9a2e981a910d1d3930a41b4de03d8bf6ca3bb8c4;hb=01b970b8972e4e457b1d8e3f5af350c325152942;hp=6a1d184f600f88d28723a409b5237ad1b30a3c7e;hpb=f550aee00a62fe1d8baf62d83cd7efef6cc2ee92;p=pspp diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index 6a1d184f60..9a2e981a91 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -402,7 +402,7 @@ stc_custom_locale (struct lexer *lexer, struct dataset *ds UNUSED, } else { - msg (ME, _("%s is not a recognised encoding or locale name"), + msg (ME, _("%s is not a recognized encoding or locale name"), ds_cstr (s)); return 0; } @@ -484,6 +484,10 @@ stc_custom_format (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_se lex_match (lexer, '='); if (!parse_format_specifier (lexer, &fmt)) return 0; + + if (!fmt_check_output (&fmt)) + return 0; + if (fmt_is_string (fmt.type)) { char str[FMT_STRING_LEN_MAX + 1]; @@ -505,7 +509,7 @@ stc_custom_journal (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_s journal_enable (); else if (lex_match_id (lexer, "OFF") || lex_match_id (lexer, "NO")) journal_disable (); - else if (lex_token (lexer) == T_STRING || lex_token (lexer) == T_ID) + else if (lex_is_string (lexer) || lex_token (lexer) == T_ID) { journal_set_file_name (ds_cstr (lex_tokstr (lexer))); lex_get (lexer); @@ -614,13 +618,13 @@ show_cce (const struct dataset *ds UNUSED) static char * show_decimals (const struct dataset *ds UNUSED) { - return xasprintf ("\"%c\"", settings_get_decimal_char (FMT_F)); + return xasprintf ("`%c'", settings_get_decimal_char (FMT_F)); } static char * show_endcmd (const struct dataset *ds UNUSED) { - return xasprintf ("\"%c\"", settings_get_endcmd ()); + return xasprintf ("`%c'", settings_get_endcmd ()); } static char * @@ -919,6 +923,45 @@ cmd_show (struct lexer *lexer, struct dataset *ds) return CMD_SUCCESS; } + +#define MAX_SAVED_SETTINGS 5 + +static struct settings *saved_settings[MAX_SAVED_SETTINGS]; +static int n_saved_settings; + +int +cmd_preserve (struct lexer *lexer, struct dataset *ds UNUSED) +{ + if (n_saved_settings < MAX_SAVED_SETTINGS) + { + saved_settings[n_saved_settings++] = settings_get (); + return lex_end_of_command (lexer); + } + else + { + msg (SE, _("Too many PRESERVE commands without a RESTORE: at most " + "%d levels of saved settings are allowed."), + MAX_SAVED_SETTINGS); + return CMD_CASCADING_FAILURE; + } +} + +int +cmd_restore (struct lexer *lexer, struct dataset *ds UNUSED) +{ + if (n_saved_settings > 0) + { + struct settings *s = saved_settings[--n_saved_settings]; + settings_set (s); + settings_destroy (s); + return lex_end_of_command (lexer); + } + else + { + msg (SE, _("RESTORE without matching PRESERVE.")); + return CMD_FAILURE; + } +} /* Local Variables: