1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 #include "range-prs.h"
33 #define _(msgid) gettext (msgid)
35 #include "debug-print.h"
38 cmd_missing_values (void)
43 int retval = CMD_PART_SUCCESS_MAYBE;
44 bool deferred_errors = false;
50 if (!parse_variables (default_dict, &v, &nv, PV_NONE))
55 lex_error (_("expecting `('"));
59 for (i = 0; i < nv; i++)
60 mv_init (&v[i]->miss, v[i]->width);
64 struct missing_values mv;
66 for (i = 0; i < nv; i++)
67 if (v[i]->type != v[0]->type)
69 const struct variable *n = v[0]->type == NUMERIC ? v[0] : v[i];
70 const struct variable *s = v[0]->type == NUMERIC ? v[i] : v[0];
71 msg (SE, _("Cannot mix numeric variables (e.g. %s) and "
72 "string variables (e.g. %s) within a single list."),
77 if (v[0]->type == NUMERIC)
80 while (!lex_match (')'))
85 if (!parse_num_range (&x, &y, &v[0]->print))
90 : mv_add_num_range (&mv, x, y));
92 deferred_errors = true;
99 mv_init (&mv, MAX_SHORT_STRING);
100 while (!lex_match (')'))
102 if (!lex_force_string ())
104 deferred_errors = true;
108 if (ds_length (&tokstr) > MAX_SHORT_STRING)
110 ds_truncate (&tokstr, MAX_SHORT_STRING);
111 msg (SE, _("Truncating missing value to short string "
112 "length (%d characters)."),
116 ds_rpad (&tokstr, MAX_SHORT_STRING, ' ');
118 if (!mv_add_str (&mv, ds_data (&tokstr)))
119 deferred_errors = true;
126 for (i = 0; i < nv; i++)
128 if (!mv_is_resizable (&mv, v[i]->width))
130 msg (SE, _("Missing values provided are too long to assign "
131 "to variable of width %d."),
133 deferred_errors = true;
137 mv_copy (&v[i]->miss, &mv);
138 mv_resize (&v[i]->miss, v[i]->width);
147 retval = lex_end_of_command ();
152 retval = CMD_PART_SUCCESS_MAYBE;