X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Futilities%2Fset.c;h=e7c17765d61c2419c90ceb73a4a409b2d14a8bf0;hb=15e323443edce619168aede1421aa195e7f7ecc2;hp=a29e5c2ef05ed2a9df06363bc939562a3834dca3;hpb=5b1ac2e0d8c2087946ae36449833588f881fae52;p=pspp diff --git a/src/language/utilities/set.c b/src/language/utilities/set.c index a29e5c2ef0..e7c17765d6 100644 --- a/src/language/utilities/set.c +++ b/src/language/utilities/set.c @@ -23,9 +23,6 @@ #include #include -#include "gl/ftoastr.h" -#include "gl/vasnprintf.h" - #include "data/casereader.h" #include "data/data-in.h" #include "data/data-out.h" @@ -52,11 +49,15 @@ #include "output/journal.h" #include "output/pivot-table.h" +#include "gl/ftoastr.h" #include "gl/minmax.h" +#include "gl/relocatable.h" +#include "gl/vasnprintf.h" #include "gl/xalloc.h" #include "gettext.h" #define _(msgid) gettext (msgid) +#define N_(msgid) (msgid) struct setting { @@ -616,6 +617,22 @@ show_JOURNAL (const struct dataset *ds UNUSED) : xstrdup (enabled)); } +static bool +parse_LEADZERO (struct lexer *lexer) +{ + int leadzero = force_parse_bool (lexer); + if (leadzero != -1) + settings_set_include_leading_zero (leadzero); + return leadzero != -1; +} + +static char * +show_LEADZERO (const struct dataset *ds UNUSED) +{ + bool leadzero = settings_get_fmt_settings ()->include_leading_zero; + return xstrdup (leadzero ? "ON" : "OFF"); +} + static bool parse_LENGTH (struct lexer *lexer) { @@ -669,6 +686,24 @@ show_LOCALE (const struct dataset *ds UNUSED) return xstrdup (get_default_encoding ()); } +static bool +parse_MDISPLAY (struct lexer *lexer) +{ + int mdisplay = force_parse_enum (lexer, + "TEXT", SETTINGS_MDISPLAY_TEXT, + "TABLES", SETTINGS_MDISPLAY_TABLES); + if (mdisplay >= 0) + settings_set_mdisplay (mdisplay); + return mdisplay >= 0; +} + +static char * +show_MDISPLAY (const struct dataset *ds UNUSED) +{ + return xstrdup (settings_get_mdisplay () == SETTINGS_MDISPLAY_TEXT + ? "TEXT" : "TABLES"); +} + static bool parse_MESSAGES (struct lexer *lexer) { @@ -922,12 +957,6 @@ show_SUBTITLE (const struct dataset *ds UNUSED) return xstrdup (output_get_subtitle ()); } -static char * -show_SYSTEM (const struct dataset *ds UNUSED) -{ - return xstrdup (host_system); -} - static char * show_TEMPDIR (const struct dataset *ds UNUSED) { @@ -1150,6 +1179,36 @@ show_copying (const struct dataset *ds UNUSED) { fputs (copyleft, stdout); } + +static void +add_row (struct pivot_table *table, const char *attribute, + const char *value) +{ + int row = pivot_category_create_leaf (table->dimensions[0]->root, + pivot_value_new_text (attribute)); + if (value) + pivot_table_put1 (table, row, pivot_value_new_user_text (value, -1)); +} + +static void +show_system (const struct dataset *ds UNUSED) +{ + struct pivot_table *table = pivot_table_create (N_("System Information")); + pivot_dimension_create (table, PIVOT_AXIS_ROW, N_("Attribute")); + + add_row (table, N_("Version"), version); + add_row (table, N_("Host System"), host_system); + add_row (table, N_("Build System"), build_system); + add_row (table, N_("Locale Directory"), relocate (locale_dir)); + add_row (table, N_("Compiler Version"), +#ifdef __VERSION__ + __VERSION__ +#else + "Unknown" +#endif + ); + pivot_table_submit (table); +} static const struct setting settings[] = { { "BASETEXTDIRECTION", parse_BASETEXTDIRECTION, NULL }, @@ -1175,8 +1234,10 @@ static const struct setting settings[] = { { "HEADER", parse_HEADER, NULL }, { "INCLUDE", parse_INCLUDE, show_INCLUDE }, { "JOURNAL", parse_JOURNAL, show_JOURNAL }, + { "LEADZERO", parse_LEADZERO, show_LEADZERO }, { "LENGTH", parse_LENGTH, show_LENGTH }, { "LOCALE", parse_LOCALE, show_LOCALE }, + { "MDISPLAY", parse_MDISPLAY, show_MDISPLAY }, { "MESSAGES", parse_MESSAGES, show_MESSAGES }, { "MEXPAND", parse_MEXPAND, show_MEXPAND }, { "MITERATE", parse_MITERATE, show_MITERATE }, @@ -1194,7 +1255,6 @@ static const struct setting settings[] = { { "SCOMPRESSION", parse_SCOMPRESSION, show_SCOMPRESSION }, { "SEED", parse_SEED, NULL }, { "SMALL", parse_SMALL, show_SMALL }, - { "SYSTEM", NULL, show_SYSTEM }, { "TEMPDIR", NULL, show_TEMPDIR }, { "TNUMBERS", parse_TNUMBERS, show_TNUMBERS }, { "TVARS", parse_TVARS, show_TVARS }, @@ -1274,6 +1334,8 @@ cmd_show (struct lexer *lexer, struct dataset *ds) show_warranty (ds); else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE")) show_copying (ds); + else if (lex_match_id (lexer, "SYSTEM")) + show_system (ds); else if (lex_match_id (lexer, "TITLE")) { struct setting s = { .name = "TITLE", .show = show_TITLE };