#include <output/output.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
static struct pool *pl_tc; /* For table cells. */
static struct pool *pl_col; /* For column data. */
-static int internal_cmd_crosstabs (struct dataset *ds);
+static int internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds);
static void precalc (const struct ccase *, void *, const struct dataset *);
static bool calc_general (const struct ccase *, void *, const struct dataset *);
static bool calc_integer (const struct ccase *, void *, const struct dataset *);
/* Parse and execute CROSSTABS, then clean up. */
int
-cmd_crosstabs (struct dataset *ds)
+cmd_crosstabs (struct lexer *lexer, struct dataset *ds)
{
- int result = internal_cmd_crosstabs (ds);
+ int result = internal_cmd_crosstabs (lexer, ds);
free (variables);
pool_destroy (pl_tc);
/* Parses and executes the CROSSTABS procedure. */
static int
-internal_cmd_crosstabs (struct dataset *ds)
+internal_cmd_crosstabs (struct lexer *lexer, struct dataset *ds)
{
int i;
bool ok;
pl_tc = pool_create ();
pl_col = pool_create ();
- if (!parse_crosstabs (ds, &cmd, NULL))
+ if (!parse_crosstabs (lexer, ds, &cmd, NULL))
return CMD_FAILURE;
mode = variables ? INTEGER : GENERAL;
/* Parses the TABLES subcommand. */
static int
-crs_custom_tables (struct dataset *ds, struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
+crs_custom_tables (struct lexer *lexer, struct dataset *ds, struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
{
struct var_set *var_set;
int n_by;
int success = 0;
/* Ensure that this is a TABLES subcommand. */
- if (!lex_match_id ("TABLES")
- && (token != T_ID || dict_lookup_var (dataset_dict (ds), tokid) == NULL)
- && token != T_ALL)
+ if (!lex_match_id (lexer, "TABLES")
+ && (lex_token (lexer) != T_ID || dict_lookup_var (dataset_dict (ds), lex_tokid (lexer)) == NULL)
+ && lex_token (lexer) != T_ALL)
return 2;
- lex_match ('=');
+ lex_match (lexer, '=');
if (variables != NULL)
var_set = var_set_create_from_array (variables, variables_cnt);
{
by = xnrealloc (by, n_by + 1, sizeof *by);
by_nvar = xnrealloc (by_nvar, n_by + 1, sizeof *by_nvar);
- if (!parse_var_set_vars (var_set, &by[n_by], &by_nvar[n_by],
+ if (!parse_var_set_vars (lexer, var_set, &by[n_by], &by_nvar[n_by],
PV_NO_DUPLICATE | PV_NO_SCRATCH))
goto done;
if (xalloc_oversized (nx, by_nvar[n_by]))
nx *= by_nvar[n_by];
n_by++;
- if (!lex_match (T_BY))
+ if (!lex_match (lexer, T_BY))
{
if (n_by < 2)
{
- lex_error (_("expecting BY"));
+ lex_error (lexer, _("expecting BY"));
goto done;
}
else
/* Parses the VARIABLES subcommand. */
static int
-crs_custom_variables (struct dataset *ds, struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
+crs_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
{
if (nxtab)
{
return 0;
}
- lex_match ('=');
+ lex_match (lexer, '=');
for (;;)
{
long min, max;
- if (!parse_variables (dataset_dict (ds), &variables, &variables_cnt,
+ if (!parse_variables (lexer, dataset_dict (ds),
+ &variables, &variables_cnt,
(PV_APPEND | PV_NUMERIC
| PV_NO_DUPLICATE | PV_NO_SCRATCH)))
return 0;
- if (token != '(')
+ if (lex_token (lexer) != '(')
{
- lex_error ("expecting `('");
+ lex_error (lexer, "expecting `('");
goto lossage;
}
- lex_get ();
+ lex_get (lexer);
- if (!lex_force_int ())
+ if (!lex_force_int (lexer))
goto lossage;
- min = lex_integer ();
- lex_get ();
+ min = lex_integer (lexer);
+ lex_get (lexer);
- lex_match (',');
+ lex_match (lexer, ',');
- if (!lex_force_int ())
+ if (!lex_force_int (lexer))
goto lossage;
- max = lex_integer ();
+ max = lex_integer (lexer);
if (max < min)
{
msg (SE, _("Maximum value (%ld) less than minimum value (%ld)."),
max, min);
goto lossage;
}
- lex_get ();
+ lex_get (lexer);
- if (token != ')')
+ if (lex_token (lexer) != ')')
{
- lex_error ("expecting `)'");
+ lex_error (lexer, "expecting `)'");
goto lossage;
}
- lex_get ();
+ lex_get (lexer);
for (i = orig_nv; i < variables_cnt; i++)
{
var_attach_aux (variables[i], vr, var_dtor_free);
}
- if (token == '/')
+ if (lex_token (lexer) == '/')
break;
}
/* Allocate table space for the matrix. */
if (table && tab_row (table) + (n_rows + 1) * num_cells > tab_nr (table))
tab_realloc (table, -1,
- max (tab_nr (table) + (n_rows + 1) * num_cells,
+ MAX (tab_nr (table) + (n_rows + 1) * num_cells,
tab_nr (table) * (pe - pb) / (te - tb)));
if (mode == GENERAL)
{
int x;
- if (min (c, d) < min (a, b))
+ if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
- if (min (b, d) < min (a, c))
+ if (MIN (b, d) < MIN (a, c))
swap (&a, &b), swap (&c, &d);
if (b * c < a * d)
{
calc_symmetric (double v[N_SYMMETRIC], double ase[N_SYMMETRIC],
double t[N_SYMMETRIC])
{
- int q = min (ns_rows, ns_cols);
+ int q = MIN (ns_rows, ns_cols);
if (q <= 1)
return 0;
assert (fmt_subst.type == FMT_A || fmt_subst.type == FMT_AHEX);
if (fmt_subst.type == FMT_A)
- fmt_subst.w = min (8, fmt_subst.w);
+ fmt_subst.w = MIN (8, fmt_subst.w);
else
- fmt_subst.w = min (16, fmt_subst.w);
+ fmt_subst.w = MIN (16, fmt_subst.w);
fp = &fmt_subst;
}