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=3c0109cce89b4a1023640b08608a460934597dba;hpb=649775d1010c9c89ea63d90544d41069538f90a7;p=pspp diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index 3c0109cce8..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; } @@ -509,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); @@ -618,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 * @@ -923,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: