projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Completely rewrite src/data/format.[ch], to achieve better
[pspp]
/
src
/
language
/
dictionary
/
sys-file-info.c
diff --git
a/src/language/dictionary/sys-file-info.c
b/src/language/dictionary/sys-file-info.c
index 13c3275e035093a5c2c7be31bd1fc479f3d2c3a6..2a0439c2dd2944858d3d9fde2d46f9e4e5ebc7f5 100644
(file)
--- a/
src/language/dictionary/sys-file-info.c
+++ b/
src/language/dictionary/sys-file-info.c
@@
-1,5
+1,5
@@
/* PSPP - computes sample statistics.
/* 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 <blp@gnu.org>.
This program is free software; you can redistribute it and/or
Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
@@
-31,6
+31,7
@@
#include <language/command.h>
#include <language/data-io/file-handle.h>
#include <language/lexer/lexer.h>
#include <language/command.h>
#include <language/data-io/file-handle.h>
#include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
#include <libpspp/alloc.h>
#include <libpspp/array.h>
#include <libpspp/hash.h>
#include <libpspp/alloc.h>
#include <libpspp/array.h>
#include <libpspp/hash.h>
@@
-77,7
+78,7
@@
sysfile_info_dim (struct tab_table *t, struct outp_driver *d)
/* SYSFILE INFO utility. */
int
/* SYSFILE INFO utility. */
int
-cmd_sysfile_info (
void
)
+cmd_sysfile_info (
struct dataset *ds UNUSED
)
{
struct file_handle *h;
struct dictionary *d;
{
struct file_handle *h;
struct dictionary *d;
@@
-175,12
+176,12
@@
cmd_sysfile_info (void)
/* DISPLAY utility. */
static void display_macros (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_variables (struct variable **, size_t, int);
-static void display_vectors (int sorted);
+static void display_vectors (
const struct dictionary *dict,
int sorted);
int
int
-cmd_display (
void
)
+cmd_display (
struct dataset *ds
)
{
/* Whether to sort the list of variables alphabetically. */
int sorted;
{
/* 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"))
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;
else if (lex_match_id ("FILE"))
{
som_blank_line ();
if (!lex_force_match_id ("LABEL"))
return CMD_FAILURE;
- if (dict_get_label (d
efault_dict
) == NULL)
+ if (dict_get_label (d
ataset_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,
_("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 (d
efault_dict
));
+ tab_output_text (TAB_LEFT | TAB_FIX, dict_get_label (d
ataset_dict (ds)
));
}
}
else
}
}
else
@@
-230,7
+231,7
@@
cmd_display (void)
if (as == AS_VECTOR)
{
if (as == AS_VECTOR)
{
- display_vectors (sorted);
+ display_vectors (
dataset_dict(ds),
sorted);
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
@@
-240,7
+241,7
@@
cmd_display (void)
if (token != '.')
{
if (token != '.')
{
- if (!parse_variables (d
efault_dict
, &vl, &n, PV_NONE))
+ if (!parse_variables (d
ataset_dict (ds)
, &vl, &n, PV_NONE))
{
free (vl);
return CMD_FAILURE;
{
free (vl);
return CMD_FAILURE;
@@
-248,7
+249,7
@@
cmd_display (void)
as = AS_DICTIONARY;
}
else
as = AS_DICTIONARY;
}
else
- dict_get_vars (d
efault_dict
, &vl, &n, 0);
+ dict_get_vars (d
ataset_dict (ds)
, &vl, &n, 0);
if (as == AS_SCRATCH)
{
if (as == AS_SCRATCH)
{
@@
-270,7
+271,7
@@
cmd_display (void)
}
if (sorted)
}
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);
display_variables (vl, n, as);
@@
-288,9
+289,9
@@
display_macros (void)
}
static void
}
static void
-display_documents (
void
)
+display_documents (
const struct dictionary *dict
)
{
{
- const char *documents = dict_get_documents (d
efault_d
ict);
+ const char *documents = dict_get_documents (dict);
som_blank_line ();
if (documents == NULL)
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)
{
&& 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"),
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
{
r++;
}
else
{
+ char str[FMT_STRING_LEN_MAX + 1];
tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF,
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,
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++;
}
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)
double x, y;
mv_pop_range (&mv, &x, &y);
if (x == LOWEST)
- cp +=
n
sprintf (cp, "LOWEST THRU %g", y);
+ cp += sprintf (cp, "LOWEST THRU %g", y);
else if (y == HIGHEST)
else if (y == HIGHEST)
- cp +=
n
sprintf (cp, "%g THRU HIGHEST", x);
+ cp += sprintf (cp, "%g THRU HIGHEST", x);
else
else
- cp +=
n
sprintf (cp, "%g THRU %g", x, y);
+ cp += sprintf (cp, "%g THRU %g", x, y);
cnt++;
}
while (mv_has_value (&mv))
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)
union value value;
mv_pop_value (&mv, &value);
if (cnt++ > 0)
- cp +=
n
sprintf (cp, "; ");
+ cp += sprintf (cp, "; ");
if (v->type == NUMERIC)
if (v->type == NUMERIC)
- cp +=
n
sprintf (cp, "%g", value.f);
+ cp += sprintf (cp, "%g", value.f);
else
{
*cp++ = '"';
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 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;
{
const struct vector **vl;
int i;
struct tab_table *t;
size_t nvec;
- nvec = dict_get_vector_cnt (d
efault_d
ict);
+ nvec = dict_get_vector_cnt (dict);
if (nvec == 0)
{
msg (SW, _("No vectors defined."));
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 = xnmalloc (nvec, sizeof *vl);
for (i = 0; i < nvec; i++)
- vl[i] = dict_get_vector (d
efault_d
ict, i);
+ vl[i] = dict_get_vector (dict, i);
if (sorted)
qsort (vl, nvec, sizeof *vl, compare_vectors_by_name);
if (sorted)
qsort (vl, nvec, sizeof *vl, compare_vectors_by_name);