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

Diff of /pspp/src/recode.c

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

revision 1.28 by blp, Wed Oct 26 05:06:14 2005 UTC revision 1.29 by blp, Thu Nov 3 06:21:46 2005 UTC
# Line 81  struct rcd_var Line 81  struct rcd_var
81  /* RECODE transformation. */  /* RECODE transformation. */
82  struct recode_trns  struct recode_trns
83    {    {
     struct trns_header h;  
84      struct rcd_var *codings;      struct rcd_var *codings;
85    };    };
86    
# Line 105  struct recode_trns Line 104  struct recode_trns
104  #define RCD_MISC_MISSING        0100u   /* Encountered MISSING or SYSMIS in  #define RCD_MISC_MISSING        0100u   /* Encountered MISSING or SYSMIS in
105                                             this input spec. */                                             this input spec. */
106    
107  static int parse_dest_spec (struct rcd_var * rcd, union value *v,  static int parse_dest_spec (struct rcd_var *rcd, union value *v,
108                              size_t *max_dst_width);                              size_t *max_dst_width);
109  static int parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width);  static int parse_src_spec (struct rcd_var *rcd, int type, size_t max_src_width);
110  static trns_proc_func recode_trns_proc;  static trns_proc_func recode_trns_proc;
111  static trns_free_func recode_trns_free;  static trns_free_func recode_trns_free;
112  static double convert_to_double (const char *, int);  static double convert_to_double (const char *, int);
# Line 425  cmd_recode (void) Line 424  cmd_recode (void)
424        }        }
425    
426    trns = xmalloc (sizeof *trns);    trns = xmalloc (sizeof *trns);
   trns->h.proc = recode_trns_proc;  
   trns->h.free = recode_trns_free;  
427    trns->codings = head;    trns->codings = head;
428    add_transformation ((struct trns_header *) trns);    add_transformation (recode_trns_proc, recode_trns_free, trns);
429    
430    return CMD_SUCCESS;    return CMD_SUCCESS;
431    
# Line 438  cmd_recode (void) Line 435  cmd_recode (void)
435      struct recode_trns t;      struct recode_trns t;
436    
437      t.codings = head;      t.codings = head;
438      recode_trns_free ((struct trns_header *) &t);      recode_trns_free (&t);
439      return CMD_FAILURE;      return CMD_FAILURE;
440    }    }
441  }  }
442    
443  static int  static int
444  parse_dest_spec (struct rcd_var * rcd, union value * v, size_t *max_dst_width)  parse_dest_spec (struct rcd_var *rcd, union value *v, size_t *max_dst_width)
445  {  {
446    int flags;    int flags;
447    
# Line 515  parse_dest_spec (struct rcd_var * rcd, u Line 512  parse_dest_spec (struct rcd_var * rcd, u
512     but with CONVERT as the keyword; 3 for success but with ELSE as the     but with CONVERT as the keyword; 3 for success but with ELSE as the
513     keyword. */     keyword. */
514  static int  static int
515  parse_src_spec (struct rcd_var * rcd, int type, size_t max_src_width)  parse_src_spec (struct rcd_var *rcd, int type, size_t max_src_width)
516  {  {
517    struct coding *c;    struct coding *c;
518    
# Line 649  parse_src_spec (struct rcd_var * rcd, in Line 646  parse_src_spec (struct rcd_var * rcd, in
646  /* Data transformation. */  /* Data transformation. */
647    
648  static void  static void
649  recode_trns_free (struct trns_header * t)  recode_trns_free (void *t_)
650  {  {
651      struct recode_trns *t = t_;
652    size_t i;    size_t i;
653    struct rcd_var *head, *next;    struct rcd_var *head, *next;
654    
655    head = ((struct recode_trns *) t)->codings;    head = t->codings;
656    while (head)    while (head)
657      {      {
658        if (head->map && !(head->flags & RCD_MISC_DUPLICATE))        if (head->map && !(head->flags & RCD_MISC_DUPLICATE))
# Line 689  recode_trns_free (struct trns_header * t Line 687  recode_trns_free (struct trns_header * t
687        free (head);        free (head);
688        head = next;        head = next;
689      }      }
690      free (t);
691  }  }
692    
693  static inline struct coding *  static inline struct coding *
694  find_src_numeric (struct rcd_var * v, struct ccase * c)  find_src_numeric (struct rcd_var *v, struct ccase *c)
695  {  {
696    double cmp = case_num (c, v->src->fv);    double cmp = case_num (c, v->src->fv);
697    struct coding *cp;    struct coding *cp;
# Line 743  find_src_numeric (struct rcd_var * v, st Line 742  find_src_numeric (struct rcd_var * v, st
742  }  }
743    
744  static inline struct coding *  static inline struct coding *
745  find_src_string (struct rcd_var * v, struct ccase * c)  find_src_string (struct rcd_var *v, struct ccase *c)
746  {  {
747    const char *cmp = case_str (c, v->src->fv);    const char *cmp = case_str (c, v->src->fv);
748    int w = v->src->width;    int w = v->src->width;
# Line 776  find_src_string (struct rcd_var * v, str Line 775  find_src_string (struct rcd_var * v, str
775  }  }
776    
777  static int  static int
778  recode_trns_proc (struct trns_header * t, struct ccase * c,  recode_trns_proc (void *t_, struct ccase *c,
779                    int case_idx UNUSED)                    int case_idx UNUSED)
780  {  {
781      struct recode_trns *t = t_;
782    struct rcd_var *v;    struct rcd_var *v;
783    
784    for (v = ((struct recode_trns *) t)->codings; v; v = v->next)    for (v = t->codings; v; v = v->next)
785      {      {
786        struct coding *cp;        struct coding *cp;
787    

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

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