X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fsys-file-info.c;h=2a0439c2dd2944858d3d9fde2d46f9e4e5ebc7f5;hb=3a61659a8fc11c51ad5af02b20f5613dcde50382;hp=97bf3df58a9c2035151f01cff8bcb27794e16f70;hpb=b0bf9b1b0f727fafac4296a048e3f45db5936f81;p=pspp diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 97bf3df58a..2a0439c2dd 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -1,5 +1,5 @@ /* PSPP - computes sample statistics. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc. Written by Ben Pfaff . This program is free software; you can redistribute it and/or @@ -24,13 +24,14 @@ #include #include -#include +#include #include #include #include #include #include #include +#include #include #include #include @@ -77,7 +78,7 @@ sysfile_info_dim (struct tab_table *t, struct outp_driver *d) /* SYSFILE INFO utility. */ int -cmd_sysfile_info (void) +cmd_sysfile_info (struct dataset *ds UNUSED) { struct file_handle *h; struct dictionary *d; @@ -175,12 +176,12 @@ cmd_sysfile_info (void) /* DISPLAY utility. */ static void display_macros (void); -static void display_documents (void); +static void display_documents (const struct dictionary *dict); static void display_variables (struct variable **, size_t, int); -static void display_vectors (int sorted); +static void display_vectors (const struct dictionary *dict, int sorted); int -cmd_display (void) +cmd_display (struct dataset *ds) { /* Whether to sort the list of variables alphabetically. */ int sorted; @@ -192,19 +193,19 @@ cmd_display (void) if (lex_match_id ("MACROS")) display_macros (); else if (lex_match_id ("DOCUMENTS")) - display_documents (); + display_documents (dataset_dict (ds)); else if (lex_match_id ("FILE")) { som_blank_line (); if (!lex_force_match_id ("LABEL")) return CMD_FAILURE; - if (dict_get_label (default_dict) == NULL) + if (dict_get_label (dataset_dict (ds)) == NULL) tab_output_text (TAB_LEFT, _("The active file does not have a file label.")); else { tab_output_text (TAB_LEFT | TAT_TITLE, _("File label:")); - tab_output_text (TAB_LEFT | TAB_FIX, dict_get_label (default_dict)); + tab_output_text (TAB_LEFT | TAB_FIX, dict_get_label (dataset_dict (ds))); } } else @@ -230,7 +231,7 @@ cmd_display (void) if (as == AS_VECTOR) { - display_vectors (sorted); + display_vectors (dataset_dict(ds), sorted); return CMD_SUCCESS; } @@ -240,7 +241,7 @@ cmd_display (void) if (token != '.') { - if (!parse_variables (default_dict, &vl, &n, PV_NONE)) + if (!parse_variables (dataset_dict (ds), &vl, &n, PV_NONE)) { free (vl); return CMD_FAILURE; @@ -248,7 +249,7 @@ cmd_display (void) as = AS_DICTIONARY; } else - dict_get_vars (default_dict, &vl, &n, 0); + dict_get_vars (dataset_dict (ds), &vl, &n, 0); if (as == AS_SCRATCH) { @@ -270,7 +271,7 @@ cmd_display (void) } if (sorted) - sort (vl, n, sizeof *vl, compare_var_names, NULL); + sort (vl, n, sizeof *vl, compare_var_ptr_names, NULL); display_variables (vl, n, as); @@ -288,9 +289,9 @@ display_macros (void) } static void -display_documents (void) +display_documents (const struct dictionary *dict) { - const char *documents = dict_get_documents (default_dict); + const char *documents = dict_get_documents (dict); som_blank_line (); if (documents == NULL) @@ -453,17 +454,19 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as) && v->print.w == v->write.w && v->print.d == v->write.d) { + char str[FMT_STRING_LEN_MAX + 1]; tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF, _("Format: %s"), - fmt_to_string (&v->print)); + fmt_to_string (&v->print, str)); r++; } else { + char str[FMT_STRING_LEN_MAX + 1]; tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF, - _("Print Format: %s"), fmt_to_string (&v->print)); + _("Print Format: %s"), fmt_to_string (&v->print, str)); r++; tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF, - _("Write Format: %s"), fmt_to_string (&v->write)); + _("Write Format: %s"), fmt_to_string (&v->write, str)); r++; } @@ -482,11 +485,11 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as) double x, y; mv_pop_range (&mv, &x, &y); if (x == LOWEST) - cp += nsprintf (cp, "LOWEST THRU %g", y); + cp += sprintf (cp, "LOWEST THRU %g", y); else if (y == HIGHEST) - cp += nsprintf (cp, "%g THRU HIGHEST", x); + cp += sprintf (cp, "%g THRU HIGHEST", x); else - cp += nsprintf (cp, "%g THRU %g", x, y); + cp += sprintf (cp, "%g THRU %g", x, y); cnt++; } while (mv_has_value (&mv)) @@ -494,9 +497,9 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as) union value value; mv_pop_value (&mv, &value); if (cnt++ > 0) - cp += nsprintf (cp, "; "); + cp += sprintf (cp, "; "); if (v->type == NUMERIC) - cp += nsprintf (cp, "%g", value.f); + cp += sprintf (cp, "%g", value.f); else { *cp++ = '"'; @@ -566,14 +569,14 @@ compare_vectors_by_name (const void *a_, const void *b_) /* Display a list of vectors. If SORTED is nonzero then they are sorted alphabetically. */ static void -display_vectors (int sorted) +display_vectors (const struct dictionary *dict, int sorted) { const struct vector **vl; int i; struct tab_table *t; size_t nvec; - nvec = dict_get_vector_cnt (default_dict); + nvec = dict_get_vector_cnt (dict); if (nvec == 0) { msg (SW, _("No vectors defined.")); @@ -582,7 +585,7 @@ display_vectors (int sorted) vl = xnmalloc (nvec, sizeof *vl); for (i = 0; i < nvec; i++) - vl[i] = dict_get_vector (default_dict, i); + vl[i] = dict_get_vector (dict, i); if (sorted) qsort (vl, nvec, sizeof *vl, compare_vectors_by_name);