/[pspp]/pspp/src/sel-if.c
ViewVC logotype

Diff of /pspp/src/sel-if.c

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

revision 1.10 by blp, Sun Jul 31 21:42:46 2005 UTC revision 1.11 by blp, Thu Nov 3 06:21:46 2005 UTC
# Line 18  Line 18 
18     02110-1301, USA. */     02110-1301, USA. */
19    
20  #include <config.h>  #include <config.h>
21    #include <stdlib.h>
22  #include "alloc.h"  #include "alloc.h"
23  #include "command.h"  #include "command.h"
24  #include "dictionary.h"  #include "dictionary.h"
# Line 33  Line 34 
34  /* SELECT IF transformation. */  /* SELECT IF transformation. */
35  struct select_if_trns  struct select_if_trns
36    {    {
     struct trns_header h;  
37      struct expression *e;       /* Test expression. */      struct expression *e;       /* Test expression. */
38    };    };
39    
# Line 59  cmd_select_if (void) Line 59  cmd_select_if (void)
59      }      }
60    
61    t = xmalloc (sizeof *t);    t = xmalloc (sizeof *t);
   t->h.proc = select_if_proc;  
   t->h.free = select_if_free;  
62    t->e = e;    t->e = e;
63    add_transformation ((struct trns_header *) t);    add_transformation (select_if_proc, select_if_free, t);
64    
65    return CMD_SUCCESS;    return CMD_SUCCESS;
66  }  }
67    
68  /* Performs the SELECT IF transformation T on case C. */  /* Performs the SELECT IF transformation T on case C. */
69  static int  static int
70  select_if_proc (struct trns_header *t_, struct ccase *c,  select_if_proc (void *t_, struct ccase *c,
71                  int case_num)                  int case_num)
72  {  {
73    struct select_if_trns *t = (struct select_if_trns *) t_;    struct select_if_trns *t = t_;
74    return expr_evaluate_num (t->e, c, case_num) == 1.0 ? -1 : -2;    return expr_evaluate_num (t->e, c, case_num) == 1.0 ? -1 : -2;
75  }  }
76    
77  /* Frees SELECT IF transformation T. */  /* Frees SELECT IF transformation T. */
78  static void  static void
79  select_if_free (struct trns_header * t)  select_if_free (void *t_)
80  {  {
81    expr_free (((struct select_if_trns *) t)->e);    struct select_if_trns *t = t_;
82      expr_free (t->e);
83      free (t);
84  }  }
85    
86  /* Parses the FILTER command. */  /* Parses the FILTER command. */

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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