Continue reforming procedure execution. In this phase, remove PROCESS
[pspp-builds.git] / src / data / procedure.c
index 1ecfd331a1f314571a79b1a68b9c74d4c491304c..4cbb55204959411a9f8132bce4a38a375bc7acb7 100644 (file)
@@ -34,7 +34,6 @@
 #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>
@@ -52,8 +51,8 @@
 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
@@ -94,9 +93,9 @@ static struct ccase *lag_queue; /* Array of n_lag ccase * elements. */
 
 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);
@@ -136,7 +135,7 @@ time_of_last_procedure (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);
 }
@@ -153,7 +152,7 @@ struct multipass_aux_data
 
 /* 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);
@@ -198,7 +197,7 @@ multipass_procedure (bool (*proc_func) (const struct casefile *, void *aux),
    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) 
 {
@@ -219,8 +218,6 @@ internal_procedure (bool (*case_func) (struct ccase *, void *),
       && 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;
@@ -284,7 +281,6 @@ open_active_file (void)
 {
   add_case_limit_trns ();
   add_filter_trns ();
-  add_process_if_trns ();
 
   /* Finalize transformations. */
   trns_chain_finalize (cur_trns_chain);
@@ -442,8 +438,6 @@ close_active_file (void)
   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 ();
@@ -484,8 +478,8 @@ struct split_aux_data
   };
 
 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
@@ -530,7 +524,7 @@ procedure_with_splits (void (*begin_func) (const struct ccase *, void *aux),
 
 /* 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_;
 
@@ -590,7 +584,7 @@ struct multipass_split_aux_data
     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 *);
 
@@ -618,7 +612,7 @@ multipass_procedure_with_splits (bool (*split_func) (const struct ccase *first,
 
 /* 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;
@@ -676,11 +670,6 @@ discard_variables (void)
   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,
@@ -942,40 +931,4 @@ filter_trns_proc (void *filter_var_,
   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;
-}