/* PSPP - computes sample statistics.
Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include <libpspp/str.h>
#include "intprops.h"
+#include "minmax.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
flip = pool_create_container (struct flip_pgm, pool);
flip->var = NULL;
- flip->idx_to_fv = dict_get_compacted_idx_to_fv (dict);
+ flip->idx_to_fv = dict_get_compacted_dict_index_to_case_index (dict);
pool_register (flip->pool, free, flip->idx_to_fv);
flip->var_cnt = 0;
flip->case_cnt = 0;
for (i = 1; i < 10000000; i++)
{
- int ofs = min (7 - intlog10 (i), len);
+ int ofs = MIN (7 - intlog10 (i), len);
memcpy (n, name, ofs);
sprintf (&n[ofs], "%d", i);
/* Write variable names as first case. */
for (i = 0; i < flip->var_cnt; i++)
buf_copy_str_rpad (flip->output_buf[i].s, MAX_SHORT_STRING,
- flip->var[i]->name);
+ var_get_name (flip->var[i]));
if (fwrite (flip->output_buf, sizeof *flip->output_buf,
flip->var_cnt, flip->file) != (size_t) flip->var_cnt)
{
if (flip->new_names != NULL)
{
struct varname *v = pool_alloc (flip->pool, sizeof *v);
+ int fv = flip->idx_to_fv[var_get_dict_index (flip->new_names)];
v->next = NULL;
- if (flip->new_names->type == NUMERIC)
+ if (var_is_numeric (flip->new_names))
{
- double f = case_num (c, flip->idx_to_fv[flip->new_names->index]);
+ double f = case_num_idx (c, fv);
if (f == SYSMIS)
strcpy (v->name, "VSYSMIS");
}
else
{
- int width = min (flip->new_names->width, MAX_SHORT_STRING);
- memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]),
- width);
+ int width = MIN (var_get_width (flip->new_names), MAX_SHORT_STRING);
+ memcpy (v->name, case_str_idx (c, fv), width);
v->name[width] = 0;
}
{
double out;
- if (flip->var[i]->type == NUMERIC)
- out = case_num (c, flip->idx_to_fv[flip->var[i]->index]);
+ if (var_is_numeric (flip->var[i]))
+ {
+ int fv = flip->idx_to_fv[var_get_dict_index (flip->var[i])];
+ out = case_num_idx (c, fv);
+ }
else
out = SYSMIS;
flip->output_buf[i].f = out;
for (case_idx = 0; case_idx < flip->case_cnt; )
{
- unsigned long read_cases = min (flip->case_cnt - case_idx,
+ unsigned long read_cases = MIN (flip->case_cnt - case_idx,
case_capacity);
size_t i;
}
for (j = 0; j < flip->case_cnt; j++)
- case_data_rw (c, j)->f = input_buf[j].f;
+ case_data_rw_idx (c, j)->f = input_buf[j].f;
ok = write_case (wc_data);
}
free (input_buf);