/[pspp]/pspp/src/vfm.c
ViewVC logotype

Diff of /pspp/src/vfm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.42 by blp, Wed Oct 26 05:06:14 2005 UTC revision 1.43 by blp, Thu Nov 3 06:21:47 2005 UTC
# Line 32  Line 32 
32  #include "casefile.h"  #include "casefile.h"
33  #include "command.h"  #include "command.h"
34  #include "dictionary.h"  #include "dictionary.h"
35  #include "do-ifP.h"  #include "ctl-stack.h"
36  #include "error.h"  #include "error.h"
37  #include "expressions/public.h"  #include "expressions/public.h"
38  #include "misc.h"  #include "misc.h"
# Line 94  static void create_trns_case (struct cca Line 94  static void create_trns_case (struct cca
94  static void open_active_file (void);  static void open_active_file (void);
95  static int write_case (struct write_case_data *wc_data);  static int write_case (struct write_case_data *wc_data);
96  static int execute_transformations (struct ccase *c,  static int execute_transformations (struct ccase *c,
97                                      struct trns_header **trns,                                      struct transformation *trns,
98                                      int first_idx, int last_idx,                                      int first_idx, int last_idx,
99                                      int case_num);                                      int case_num);
100  static int filter_case (const struct ccase *c, int case_num);  static int filter_case (const struct ccase *c, int case_num);
# Line 233  open_active_file (void) Line 233  open_active_file (void)
233      }      }
234    
235    /* Close any unclosed DO IF or LOOP constructs. */    /* Close any unclosed DO IF or LOOP constructs. */
236    discard_ctl_stack ();    ctl_stack_clear ();
237  }  }
238    
239  /* Transforms trns_case and writes it to the replacement active  /* Transforms trns_case and writes it to the replacement active
# Line 299  write_case (struct write_case_data *wc_d Line 299  write_case (struct write_case_data *wc_d
299     transformations, nonzero otherwise. */     transformations, nonzero otherwise. */
300  static int  static int
301  execute_transformations (struct ccase *c,  execute_transformations (struct ccase *c,
302                           struct trns_header **trns,                           struct transformation *trns,
303                           int first_idx, int last_idx,                           int first_idx, int last_idx,
304                           int case_num)                           int case_num)
305  {  {
# Line 307  execute_transformations (struct ccase *c Line 307  execute_transformations (struct ccase *c
307    
308    for (idx = first_idx; idx != last_idx; )    for (idx = first_idx; idx != last_idx; )
309      {      {
310        int retval = trns[idx]->proc (trns[idx], c, case_num);        struct transformation *t = &trns[idx];
311          int retval = t->proc (t->private, c, case_num);
312        switch (retval)        switch (retval)
313          {          {
314          case -1:          case -1:
# Line 603  lagged_case (int n_before) Line 604  lagged_case (int n_before)
604  /* Appends TRNS to t_trns[], the list of all transformations to be  /* Appends TRNS to t_trns[], the list of all transformations to be
605     performed on data as it is read from the active file. */     performed on data as it is read from the active file. */
606  void  void
607  add_transformation (struct trns_header * trns)  add_transformation (trns_proc_func *proc, trns_free_func *free, void *private)
608  {  {
609      struct transformation *trns;
610    if (n_trns >= m_trns)    if (n_trns >= m_trns)
611      {      t_trns = x2nrealloc (t_trns, &m_trns, sizeof *t_trns);
612        m_trns += 16;    trns = &t_trns[n_trns++];
613        t_trns = xnrealloc (t_trns, m_trns, sizeof *t_trns);    trns->proc = proc;
614      }    trns->free = free;
615    t_trns[n_trns] = trns;    trns->private = private;
616    trns->index = n_trns++;  }
617    
618    /* Returns the index number that the next transformation added by
619       add_transformation() will receive.  A trns_proc_func that
620       returns this index causes control flow to jump to it. */
621    size_t
622    next_transformation (void)
623    {
624      return n_trns;
625  }  }
626    
627  /* Cancels all active transformations, including any transformations  /* Cancels all active transformations, including any transformations
# Line 619  add_transformation (struct trns_header * Line 629  add_transformation (struct trns_header *
629  void  void
630  cancel_transformations (void)  cancel_transformations (void)
631  {  {
632    int i;    size_t i;
633    for (i = 0; i < n_trns; i++)    for (i = 0; i < n_trns; i++)
634      {      {
635        if (t_trns[i]->free)        struct transformation *t = &t_trns[i];
636          t_trns[i]->free (t_trns[i]);        if (t->free != NULL)
637        free (t_trns[i]);          t->free (t->private);
638      }      }
639    n_trns = f_trns = 0;    n_trns = f_trns = 0;
640    free (t_trns);    free (t_trns);
# Line 928  discard_variables (void) Line 938  discard_variables (void)
938    
939    cancel_transformations ();    cancel_transformations ();
940    
941    ctl_stack = NULL;    ctl_stack_clear ();
942    
943    expr_free (process_if_expr);    expr_free (process_if_expr);
944    process_if_expr = NULL;    process_if_expr = NULL;

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26