X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Futilities%2Fset.q;h=9a7e841707f535076bf1ad0126f454dd17aa1ba8;hb=1c14db584d9a90589ae04889975944e4e7ca3a77;hp=ed6a08519ed7418e33ac6af1cb267f3bc5db94e6;hpb=4183dccd4130c9a6122cb2fa149e5dbf811db554;p=pspp diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index ed6a08519e..9a7e841707 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,11 @@ #include #include #include +#include +#include "gl/vasnprintf.h" + +#include "data/casereader.h" #include "data/data-in.h" #include "data/data-out.h" #include "data/dataset.h" @@ -34,6 +38,8 @@ #include "language/lexer/lexer.h" #include "libpspp/compiler.h" #include "libpspp/copyleft.h" +#include "libpspp/temp-file.h" +#include "libpspp/version.h" #include "libpspp/float-format.h" #include "libpspp/i18n.h" #include "libpspp/integer-format.h" @@ -102,6 +108,7 @@ int tgetnum (const char *); scripttab=string; seed=custom; tnumbers=custom; + tvars=custom; tb1=string; tbfonts=string; undefined=undef:warn/nowarn; @@ -351,6 +358,35 @@ stc_custom_tnumbers (struct lexer *lexer, } +static int +stc_custom_tvars (struct lexer *lexer, + struct dataset *ds UNUSED, + struct cmd_set *cmd UNUSED, void *aux UNUSED) +{ + lex_match (lexer, T_EQUALS); + + if (lex_match_id (lexer, "NAMES")) + { + settings_set_var_style (SETTINGS_VAR_STYLE_NAMES); + } + else if (lex_match_id (lexer, "LABELS")) + { + settings_set_var_style (SETTINGS_VAR_STYLE_LABELS); + } + else if (lex_match_id (lexer, "BOTH")) + { + settings_set_var_style (SETTINGS_VAR_STYLE_BOTH); + } + else + { + lex_error_expecting (lexer, "NAMES", "LABELS", "BOTH", NULL_SENTINEL); + return 0; + } + + return 1; +} + + /* Parses the EPOCH subcommand, which controls the epoch used for parsing 2-digit years. */ static int @@ -672,6 +708,14 @@ show_format (const struct dataset *ds UNUSED) return xstrdup (fmt_to_string (settings_get_format (), str)); } +static char * +show_journal (const struct dataset *ds UNUSED) +{ + return (journal_is_enabled () + ? xasprintf ("\"%s\"", journal_get_file_name ()) + : xstrdup ("disabled")); +} + static char * show_length (const struct dataset *ds UNUSED) { @@ -828,6 +872,65 @@ show_width (const struct dataset *ds UNUSED) return xasprintf ("%d", settings_get_viewwidth ()); } +static char * +show_workspace (const struct dataset *ds UNUSED) +{ + size_t ws = settings_get_workspace () / 1024L; + return xasprintf ("%zu", ws); +} + +static char * +show_current_directory (const struct dataset *ds UNUSED) +{ + char *buf = NULL; + char *wd = NULL; + size_t len = 256; + + do + { + len <<= 1; + buf = xrealloc (buf, len); + } + while (NULL == (wd = getcwd (buf, len))); + + return wd; +} + +static char * +show_tempdir (const struct dataset *ds UNUSED) +{ + return strdup (temp_dir_name ()); +} + +static char * +show_version (const struct dataset *ds UNUSED) +{ + return strdup (version); +} + +static char * +show_system (const struct dataset *ds UNUSED) +{ + return strdup (host_system); +} + +static char * +show_n (const struct dataset *ds) +{ + casenumber n; + size_t l; + + const struct casereader *reader = dataset_source (ds); + + if (reader == NULL) + return strdup (_("Unknown")); + + n = casereader_count_cases (reader); + + return asnprintf (NULL, &l, "%ld", n); +} + + struct show_sbc { const char *name; @@ -843,24 +946,31 @@ const struct show_sbc show_table[] = {"CCD", show_ccd}, {"CCE", show_cce}, {"DECIMALS", show_decimals}, + {"DIRECTORY", show_current_directory}, + {"ENVIRONMENT", show_system}, {"ERRORS", show_errors}, {"FORMAT", show_format}, + {"JOURNAL", show_journal}, {"LENGTH", show_length}, {"LOCALE", show_locale}, {"MESSAGES", show_messages}, {"MXERRS", show_mxerrs}, {"MXLOOPS", show_mxloops}, {"MXWARNS", show_mxwarns}, + {"N", show_n}, {"PRINTBACk", show_printback}, {"RESULTS", show_results}, {"RIB", show_rib}, {"RRB", show_rrb}, {"SCOMPRESSION", show_scompression}, + {"TEMPDIR", show_tempdir}, {"UNDEFINED", show_undefined}, + {"VERSION", show_version}, {"WEIGHT", show_weight}, {"WIB", show_wib}, {"WRB", show_wrb}, {"WIDTH", show_width}, + {"WORKSPACE", show_workspace}, }; static void @@ -905,6 +1015,7 @@ show_copying (const struct dataset *ds UNUSED) fputs (copyleft, stdout); } + int cmd_show (struct lexer *lexer, struct dataset *ds) { @@ -922,7 +1033,7 @@ cmd_show (struct lexer *lexer, struct dataset *ds) show_all_cc (ds); else if (lex_match_id (lexer, "WARRANTY")) show_warranty (ds); - else if (lex_match_id (lexer, "COPYING")) + else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE")) show_copying (ds); else if (lex_token (lexer) == T_ID) {