/* PSPP - computes sample statistics.
Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
AS_VECTOR
};
-static int describe_variable (struct variable *v, struct tab_table *t, int r, int as);
+static int describe_variable (const struct variable *v, struct tab_table *t, int r, int as);
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
return CMD_FAILURE;
sfm_close_reader (reader);
- t = tab_create (2, 9, 0);
+ t = tab_create (2, 10, 0);
tab_vline (t, TAL_GAP, 1, 0, 8);
tab_text (t, 0, 0, TAB_LEFT, _("File:"));
tab_text (t, 1, 0, TAB_LEFT, fh_get_file_name (h));
tab_text (t, 0, 2, TAB_LEFT, _("Created:"));
tab_text (t, 1, 2, TAB_LEFT | TAT_PRINTF, "%s %s by %s",
info.creation_date, info.creation_time, info.product);
- tab_text (t, 0, 3, TAB_LEFT, _("Endian:"));
- tab_text (t, 1, 3, TAB_LEFT, info.big_endian ? _("Big.") : _("Little."));
- tab_text (t, 0, 4, TAB_LEFT, _("Variables:"));
- tab_text (t, 1, 4, TAB_LEFT | TAT_PRINTF, "%d",
- dict_get_var_cnt (d));
- tab_text (t, 0, 5, TAB_LEFT, _("Cases:"));
- tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF,
+ tab_text (t, 0, 3, TAB_LEFT, _("Integer Format:"));
+ tab_text (t, 1, 3, TAB_LEFT,
+ info.integer_format == INTEGER_MSB_FIRST ? _("Big Endian.")
+ : info.integer_format == INTEGER_LSB_FIRST ? _("Little Endian.")
+ : _("Unknown."));
+ tab_text (t, 0, 4, TAB_LEFT, _("Real Format:"));
+ tab_text (t, 1, 4, TAB_LEFT,
+ info.float_format == FLOAT_IEEE_DOUBLE_LE ? _("IEEE 754 LE.")
+ : info.float_format == FLOAT_IEEE_DOUBLE_BE ? _("IEEE 754 BE.")
+ : info.float_format == FLOAT_VAX_D ? _("VAX D.")
+ : info.float_format == FLOAT_VAX_G ? _("VAX G.")
+ : info.float_format == FLOAT_Z_LONG ? _("IBM 390 Hex Long.")
+ : _("Unknown."));
+ tab_text (t, 0, 5, TAB_LEFT, _("Variables:"));
+ tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF, "%u",
+ (unsigned int) dict_get_var_cnt (d));
+ tab_text (t, 0, 6, TAB_LEFT, _("Cases:"));
+ tab_text (t, 1, 6, TAB_LEFT | TAT_PRINTF,
info.case_cnt == -1 ? _("Unknown") : "%d", info.case_cnt);
- tab_text (t, 0, 6, TAB_LEFT, _("Type:"));
- tab_text (t, 1, 6, TAB_LEFT, _("System File."));
- tab_text (t, 0, 7, TAB_LEFT, _("Weight:"));
+ tab_text (t, 0, 7, TAB_LEFT, _("Type:"));
+ tab_text (t, 1, 7, TAB_LEFT, _("System File."));
+ tab_text (t, 0, 8, TAB_LEFT, _("Weight:"));
{
struct variable *weight_var = dict_get_weight (d);
- tab_text (t, 1, 7, TAB_LEFT,
+ tab_text (t, 1, 8, TAB_LEFT,
(weight_var != NULL
? var_get_name (weight_var) : _("Not weighted.")));
}
- tab_text (t, 0, 8, TAB_LEFT, _("Mode:"));
- tab_text (t, 1, 8, TAB_LEFT | TAT_PRINTF,
+ tab_text (t, 0, 9, TAB_LEFT, _("Mode:"));
+ tab_text (t, 1, 9, TAB_LEFT | TAT_PRINTF,
_("Compression %s."), info.compressed ? _("on") : _("off"));
tab_dim (t, tab_natural_dimensions);
tab_submit (t);
static void display_macros (void);
static void display_documents (const struct dictionary *dict);
-static void display_variables (struct variable **, size_t, int);
+static void display_variables (const struct variable **, size_t, int);
static void display_vectors (const struct dictionary *dict, int sorted);
int
/* Variables to display. */
size_t n;
- struct variable **vl;
+ const struct variable **vl;
if (lex_match_id (lexer, "MACROS"))
display_macros ();
if (lex_token (lexer) != '.')
{
- if (!parse_variables (lexer, dataset_dict (ds), &vl, &n, PV_NONE))
+ if (!parse_variables_const (lexer, dataset_dict (ds), &vl, &n, PV_NONE))
{
free (vl);
return CMD_FAILURE;
"contain any documents."));
else
{
- size_t n_lines = strlen (documents) / 80;
- char buf[81];
+ struct string line = DS_EMPTY_INITIALIZER;
size_t i;
tab_output_text (TAB_LEFT | TAT_TITLE,
_("Documents in the active file:"));
som_blank_line ();
- buf[80] = 0;
- for (i = 0; i < n_lines; i++)
- {
- int len = 79;
-
- memcpy (buf, &documents[i * 80], 80);
- while ((isspace ((unsigned char) buf[len]) || buf[len] == 0)
- && len > 0)
- len--;
- buf[len + 1] = 0;
- tab_output_text (TAB_LEFT | TAB_FIX | TAT_NOWRAP, buf);
- }
+ for (i = 0; i < dict_get_document_line_cnt (dict); i++)
+ {
+ dict_get_document_line (dict, i, &line);
+ tab_output_text (TAB_LEFT | TAB_FIX | TAT_NOWRAP, ds_cstr (&line));
+ }
+ ds_destroy (&line);
}
}
}
static void
-display_variables (struct variable **vl, size_t n, int as)
+display_variables (const struct variable **vl, size_t n, int as)
{
- struct variable **vp = vl; /* Variable pointer. */
+ const struct variable **vp = vl; /* Variable pointer. */
struct tab_table *t;
int nc; /* Number of columns. */
int nr; /* Number of rows. */
for (i = r = 1; i <= n; i++)
{
- struct variable *v;
+ const struct variable *v;
while (*vp == NULL)
vp++;
The variable will be described in the format AS. Returns the next
row available for use in the table. */
static int
-describe_variable (struct variable *v, struct tab_table *t, int r, int as)
+describe_variable (const struct variable *v, struct tab_table *t, int r, int as)
{
const struct fmt_spec *print = var_get_print_format (v);
const struct fmt_spec *write = var_get_write_format (v);
int i;
struct tab_table *t;
size_t nvec;
+ size_t nrow;
+ size_t row;
nvec = dict_get_vector_cnt (dict);
if (nvec == 0)
}
vl = xnmalloc (nvec, sizeof *vl);
- for (i = 0; i < nvec; i++)
- vl[i] = dict_get_vector (dict, i);
+ nrow = 0;
+ for (i = 0; i < nvec; i++)
+ {
+ vl[i] = dict_get_vector (dict, i);
+ nrow += vector_get_var_cnt (vl[i]);
+ }
if (sorted)
qsort (vl, nvec, sizeof *vl, compare_vector_ptrs_by_name);
- t = tab_create (1, nvec + 1, 0);
+ t = tab_create (4, nrow + 1, 0);
tab_headers (t, 0, 0, 1, 0);
tab_columns (t, TAB_COL_DOWN, 1);
tab_dim (t, tab_natural_dimensions);
- tab_hline (t, TAL_1, 0, 0, 1);
+ tab_box (t, TAL_1, TAL_1, -1, -1, 0, 0, 3, nrow);
+ tab_box (t, -1, -1, -1, TAL_1, 0, 0, 3, nrow);
+ tab_hline (t, TAL_2, 0, 3, 1);
tab_text (t, 0, 0, TAT_TITLE | TAB_LEFT, _("Vector"));
+ tab_text (t, 1, 0, TAT_TITLE | TAB_LEFT, _("Position"));
+ tab_text (t, 2, 0, TAT_TITLE | TAB_LEFT, _("Variable"));
+ tab_text (t, 3, 0, TAT_TITLE | TAB_LEFT, _("Print Format"));
tab_flags (t, SOMF_NO_TITLE);
- for (i = 0; i < nvec; i++)
- tab_text (t, 0, i + 1, TAB_LEFT, vector_get_name (vl[i]));
- tab_submit (t);
-
- free (vl);
-}
-
-
-
-
-
-
-
+ row = 1;
+ for (i = 0; i < nvec; i++)
+ {
+ const struct vector *vec = vl[i];
+ size_t j;
+
+ tab_joint_text (t, 0, row, 0, row + vector_get_var_cnt (vec) - 1,
+ TAB_LEFT, vector_get_name (vl[i]));
+ for (j = 0; j < vector_get_var_cnt (vec); j++)
+ {
+ struct variable *var = vector_get_var (vec, j);
+ char fmt_string[FMT_STRING_LEN_MAX + 1];
+ fmt_to_string (var_get_print_format (var), fmt_string);
+
+ tab_text (t, 1, row, TAB_RIGHT | TAT_PRINTF, "%d", (int) j + 1);
+ tab_text (t, 2, row, TAB_LEFT, var_get_name (var));
+ tab_text (t, 3, row, TAB_LEFT, fmt_string);
+ row++;
+ }
+ tab_hline (t, TAL_1, 0, 3, row);
+ }
+ tab_submit (t);
+ free (vl);
+}