From 4767b203cd2e4a850b72f90a0b89717c4ee7c074 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 27 Apr 2006 02:51:12 +0000 Subject: [PATCH] Continue reforming procedure execution. In this phase, assert that add_transformation() is not called during procedure execution. Thanks to John Darrington for the suggestion. --- src/ChangeLog | 15 +++++++++++++++ src/procedure.c | 19 ++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 7d0e1b27..beadbd2c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +Wed Apr 26 19:48:52 2006 Ben Pfaff + + Continue reforming procedure execution. In this phase, assert + that add_transformation() is not called during procedure + execution. Thanks to John Darrington for the suggestion. + + * procedure.c: (static var in_procedure) New var. + (internal_procedure) Get rid of recursive_call local var and + logic. + (open_active_file) Set in_procedure and make sure it wasn't + already set. + (close_active_file) Reset in_procedure and make sure it was + already set. + (add_transformation) Make sure we're not in a procedure. + Wed Apr 26 19:33:52 2006 Ben Pfaff Continue reforming procedure execution. In this phase, break diff --git a/src/procedure.c b/src/procedure.c index 7fd57750..725e8ec5 100644 --- a/src/procedure.c +++ b/src/procedure.c @@ -85,6 +85,10 @@ static struct dict_compactor *compactor; /* Time at which vfm was last invoked. */ static time_t last_vfm_invocation; +/* Whether we're inside a procedure. + For debugging purposes only. */ +static bool in_procedure; + /* Lag queue. */ int n_lag; /* Number of cases to lag. */ static int lag_count; /* Number of cases in lag_queue so far. */ @@ -178,12 +182,9 @@ procedure (bool (*proc_func) (struct ccase *, void *), void *aux) static bool internal_procedure (bool (*proc_func) (struct ccase *, void *), void *aux) { - static int recursive_call; struct write_case_data wc_data; bool ok; - assert (++recursive_call == 1); - wc_data.proc_func = proc_func; wc_data.aux = aux; create_trns_case (&wc_data.trns_case, default_dict); @@ -200,8 +201,6 @@ internal_procedure (bool (*proc_func) (struct ccase *, void *), void *aux) case_destroy (&wc_data.sink_case); case_destroy (&wc_data.trns_case); - assert (--recursive_call == 0); - return ok; } @@ -239,6 +238,9 @@ create_trns_case (struct ccase *trns_case, struct dictionary *dict) static void open_active_file (void) { + assert (!in_procedure); + in_procedure = true; + /* Make temp_dict refer to the dictionary right before data reaches the sink */ if (!temporary) @@ -483,6 +485,10 @@ close_active_file (void) process_if_expr = NULL; dict_set_case_limit (default_dict, 0); dict_clear_vectors (default_dict); + + assert (in_procedure); + in_procedure = false; + return cancel_transformations (); } @@ -511,6 +517,9 @@ void add_transformation (trns_proc_func *proc, trns_free_func *free, void *private) { struct transformation *trns; + + assert (!in_procedure); + if (n_trns >= m_trns) t_trns = x2nrealloc (t_trns, &m_trns, sizeof *t_trns); trns = &t_trns[n_trns++]; -- 2.30.2