#include "data/casereader-provider.h"
#include "data/casereader-shim.h"
#include "data/casewriter.h"
+#include "data/control-stack.h"
#include "data/dictionary.h"
#include "data/file-handle-def.h"
#include "data/session.h"
dataset_clear (ds);
dict_destroy (ds->dict);
caseinit_destroy (ds->caseinit);
+ ctl_stack_clear ();
trns_chain_destroy (ds->permanent_trns_chain);
dataset_transformations_changed__ (ds, false);
free (ds->name);
add_case_limit_trns (ds);
if (filter)
add_filter_trns (ds);
- trns_chain_finalize (ds->cur_trns_chain);
+ ctl_stack_clear ();
/* Make permanent_dict refer to the dictionary right before
data reaches the sink. */
ds->permanent_dict = dict_clone (ds->dict);
- trns_chain_finalize (ds->permanent_trns_chain);
+ ctl_stack_clear ();
ds->temporary_trns_chain = ds->cur_trns_chain = trns_chain_create ();
dataset_transformations_changed__ (ds, true);
}
{
if (proc_in_temporary_transformations (ds))
{
- trns_chain_finalize (ds->temporary_trns_chain);
+ ctl_stack_clear ();
trns_chain_splice (ds->permanent_trns_chain, ds->temporary_trns_chain);
ds->temporary_trns_chain = NULL;
ds->dict = ds->permanent_dict;
ds->permanent_dict = NULL;
+ ctl_stack_clear ();
trns_chain_destroy (ds->temporary_trns_chain);
ds->temporary_trns_chain = NULL;
dataset_transformations_changed__ (
{
bool ok;
assert (ds->proc_state == PROC_COMMITTED);
+ ctl_stack_clear ();
ok = trns_chain_destroy (ds->permanent_trns_chain);
ok = trns_chain_destroy (ds->temporary_trns_chain) && ok;
ds->permanent_trns_chain = ds->cur_trns_chain = trns_chain_create ();
struct transformation *trns; /* Array of transformations. */
size_t trns_cnt; /* Number of transformations. */
size_t trns_cap; /* Allocated capacity. */
- bool finalized; /* Finalize functions called? */
};
/* Allocates and returns a new transformation chain. */
chain->trns = NULL;
chain->trns_cnt = 0;
chain->trns_cap = 0;
- chain->finalized = false;
return chain;
}
-/* Finalizes all the un-finalized transformations in CHAIN.
- Any given transformation is only finalized once. */
-void
-trns_chain_finalize (struct trns_chain *chain)
-{
- while (!chain->finalized)
- {
- ctl_stack_clear (); /* XXX layering violation */
- chain->finalized = true;
- }
-}
-
-/* Destroys CHAIN, finalizing it in the process if it has not
- already been finalized. */
+/* Destroys CHAIN. */
bool
trns_chain_destroy (struct trns_chain *chain)
{
{
size_t i;
- /* Needed to ensure that the control stack gets cleared. */
- trns_chain_finalize (chain);
-
for (i = 0; i < chain->trns_cnt; i++)
{
struct transformation *trns = &chain->trns[i];
{
struct transformation *trns;
- chain->finalized = false;
-
if (chain->trns_cnt == chain->trns_cap)
chain->trns = x2nrealloc (chain->trns, &chain->trns_cap,
sizeof *chain->trns);
trns->aux = aux;
}
-/* Appends the transformations in SRC to those in DST,
- and destroys SRC.
- Both DST and SRC must already be finalized. */
+/* Appends the transformations in SRC to those in DST, and destroys SRC. */
void
trns_chain_splice (struct trns_chain *dst, struct trns_chain *src)
{
size_t i;
- assert (dst->finalized);
- assert (src->finalized);
-
if (dst->trns_cnt + src->trns_cnt > dst->trns_cap)
{
dst->trns_cap = dst->trns_cnt + src->trns_cnt;
{
int i;
- assert (chain->finalized);
for (i = start < 0 ? 0 : start; i < chain->trns_cnt; )
{
struct transformation *trns = &chain->trns[i];
/* Transformation chains. */
struct trns_chain *trns_chain_create (void);
-void trns_chain_finalize (struct trns_chain *);
bool trns_chain_destroy (struct trns_chain *);
bool trns_chain_is_empty (const struct trns_chain *);
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2012, 2013, 2015 Free Software Foundation, Inc.
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
#include "data/case.h"
#include "data/caseinit.h"
#include "data/casereader-provider.h"
+#include "data/control-stack.h"
#include "data/dataset.h"
#include "data/dictionary.h"
#include "data/session.h"
return CMD_FAILURE;
}
- inp->trns_chain = proc_capture_transformations (inp->ds);
- trns_chain_finalize (inp->trns_chain);
+ ctl_stack_clear ();
+ inp->trns_chain = proc_capture_transformations (ds);
inp->restart = TRNS_CONTINUE;
if (pgm != NULL)
{
session_destroy (pgm->session);
+ ctl_stack_clear ();
trns_chain_destroy (pgm->trns_chain);
caseinit_destroy (pgm->init);
caseproto_unref (pgm->proto);