New functions dict_create_var_assert(), dict_lookup_var_assert().
+Sun Feb 15 23:14:59 2004 Ben Pfaff <blp@gnu.org>
+
+ New functions dict_create_var_assert(), dict_lookup_var_assert().
+ Converted several dict_*_var()/assert pairs into a single
+ dict_*_var_assert().
+
+ * dictionary.c: (dict_create_var_assert) New function.
+ (dict_lookup_var_assert) New function.
+
+Sun Feb 15 23:06:08 2004 Ben Pfaff <blp@gnu.org>
+
+ Got rid of "struct long_vec", envector(), devector(), etc. Added
+ two members `init', `reinit' to struct variable as a substitute.
+
+ * Makefile.am: (pspp_SOURCES) Removed cases.c, cases.h.
+
+ * cases.c: Removed.
+
+ * cases.h: Removed.
+
+ * aggregate.c: (parse_aggregate_functions) destvar doesn't need
+ init.
+
+ * autorecode.c: (cmd_autorecode) destvars don't need init.
+
+ * compute.c: (lvalue_finalize) Set reinit.
+
+ * data-list.c: (fixed_parse_compatible) Don't need init usually.
+ (dump_fmt_list) Ditto.
+ (parse_free) Ditto.
+
+ * descript.q: (run_z_pass) Don't need init for z-scores.
+
+ * dictionary.c: (dict_create_var) Initialize `init', `reinit'
+ members.
+ (dict_clone_var) Copy `reinit' member, initialize `init' member.
+
+ * glob.c: (init_glob) Remove vec_init() calls.
+
+ * inpt-pgm.c: (cmd_end_input_program) Use `reinit', not `left'.
+
+ * loop.c: (internal_cmd_loop) Don't need to call envector().
+
+ * numeric.c: (cmd_numeric) Ditto.
+ (cmd_string) Ditto.
+ (cmd_leave) Ditto. Set `init', `reinit' members.
+
+ * recode.c: (cmd_recode) Don't need to call envector().
+
+ * repeat.c: (internal_cmd_do_repeat) Ditto.
+
+ * var.h: (struct variable) Remove `left'. Add `init', `reinit'.
+ (force_create_variable) Removed prototype.
+ (force_dup_variable) Ditto.
+
+ * vector.c: (cmd_vector) Don't need to call envector().
+
+ * vfm.c: (reinit_sysmis) Removed.
+ (reinit_blanks) Removed.
+ (init_zero) Removed.
+ (init_blanks) Removed.
+ (process_active_file_write_case) No need to deal with vectors.
+ Call clear_temp_case().
+ (vector_initialization) Rewrite to use `init', `reinit'.
+ (close_active_file) No need to call vec_clear().
+ (procedure_write_case) Call clear_temp_case().
+ (clear_temp_case) New function.
+
Sun Feb 15 20:50:36 2004 Ben Pfaff <blp@gnu.org>
* pfm-write.c: (bufwrite) Get rid of nasty cast that also invoked
pspp_SOURCES = $(q_sources_c) \
aggregate.c algorithm.c algorithm.h alloc.c alloc.h \
-apply-dict.c approx.h ascii.c autorecode.c bitvector.h cases.c cases.h \
+apply-dict.c approx.h ascii.c autorecode.c bitvector.h \
cmdline.c cmdline.h command.c command.def command.h compute.c \
count.c data-in.c data-in.h data-list.c \
data-out.c debug-print.h devind.c devind.h dfm.c dfm.h \
}
free (dest[i]);
+ destvar->init = 0;
if (dest_label[i])
{
destvar->label = dest_label[i];
for (i = 0; i < nv_dest; i++)
{
- v_dest[i] = dict_create_var (default_dict, n_dest[i], 0);
- assert (v_dest[i] != NULL);
+ v_dest[i] = dict_create_var_assert (default_dict, n_dest[i], 0);
+ v_dest[i]->init = 0;
free (n_dest[i]);
}
free (n_dest);
+++ /dev/null
-/* 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
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- 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. */
-
-#include <config.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "alloc.h"
-#include "cases.h"
-#include "var.h"
-#include "vfm.h"
-
-#include "debug-print.h"
-
-/* Initializes V. */
-void
-vec_init (struct long_vec * v)
-{
- v->vec = NULL;
- v->n = v->m = 0;
-}
-
-/* Deletes the contents of V. */
-void
-vec_clear (struct long_vec * v)
-{
- free (v->vec);
- v->vec = NULL;
- v->n = v->m = 0;
-}
-
-/* Inserts ELEM into V. */
-void
-vec_insert (struct long_vec * v, long elem)
-{
- if (v->n >= v->m)
- {
- v->m = (v->m == 0 ? 16 : 2 * v->m);
- v->vec = xrealloc (v->vec, v->m * sizeof *v->vec);
- }
- v->vec[v->n++] = elem;
-}
-
-/* Deletes all occurrences of values A through B exclusive from V. */
-void
-vec_delete (struct long_vec * v, long a, long b)
-{
- int i;
-
- for (i = v->n - 1; i >= 0; i--)
- if (v->vec[i] >= a && v->vec[i] < b)
- v->vec[i] = v->vec[--v->n];
-}
-
-/* Sticks V->FV in the proper vector. */
-void
-envector (const struct variable *v)
-{
- if (v->type == NUMERIC)
- {
- if (v->left)
- vec_insert (&init_zero, v->fv);
- else
- vec_insert (&reinit_sysmis, v->fv);
- }
- else
- {
- int i;
-
- if (v->left)
- for (i = v->fv; i < v->fv + v->nv; i++)
- vec_insert (&init_blanks, i);
- else
- for (i = v->fv; i < v->fv + v->nv; i++)
- vec_insert (&reinit_blanks, i);
- }
-}
-
-/* Removes V->FV from the proper vector. */
-void
-devector (const struct variable *v)
-{
- if (v->type == NUMERIC)
- {
- if (v->left)
- vec_delete (&init_zero, v->fv, v->fv + 1);
- else
- vec_delete (&reinit_sysmis, v->fv, v->fv + 1);
- }
- else if (v->left)
- vec_delete (&init_blanks, v->fv, v->fv + v->nv);
- else
- vec_delete (&reinit_blanks, v->fv, v->fv + v->nv);
-}
+++ /dev/null
-/* 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
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- 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. */
-
-#if !cases_h
-#define cases_h 1
-
-/* Vectors. */
-
-/* A vector of longs. */
-struct long_vec
- {
- long *vec; /* Contents. */
- int n; /* Number of elements. */
- int m; /* Number of elements room is allocated for. */
- };
-
-struct variable;
-
-void vec_init (struct long_vec *);
-void vec_clear (struct long_vec *);
-void vec_insert (struct long_vec *, long);
-void vec_delete (struct long_vec *, long a, long b);
-void devector (const struct variable *);
-void envector (const struct variable *);
-
-#endif /* !cases_h */
#include <stdlib.h>
#include "alloc.h"
#include "approx.h"
-#include "cases.h"
#include "command.h"
#include "error.h"
#include "expr.h"
{
compute->variable = dict_lookup_var (default_dict, lvalue->var_name);
if (compute->variable == NULL)
- compute->variable = dict_create_var (default_dict, lvalue->var_name,
- 0);
- assert (compute->variable != NULL);
-
+ compute->variable = dict_create_var_assert (default_dict,
+ lvalue->var_name, 0);
compute->fv = compute->variable->fv;
compute->width = compute->variable->width;
/* Goofy behavior, but compatible: Turn off LEAVE. */
- if (compute->variable->left
- && dict_class_from_id (compute->variable->name) != DC_SCRATCH)
- {
- devector (compute->variable);
- compute->variable->left = 0;
- envector (compute->variable);
- }
+ if (dict_class_from_id (compute->variable->name) != DC_SCRATCH)
+ compute->variable->reinit = 1;
}
else
{
the same dest var more than once. */
cnt->d = dict_lookup_var (default_dict, cnt->n);
- if (!cnt->d)
- {
- cnt->d = dict_create_var (default_dict, cnt->n, 0);
- assert (cnt->d != NULL);
- }
+ if (cnt->d == NULL)
+ cnt->d = dict_create_var_assert (default_dict, cnt->n, 0);
}
#if DEBUGGING
return CMD_FAILURE;
dls.end = dict_lookup_var (default_dict, tokid);
if (!dls.end)
- {
- dls.end = dict_create_var (default_dict, tokid, 0);
- assert (dls.end != NULL);
- }
+ dls.end = dict_create_var_assert (default_dict, tokid, 0);
lex_get ();
}
else if (token == T_ID)
{
convert_fmt_ItoO (&fx.spec.input, &v->print);
v->write = v->print;
+ if (vfm_source != &input_program_source
+ && vfm_source != &file_type_source)
+ v->init = 0;
}
else
{
- v = dict_lookup_var (default_dict, fx.name[i]);
- assert (v != NULL);
+ v = dict_lookup_var_assert (default_dict, fx.name[i]);
if (!vfm_source)
{
msg (SE, _("%s is a duplicate variable name."), fx.name[i]);
return 0;
}
+ if (vfm_source != &input_program_source
+ && vfm_source != &file_type_source)
+ v->init = 0;
+
fx.spec.input = f->f;
convert_fmt_ItoO (&fx.spec.input, &v->print);
v->write = v->print;
v->print = v->write = out;
+ if (vfm_source != &input_program_source
+ && vfm_source != &file_type_source)
+ v->init = 0;
+
strcpy (spec.name, name[i]);
spec.fv = v->fv;
spec.width = width;
struct variable *d;
t->z[count].s = v;
- t->z[count].d = d = dict_create_var (default_dict,
- v->p.dsc.zname, 0);
- assert (d != NULL);
+ t->z[count].d = d = dict_create_var_assert (default_dict,
+ v->p.dsc.zname, 0);
+ d->init = 0;
if (v->label)
{
d->label = xmalloc (strlen (v->label) + 12);
{
d->split = xmalloc (d->split_cnt * sizeof *d->split);
for (i = 0; i < d->split_cnt; i++)
- {
- d->split[i] = dict_lookup_var (d, s->split[i]->name);
- assert (d->split[i] != NULL);
- }
+ d->split[i] = dict_lookup_var_assert (d, s->split[i]->name);
}
if (s->weight != NULL)
- {
- d->weight = dict_lookup_var (d, s->weight->name);
- assert (d->weight != NULL);
- }
+ d->weight = dict_lookup_var_assert (d, s->weight->name);
if (s->filter != NULL)
- {
- d->filter = dict_lookup_var (d, s->filter->name);
- assert (d->filter != NULL);
- }
+ d->filter = dict_lookup_var_assert (d, s->filter->name);
d->case_limit = s->case_limit;
dict_set_label (d, dict_get_label (s));
v->width = width;
v->fv = d->value_cnt;
v->nv = width == 0 ? 1 : DIV_RND_UP (width, 8);
- v->left = name[0] == '#';
+ v->init = 1;
+ v->reinit = name[0] != '#';
v->miss_type = MISSING_NONE;
if (v->type == NUMERIC)
{
return v;
}
+struct variable *
+dict_create_var_assert (struct dictionary *d, const char *name, int width)
+{
+ struct variable *v = dict_create_var (d, name, width);
+ assert (v != NULL);
+ return v;
+}
+
struct variable *
dict_clone_var (struct dictionary *d, const struct variable *ov,
const char *name)
if (nv == NULL)
return NULL;
- nv->left = ov->left;
+ nv->init = 1;
+ nv->reinit = ov->reinit;
nv->miss_type = ov->miss_type;
memcpy (nv->missing, ov->missing, sizeof nv->missing);
nv->print = ov->print;
return hsh_find (d->name_tab, &v);
}
+struct variable *
+dict_lookup_var_assert (const struct dictionary *d, const char *name)
+{
+ struct variable *v = dict_lookup_var (d, name);
+ assert (v != NULL);
+ return v;
+}
+
int
dict_contains_var (const struct dictionary *d, const struct variable *v)
{
static int
build_dictionary (void)
{
- if (!dict_create_var (default_dict, "CASE_LBL", 8))
- assert (0);
+ dict_create_var_assert (default_dict, "CASE_LBL", 8);
if (!new_names_tail)
{
char s[9];
sprintf (s, "VAR%03d", i);
- v = dict_create_var (default_dict, s, 0);
- assert (v != NULL);
+ v = dict_create_var_assert (default_dict, s, 0);
}
}
else
/* var.h */
default_dict = dict_create ();
- vec_init (&reinit_sysmis);
- vec_init (&reinit_blanks);
- vec_init (&init_zero);
- vec_init (&init_blanks);
-
last_vfm_invocation = time (NULL);
/* lexer.h */
size_t j;
value_init = var->type == NUMERIC ? INP_NUMERIC : INP_STRING;
- value_init |= var->left ? INP_INIT_ONCE : INP_REINIT;
+ value_init |= var->reinit ? INP_REINIT : INP_INIT_ONCE;
for (j = 0; j < var->nv; j++)
inp_init[j + var->fv] = value_init;
{
two->index = dict_lookup_var (default_dict, name);
if (!two->index)
- {
- two->index = dict_create_var (default_dict, name, 0);
-#if DEBUGGING
- envector (two->index);
-#endif
- }
+ two->index = dict_create_var (default_dict, name, 0);
}
/* Push on control stack. */
if (strcmp (v[i], "ROWTYPE_"))
{
- new_var = dict_create_var (default_dict, v[i], 0);
- assert (new_var != NULL);
+ new_var = dict_create_var_assert (default_dict, v[i], 0);
new_var->p.mxd.vartype = MXD_CONTINUOUS;
new_var->p.mxd.subtype = i;
}
}
{
- rowtype_ = dict_create_var (default_dict, "ROWTYPE_", 8);
- assert (rowtype_ != NULL);
+ rowtype_ = dict_create_var_assert (default_dict, "ROWTYPE_", 8);
rowtype_->p.mxd.vartype = MXD_ROWTYPE;
rowtype_->p.mxd.subtype = 0;
}
goto lossage;
}
- single_split = dict_create_var (default_dict, tokid, 0);
- assert (single_split != NULL);
+ single_split = dict_create_var_assert (default_dict, tokid, 0);
lex_get ();
single_split->p.mxd.vartype = MXD_CONTINUOUS;
/* Create VARNAME_. */
{
- varname_ = dict_create_var (default_dict, "VARNAME_", 8);
- assert (varname_ != NULL);
+ varname_ = dict_create_var_assert (default_dict, "VARNAME_", 8);
varname_->p.mxd.vartype = MXD_VARNAME;
varname_->p.mxd.subtype = 0;
}
#include <config.h>
#include <assert.h>
#include <stdlib.h>
-#include "cases.h"
#include "command.h"
#include "error.h"
#include "lexer.h"
{
if (f.type != -1)
new_var->print = new_var->write = f;
- envector (new_var);
}
}
if (!new_var)
msg (SE, _("There is already a variable named %s."), v[i]);
else
- {
- new_var->print = new_var->write = f;
- envector (new_var);
- }
+ new_var->print = new_var->write = f;
}
/* Clean up. */
return CMD_FAILURE;
for (i = 0; i < nv; i++)
{
- if (v[i]->left)
+ if (!v[i]->reinit)
continue;
- devector (v[i]);
- v[i]->left = 1;
- envector (v[i]);
+ v[i]->reinit = 0;
+ v[i]->init = 1;
}
free (v);
#include <stdlib.h>
#include "alloc.h"
#include "approx.h"
-#include "cases.h"
#include "command.h"
#include "error.h"
#include "lexer.h"
rcd->dest = dict_create_var (default_dict, rcd->dest_name, 0);
if (!rcd->dest)
{
- /* This can occur if a destname is duplicated. We could
- give an error at parse time but I don't care enough. */
- rcd->dest = dict_lookup_var (default_dict, rcd->dest_name);
- assert (rcd->dest != NULL);
+ /* FIXME: This can occur if a destname is duplicated.
+ We could give an error at parse time but I don't
+ care enough. */
+ rcd->dest = dict_lookup_var_assert (default_dict, rcd->dest_name);
}
- else
- envector (rcd->dest);
}
trns = xmalloc (sizeof *trns);
#include <math.h>
#include <stdlib.h>
#include "alloc.h"
-#include "cases.h"
#include "command.h"
#include "error.h"
#include "getline.h"
{
/* Note that if the variable already exists there is no
harm done. */
- struct variable *v = dict_create_var (default_dict,
- iter->replacement[i],
- 0);
-
- /* If we created the variable then we need to initialize
- its observations to SYSMIS. */
- if (v)
- envector (v);
+ dict_create_var (default_dict, iter->replacement[i], 0);
}
}
}
/* A variable's dictionary entry. Note: don't reorder name[] from the
first element; a pointer to `variable' should be a pointer to
- member `name'.*/
+ member `name'. FIXME: is this comment still accurate? */
struct variable
{
/* Required by parse_variables() to be in this order. */
char name[9]; /* As a string. */
int index; /* Index into its dictionary's var[]. */
- int type; /* NUMERIC or ALPHA. */
+ int type; /* NUMERIC or ALPHA. */
/* Also important but parse_variables() doesn't need it. Still,
check before reordering. */
int width; /* Size of string variables in chars. */
int fv, nv; /* Index into `value's, number of values. */
- int left; /* 0=reinitialize each case, 1=don't. */
+ unsigned init : 1; /* 1=VFM must init and possibly reinit. */
+ unsigned reinit : 1; /* Cases are: 1=reinitialized; 0=left. */
/* Missing values. */
int miss_type; /* One of the MISSING_* constants. */
struct variable *dict_create_var (struct dictionary *, const char *,
int width);
+struct variable *dict_create_var_assert (struct dictionary *, const char *,
+ int width);
struct variable *dict_clone_var (struct dictionary *, const struct variable *,
const char *);
void dict_rename_var (struct dictionary *, struct variable *, const char *);
struct variable *dict_lookup_var (const struct dictionary *, const char *);
+struct variable *dict_lookup_var_assert (const struct dictionary *,
+ const char *);
int dict_contains_var (const struct dictionary *, const struct variable *);
void dict_delete_var (struct dictionary *, struct variable *);
void dict_delete_vars (struct dictionary *,
int is_system_missing (const union value *, const struct variable *);
int is_user_missing (const union value *, const struct variable *);
void copy_missing_values (struct variable *dest, const struct variable *src);
-
-#if GLOBAL_DEBUGGING
-struct variable *force_create_variable (struct dictionary *, const char *name,
- int type, int width);
-struct variable *force_dup_variable (struct dictionary *,
- const struct variable *src,
- const char *name);
-#else
-#define force_create_variable(A, B, C, D) \
- create_variable (A, B, C, D)
-#define force_dup_variable(A, B, C) \
- dup_variable (A, B, C)
-#endif
-
\f
/* Transformations. */
#include <assert.h>
#include <stdlib.h>
#include "alloc.h"
-#include "cases.h"
#include "command.h"
#include "error.h"
#include "lexer.h"
for (i = 0; i < nv; i++)
{
sprintf (name, "%s%d", cp, i + 1);
- v[i] = dict_create_var (default_dict, name, 0);
- assert (v[i] != NULL);
- envector (v[i]);
+ v[i] = dict_create_var_assert (default_dict, name, 0);
}
if (!dict_create_vector (default_dict, cp, v, nv))
assert (0);
/* This is used to read from the active file. */
struct case_stream *vfm_source;
-/* `value' indexes to initialize to particular values for certain cases. */
-struct long_vec reinit_sysmis; /* SYSMIS for every case. */
-struct long_vec reinit_blanks; /* Blanks for every case. */
-struct long_vec init_zero; /* Zero for first case only. */
-struct long_vec init_blanks; /* Blanks for first case only. */
-
/* This is used to write to the replacement active file. */
struct case_stream *vfm_sink;
static void finish_compaction (void);
static void lag_case (void);
static int procedure_write_case (struct write_case_data *);
+static void clear_temp_case (void);
\f
/* Public functions. */
case_count++;
done:
- {
- long *lp;
+ clear_temp_case ();
- /* This case is finished. Initialize the variables for the next case. */
- for (lp = reinit_sysmis.vec; *lp != -1;)
- temp_case->data[*lp++].f = SYSMIS;
- for (lp = reinit_blanks.vec; *lp != -1;)
- memset (temp_case->data[*lp++].s, ' ', MAX_SHORT_STRING);
- }
-
return 1;
}
}
#endif
-/* Initializes temp_case from the vectors that say which `value's need
- to be initialized just once, and which ones need to be
+/* Initializes temp_case from the vectors that say which `value's
+ need to be initialized just once, and which ones need to be
re-initialized before every case. */
static void
vector_initialization (void)
{
- int i;
- long *lp;
-
- /* Just once. */
- for (i = 0; i < init_zero.n; i++)
- temp_case->data[init_zero.vec[i]].f = 0.0;
- for (i = 0; i < init_blanks.n; i++)
- memset (temp_case->data[init_blanks.vec[i]].s, ' ', MAX_SHORT_STRING);
-
- /* These vectors need to be repeatedly accessed, so we add a
- sentinel to (hopefully) improve speed. */
- vec_insert (&reinit_sysmis, -1);
- vec_insert (&reinit_blanks, -1);
-
- for (lp = reinit_sysmis.vec; *lp != -1;)
- temp_case->data[*lp++].f = SYSMIS;
- for (lp = reinit_blanks.vec; *lp != -1;)
- memset (temp_case->data[*lp++].s, ' ', MAX_SHORT_STRING);
+ size_t var_cnt = dict_get_var_cnt (default_dict);
+ size_t i;
-#if DEBUGGING
- printf ("vfm: init_zero=");
- for (i = 0; i < init_zero.n; i++)
- printf ("%s%s", i ? "," : "", index_to_varname (init_zero.vec[i]));
- printf (" init_blanks=");
- for (i = 0; i < init_blanks.n; i++)
- printf ("%s%s", i ? "," : "", index_to_varname (init_blanks.vec[i]));
- printf (" reinit_sysmis=");
- for (lp = reinit_sysmis.vec; *lp != -1; lp++)
- printf ("%s%s", lp != reinit_sysmis.vec ? "," : "",
- index_to_varname (*lp));
- printf (" reinit_blanks=");
- for (lp = reinit_blanks.vec; *lp != -1; lp++)
- printf ("%s%s", lp != reinit_blanks.vec ? "," : "",
- index_to_varname (*lp));
- printf ("\n");
-#endif
+ for (i = 0; i < var_cnt; i++)
+ {
+ struct variable *v = dict_get_var (default_dict, i);
+
+ if (v->type == NUMERIC)
+ {
+ if (v->reinit)
+ temp_case->data[v->fv].f = 0.0;
+ else
+ temp_case->data[v->fv].f = SYSMIS;
+ }
+ else
+ memset (temp_case->data[v->fv].s, ' ', v->width);
+ }
}
/* Sets filter_index to an appropriate value. */
/* Cancel transformations. */
cancel_transformations ();
- /* Clear value-initialization vectors. */
- vec_clear (&init_zero);
- vec_clear (&init_blanks);
- vec_clear (&reinit_sysmis);
- vec_clear (&reinit_blanks);
-
/* Turn off case limiter. */
dict_set_case_limit (default_dict, 0);
done:
debug_putc ('\n', stdout);
-
- {
- long *lp;
- /* This case is finished. Initialize the variables for the next case. */
- for (lp = reinit_sysmis.vec; *lp != -1;)
- temp_case->data[*lp++].f = SYSMIS;
- for (lp = reinit_blanks.vec; *lp != -1;)
- memset (temp_case->data[*lp++].s, ' ', MAX_SHORT_STRING);
- }
+ clear_temp_case ();
/* Return previously determined value. */
return more_cases;
}
+/* Clears the variables in the temporary case that need to be
+ cleared between processing cases. */
+static void
+clear_temp_case (void)
+{
+ /* FIXME? This is linear in the number of variables, but
+ doesn't need to be, so it's an easy optimization target. */
+ size_t var_cnt = dict_get_var_cnt (default_dict);
+ size_t i;
+
+ for (i = 0; i < var_cnt; i++)
+ {
+ struct variable *v = dict_get_var (default_dict, i);
+ if (v->init && v->reinit)
+ {
+ if (v->type == NUMERIC)
+ temp_case->data[v->fv].f = SYSMIS;
+ else
+ memset (temp_case->data[v->fv].s, ' ', v->width);
+ }
+ }
+}
+
/* Appends TRNS to t_trns[], the list of all transformations to be
performed on data as it is read from the active file. */
void
#if !vfm_h
#define vfm_h 1
-#include "cases.h"
#include <time.h>
/* This is the time at which vfm was last invoked. */