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

Diff of /pspp/src/flip.c

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

revision 1.17 by blp, Wed Dec 1 05:41:10 2004 UTC revision 1.18 by blp, Mon Mar 14 06:54:40 2005 UTC
# Line 50  struct varname Line 50  struct varname
50  struct flip_pgm  struct flip_pgm
51    {    {
52      struct variable **var;      /* Variables to transpose. */      struct variable **var;      /* Variables to transpose. */
53        int *idx_to_fv;             /* var[]->index to compacted sink case fv. */
54      int var_cnt;                /* Number of elements in `var'. */      int var_cnt;                /* Number of elements in `var'. */
55      int case_cnt;               /* Pre-flip case count. */      int case_cnt;               /* Pre-flip case count. */
56      size_t case_size;           /* Post-flip bytes per case. */      size_t case_size;           /* Post-flip bytes per case. */
# Line 85  cmd_flip (void) Line 86  cmd_flip (void)
86    
87    flip = xmalloc (sizeof *flip);    flip = xmalloc (sizeof *flip);
88    flip->var = NULL;    flip->var = NULL;
89      flip->idx_to_fv = dict_get_compacted_idx_to_fv (default_dict);
90    flip->var_cnt = 0;    flip->var_cnt = 0;
91    flip->case_cnt = 0;    flip->case_cnt = 0;
92    flip->new_names = NULL;    flip->new_names = NULL;
# Line 163  destroy_flip_pgm (struct flip_pgm *flip) Line 165  destroy_flip_pgm (struct flip_pgm *flip)
165    struct varname *iter, *next;    struct varname *iter, *next;
166        
167    free (flip->var);    free (flip->var);
168      free (flip->idx_to_fv);
169    for (iter = flip->new_names_head; iter != NULL; iter = next)    for (iter = flip->new_names_head; iter != NULL; iter = next)
170      {      {
171        next = iter->next;        next = iter->next;
# Line 308  flip_sink_write (struct case_sink *sink, Line 311  flip_sink_write (struct case_sink *sink,
311        v->next = NULL;        v->next = NULL;
312        if (flip->new_names->type == NUMERIC)        if (flip->new_names->type == NUMERIC)
313          {          {
314            double f = case_num (c, sink->idx_to_fv[flip->new_names->index]);            double f = case_num (c, flip->idx_to_fv[flip->new_names->index]);
315    
316            if (f == SYSMIS)            if (f == SYSMIS)
317              strcpy (v->name, "VSYSMIS");              strcpy (v->name, "VSYSMIS");
# Line 327  flip_sink_write (struct case_sink *sink, Line 330  flip_sink_write (struct case_sink *sink,
330        else        else
331          {          {
332            int width = min (flip->new_names->width, 8);            int width = min (flip->new_names->width, 8);
333            memcpy (v->name, case_str (c, sink->idx_to_fv[flip->new_names->index]),            memcpy (v->name, case_str (c, flip->idx_to_fv[flip->new_names->index]),
334                    width);                    width);
335            v->name[width] = 0;            v->name[width] = 0;
336          }          }
# Line 345  flip_sink_write (struct case_sink *sink, Line 348  flip_sink_write (struct case_sink *sink,
348        double out;        double out;
349                
350        if (flip->var[i]->type == NUMERIC)        if (flip->var[i]->type == NUMERIC)
351          out = case_num (c, sink->idx_to_fv[flip->var[i]->index]);          out = case_num (c, flip->idx_to_fv[flip->var[i]->index]);
352        else        else
353          out = SYSMIS;          out = SYSMIS;
354        info->output_buf[i].f = out;        info->output_buf[i].f = out;
# Line 474  static const struct case_sink_class flip Line 477  static const struct case_sink_class flip
477  static struct case_source *  static struct case_source *
478  flip_source_create (struct flip_pgm *pgm)  flip_source_create (struct flip_pgm *pgm)
479  {  {
480    return create_case_source (&flip_source_class, default_dict, pgm);    return create_case_source (&flip_source_class, pgm);
481  }  }
482    
483  /* Reads the FLIP stream.  Copies each case into C and calls  /* Reads the FLIP stream.  Copies each case into C and calls

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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