X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fsys-file-info.c;h=ec93ea201cfc3db974284194b86a387810fa2321;hb=0097b71cac1297fba88b3c019836090dd0cf639c;hp=a13dda37d746f5fae28c8c3d44e46fa353461a64;hpb=077a1c38bd58911cb74a08f95be3691e49b87779;p=pspp-builds.git diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index a13dda37..ec93ea20 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -62,7 +62,7 @@ enum 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. */ @@ -193,7 +193,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) 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 @@ -204,7 +204,7 @@ cmd_display (struct lexer *lexer, struct dataset *ds) /* Variables to display. */ size_t n; - struct variable **vl; + const struct variable **vl; if (lex_match_id (lexer, "MACROS")) display_macros (); @@ -258,7 +258,7 @@ cmd_display (struct lexer *lexer, struct dataset *ds) 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; @@ -316,25 +316,18 @@ display_documents (const struct dictionary *dict) "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); } } @@ -364,9 +357,9 @@ variables_dim (struct tab_table *t, struct outp_driver *d) } 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. */ @@ -404,7 +397,7 @@ display_variables (struct variable **vl, size_t n, int as) for (i = r = 1; i <= n; i++) { - struct variable *v; + const struct variable *v; while (*vp == NULL) vp++; @@ -458,7 +451,7 @@ display_variables (struct variable **vl, size_t n, int as) 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);