X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmeans.q;h=887cbfd8525d1cabdae9395d5db421cdf8b32c1b;hb=4a73877b4d56caed03d383fb4d38347a9774046f;hp=483b6dc6d45a1f3b5e9888e81672349e91395f40;hpb=06f9ee45954e5e71fa7f6262dbf37defa1dbf996;p=pspp-builds.git diff --git a/src/means.q b/src/means.q index 483b6dc6..887cbfd8 100644 --- a/src/means.q +++ b/src/means.q @@ -14,12 +14,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include #include +#include "dictionary.h" #include "error.h" #include "alloc.h" #include "command.h" @@ -28,6 +29,10 @@ #include "error.h" #include "magic.h" #include "var.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* (headers) */ #include "debug-print.h" @@ -35,8 +40,6 @@ /* (specification) means (mns_): *tables=custom; - +variables=custom; - +crossbreak=custom; +format=lab:!labels/nolabels/nocatlabs, name:!names/nonames, val:!values/novalues, @@ -50,7 +53,7 @@ /* TABLES: Variable lists for each dimension. */ int n_dim; /* Number of dimensions. */ -int *nv_dim; /* Number of variables in each dimension. */ +size_t *nv_dim; /* Number of variables in each dimension. */ struct variable ***v_dim; /* Variables in each dimension. */ /* VARIABLES: List of variables. */ @@ -130,22 +133,19 @@ mns_custom_tables (struct cmd_means *cmd) return 2; lex_match ('='); - if (cmd->sbc_tables || cmd->sbc_crossbreak) + if (cmd->sbc_tables) { - msg (SE, _("TABLES or CROSSBREAK subcommand may not appear more " + msg (SE, _("TABLES subcommand may not appear more " "than once.")); return 0; } - if (cmd->sbc_variables) - var_set = var_set_create_from_array (v_var, n_var); - else - var_set = var_set_create_from_dict (default_dict); + var_set = var_set_create_from_dict (default_dict); assert (var_set != NULL); do { - int nvl; + size_t nvl; struct variable **vl; if (!parse_var_set_vars (var_set, &vl, &nvl, @@ -153,53 +153,11 @@ mns_custom_tables (struct cmd_means *cmd) goto lossage; n_dim++; - nv_dim = xrealloc (nv_dim, n_dim * sizeof (int)); - v_dim = xrealloc (v_dim, n_dim * sizeof (struct variable **)); + nv_dim = xnrealloc (nv_dim, n_dim, sizeof *nv_dim); + v_dim = xnrealloc (v_dim, n_dim, sizeof *v_dim); nv_dim[n_dim - 1] = nvl; v_dim[n_dim - 1] = vl; - - if (cmd->sbc_variables) - { - int i; - - for (i = 0; i < nv_dim[0]; i++) - { - struct means_proc *v_inf = &v_dim[0][i]->p.mns; - - if (v_inf->min == SYSMIS) - { - msg (SE, _("Variable %s specified on TABLES or " - "CROSSBREAK, but not specified on " - "VARIABLES."), - v_dim[0][i]->name); - goto lossage; - } - - if (n_dim == 1) - { - v_inf->min = (int) v_inf->min; - v_inf->max = (int) v_inf->max; - } else { - if (v_inf->min == LOWEST || v_inf->max == HIGHEST) - { - msg (SE, _("LOWEST and HIGHEST may not be used " - "for independent variables (%s)."), - v_dim[0][i]->name); - goto lossage; - } - if (v_inf->min != (int) v_inf->min - || v_inf->max != (int) v_inf->max) - { - msg (SE, _("Independent variables (%s) may not " - "have noninteger endpoints in their " - "ranges."), - v_dim[0][i]->name); - goto lossage; - } - } - } - } } while (lex_match (T_BY)); @@ -211,98 +169,6 @@ mns_custom_tables (struct cmd_means *cmd) return 0; } -/* Parse CROSSBREAK subcommand. */ -static int -mns_custom_crossbreak (struct cmd_means *cmd) -{ - return mns_custom_tables (cmd); -} - -/* Parses the VARIABLES subcommand. */ -static int -mns_custom_variables (struct cmd_means *cmd) -{ - if (cmd->sbc_tables) - { - msg (SE, _("VARIABLES must precede TABLES.")); - return 0; - } - - if (cmd->sbc_variables == 1) - { - int i; - - for (i = 0; i < dict_get_var_cnt (default_dict); i++) - dict_get_var (default_dict, i)->p.mns.min = SYSMIS; - } - - do - { - int orig_n = n_var; - - double min, max; - - if (!parse_variables (default_dict, &v_var, &n_var, - PV_APPEND | PV_NO_DUPLICATE | PV_NO_SCRATCH)) - return 0; - - if (!lex_force_match ('(')) - return 0; - - /* Lower value. */ - if (token == T_ID - && (!strcmp (tokid, "LO") || lex_id_match ("LOWEST", tokid))) - min = LOWEST; - else - { - if (!lex_force_num ()) - return 0; - min = tokval; - } - lex_get (); - - lex_match (','); - - /* Higher value. */ - if (token == T_ID - && (!strcmp (tokid, "HI") || lex_id_match ("HIGHEST", tokid))) - max = HIGHEST; - else - { - if (!lex_force_num ()) - return 0; - max = tokval; - } - lex_get (); - - if (!lex_force_match (')')) - return 0; - - /* Range check. */ - if (max < min) - { - msg (SE, _("Upper value (%g) is less than lower value " - "(%g) on VARIABLES subcommand."), max, min); - return 0; - } - - { - int i; - - for (i = orig_n; i < n_var; i++) - { - struct means_proc *v_inf = &v_var[i]->p.mns; - - v_inf->min = min; - v_inf->max = max; - } - } - } - while (token != '/' && token != '.'); - - return 1; -} - /* Local Variables: mode: c