#include <data/storage-stream.h>
#include <data/transformations.h>
#include <data/variable.h>
-#include <language/expressions/public.h>
#include <libpspp/alloc.h>
#include <libpspp/misc.h>
#include <libpspp/str.h>
struct write_case_data
{
/* Function to call for each case. */
- bool (*case_func) (struct ccase *, void *); /* Function. */
- void *aux; /* Auxiliary data. */
+ bool (*case_func) (const struct ccase *, void *);
+ void *aux;
struct ccase trns_case; /* Case used for transformations. */
struct ccase sink_case; /* Case written to sink, if
static void add_case_limit_trns (void);
static void add_filter_trns (void);
-static void add_process_if_trns (void);
-static bool internal_procedure (bool (*case_func) (struct ccase *, void *),
+static bool internal_procedure (bool (*case_func) (const struct ccase *,
+ void *),
bool (*end_func) (void *),
void *aux);
static void update_last_vfm_invocation (void);
Returns true if successful, false if an I/O error occurred. */
bool
-procedure (bool (*proc_func) (struct ccase *, void *), void *aux)
+procedure (bool (*proc_func) (const struct ccase *, void *), void *aux)
{
return internal_procedure (proc_func, NULL, aux);
}
/* Case processing function for multipass_procedure(). */
static bool
-multipass_case_func (struct ccase *c, void *aux_data_)
+multipass_case_func (const struct ccase *c, void *aux_data_)
{
struct multipass_aux_data *aux_data = aux_data_;
return casefile_append (aux_data->casefile, c);
Returns true if successful, false if an I/O error occurred (or
if CASE_FUNC or END_FUNC ever returned false). */
static bool
-internal_procedure (bool (*case_func) (struct ccase *, void *),
+internal_procedure (bool (*case_func) (const struct ccase *, void *),
bool (*end_func) (void *),
void *aux)
{
&& trns_chain_is_empty (permanent_trns_chain))
{
n_lag = 0;
- expr_free (process_if_expr);
- process_if_expr = NULL;
dict_set_case_limit (default_dict, 0);
dict_clear_vectors (default_dict);
return true;
{
add_case_limit_trns ();
add_filter_trns ();
- add_process_if_trns ();
/* Finalize transformations. */
trns_chain_finalize (cur_trns_chain);
free_case_sink (vfm_sink);
vfm_sink = NULL;
- /* Cancel TEMPORARY, PROCESS IF, FILTER, N OF CASES, vectors,
- and get rid of all the transformations. */
dict_clear_vectors (default_dict);
permanent_dict = NULL;
return proc_cancel_all_transformations ();
};
static int equal_splits (const struct ccase *, const struct ccase *);
-static bool split_procedure_case_func (struct ccase *c, void *split_aux_);
-static bool split_procedure_end_func (void *split_aux_);
+static bool split_procedure_case_func (const struct ccase *c, void *);
+static bool split_procedure_end_func (void *);
/* Like procedure(), but it automatically breaks the case stream
into SPLIT FILE break groups. Before each group of cases with
/* Case callback used by procedure_with_splits(). */
static bool
-split_procedure_case_func (struct ccase *c, void *split_aux_)
+split_procedure_case_func (const struct ccase *c, void *split_aux_)
{
struct split_aux_data *split_aux = split_aux_;
void *func_aux; /* Auxiliary data. */
};
-static bool multipass_split_case_func (struct ccase *c, void *aux_);
+static bool multipass_split_case_func (const struct ccase *c, void *aux_);
static bool multipass_split_end_func (void *aux_);
static bool multipass_split_output (struct multipass_split_aux_data *);
/* Case callback used by multipass_procedure_with_splits(). */
static bool
-multipass_split_case_func (struct ccase *c, void *aux_)
+multipass_split_case_func (const struct ccase *c, void *aux_)
{
struct multipass_split_aux_data *aux = aux_;
bool ok = true;
vfm_source = NULL;
proc_cancel_all_transformations ();
-
- expr_free (process_if_expr);
- process_if_expr = NULL;
-
- proc_cancel_temporary_transformations ();
}
\f
/* Returns the current set of permanent transformations,
return (f != 0.0 && !mv_is_num_missing (&filter_var->miss, f)
? TRNS_CONTINUE : TRNS_DROP_CASE);
}
-\f
-static trns_proc_func process_if_trns_proc;
-static trns_free_func process_if_trns_free;
-
-/* Adds a temporary transformation to filter data according to
- the expression specified on PROCESS IF, if any. */
-static void
-add_process_if_trns (void)
-{
- if (process_if_expr != NULL)
- {
- proc_start_temporary_transformations ();
- add_transformation (process_if_trns_proc, process_if_trns_free,
- process_if_expr);
- process_if_expr = NULL;
- }
-}
-
-/* PROCESS IF transformation. */
-static int
-process_if_trns_proc (void *expression_,
- struct ccase *c UNUSED, int case_nr UNUSED)
-
-{
- struct expression *expression = expression_;
- return (expr_evaluate_num (expression, c, case_nr) == 1.0
- ? TRNS_CONTINUE : TRNS_DROP_CASE);
-}
-/* Frees a PROCESS IF transformation. */
-static bool
-process_if_trns_free (void *expression_)
-{
- struct expression *expression = expression_;
- expr_free (expression);
- return true;
-}