X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fsys-file-info.c;h=66ef00bb7063c988c6a4948c1049471399977da4;hb=42d90dac4bc5ee06ef0dd3cd62b84378f16e7ea9;hp=9cb551044914098e389c044e0d48e8098a856365;hpb=5cab4cf3322f29c0ed7134d23740e07382914f20;p=pspp diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 9cb5510449..66ef00bb70 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -89,6 +89,8 @@ static void report_encodings (const struct file_handle *, struct pool *, char **titles, bool *ids, char **strings, size_t n_strings); +static char *get_documents_as_string (const struct dictionary *); + static void add_row (struct pivot_table *table, const char *attribute, struct pivot_value *value) @@ -101,7 +103,7 @@ add_row (struct pivot_table *table, const char *attribute, /* SYSFILE INFO utility. */ int -cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) +cmd_sysfile_info (struct lexer *lexer, struct dataset *ds) { struct any_reader *any_reader; struct file_handle *h; @@ -239,6 +241,10 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) add_row (table, N_("Encoding"), pivot_value_new_user_text (dict_get_encoding (d), -1)); + if (dict_get_document_line_cnt (d) > 0) + add_row (table, N_("Documents"), + pivot_value_new_user_text_nocopy (get_documents_as_string (d))); + pivot_table_submit (table); size_t n_vars = dict_get_var_cnt (d); @@ -249,6 +255,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) display_value_labels (vars, n_vars); display_attributes (dict_get_attributes (dataset_dict (ds)), vars, n_vars, DF_ATTRIBUTES); + free (vars); dict_unref (d); @@ -397,6 +404,20 @@ display_macros (void) msg (SW, _("Macros not supported.")); } +static char * +get_documents_as_string (const struct dictionary *dict) +{ + const struct string_array *documents = dict_get_documents (dict); + struct string s = DS_EMPTY_INITIALIZER; + for (size_t i = 0; i < documents->n; i++) + { + if (i) + ds_put_byte (&s, '\n'); + ds_put_cstr (&s, documents->strings[i]); + } + return ds_steal_cstr (&s); +} + static void display_documents (const struct dictionary *dict) { @@ -405,20 +426,12 @@ display_documents (const struct dictionary *dict) table, PIVOT_AXIS_COLUMN, N_("Documents"), N_("Document")); d->hide_all_labels = true; - const struct string_array *documents = dict_get_documents (dict); - if (!documents->n) + if (!dict_get_documents (dict)->n) pivot_table_put1 (table, 0, pivot_value_new_text (N_("(none)"))); else { - struct string s = DS_EMPTY_INITIALIZER; - for (size_t i = 0; i < documents->n; i++) - { - if (i) - ds_put_byte (&s, '\n'); - ds_put_cstr (&s, documents->strings[i]); - } - pivot_table_put1 (table, 0, - pivot_value_new_user_text_nocopy (ds_steal_cstr (&s))); + char *docs = get_documents_as_string (dict); + pivot_table_put1 (table, 0, pivot_value_new_user_text_nocopy (docs)); } pivot_table_submit (table); @@ -693,7 +706,7 @@ display_attributes (const struct attrset *dict_attrset, var_get_attributes (vars[i]), flags); if (pivot_table_is_empty (table)) - pivot_table_destroy (table); + pivot_table_unref (table); else pivot_table_submit (table); } @@ -989,7 +1002,7 @@ report_encodings (const struct file_handle *h, struct pool *pool, /* Table of valid encodings. */ struct pivot_table *table = pivot_table_create__ ( pivot_value_new_text_format (N_("Usable encodings for %s."), - fh_get_name (h))); + fh_get_name (h)), "Usable Encodings"); table->caption = pivot_value_new_text_format ( N_("Encodings that can successfully read %s (by specifying the encoding " "name on the GET command's ENCODING subcommand). Encodings that " @@ -1027,7 +1040,8 @@ report_encodings (const struct file_handle *h, struct pool *pool, /* Table of alternative interpretations. */ table = pivot_table_create__ ( pivot_value_new_text_format (N_("%s Encoded Text Strings"), - fh_get_name (h))); + fh_get_name (h)), + "Alternate Encoded Text Strings"); table->caption = pivot_value_new_text ( N_("Text strings in the file dictionary that the previously listed " "encodings interpret differently, along with the interpretations."));