/[pspp]/pspp/src/sfm-write.c
ViewVC logotype

Diff of /pspp/src/sfm-write.c

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

revision 1.18 by blp, Sun Jul 31 21:42:46 2005 UTC revision 1.19 by blp, Sun Aug 7 04:39:28 2005 UTC
# Line 362  write_variable (struct sfm_writer *w, st Line 362  write_variable (struct sfm_writer *w, st
362    struct sysfile_variable sv;    struct sysfile_variable sv;
363    
364    /* Missing values. */    /* Missing values. */
365      struct missing_values mv;
366    flt64 m[3];           /* Missing value values. */    flt64 m[3];           /* Missing value values. */
367    int nm;               /* Number of missing values, possibly negative. */    int nm;               /* Number of missing values, possibly negative. */
368    
# Line 369  write_variable (struct sfm_writer *w, st Line 370  write_variable (struct sfm_writer *w, st
370    sv.type = v->width;    sv.type = v->width;
371    sv.has_var_label = (v->label != NULL);    sv.has_var_label = (v->label != NULL);
372    
373    switch (v->miss_type)    mv_copy (&mv, &v->miss);
374      nm = 0;
375      if (mv_has_range (&mv))
376      {      {
377      case MISSING_NONE:        double x, y;
378        nm = 0;        mv_pop_range (&mv, &x, &y);
379        break;        m[nm++] = x == LOWEST ? second_lowest_flt64 : x;
380      case MISSING_1:        m[nm++] = y == HIGHEST ? FLT64_MAX : y;
     case MISSING_2:  
     case MISSING_3:  
       for (nm = 0; nm < v->miss_type; nm++)  
         m[nm] = v->missing[nm].f;  
       break;  
     case MISSING_RANGE:  
       m[0] = v->missing[0].f;  
       m[1] = v->missing[1].f;  
       nm = -2;  
       break;  
     case MISSING_LOW:  
       m[0] = second_lowest_flt64;  
       m[1] = v->missing[0].f;  
       nm = -2;  
       break;  
     case MISSING_HIGH:  
       m[0] = v->missing[0].f;  
       m[1] = FLT64_MAX;  
       nm = -2;  
       break;  
     case MISSING_RANGE_1:  
       m[0] = v->missing[0].f;  
       m[1] = v->missing[1].f;  
       m[2] = v->missing[2].f;  
       nm = -3;  
       break;  
     case MISSING_LOW_1:  
       m[0] = second_lowest_flt64;  
       m[1] = v->missing[0].f;  
       m[2] = v->missing[1].f;  
       nm = -3;  
       break;  
     case MISSING_HIGH_1:  
       m[0] = v->missing[0].f;  
       m[1] = second_lowest_flt64;  
       m[2] = v->missing[1].f;  
       nm = -3;  
       break;  
     default:  
       assert (0);  
       abort ();  
381      }      }
382      while (mv_has_value (&mv))
383        {
384          union value value;
385          mv_pop_value (&mv, &value);
386          if (v->type == NUMERIC)
387            m[nm] = value.f;
388          else
389            buf_copy_rpad ((char *) &m[nm], sizeof m[nm], value.s, v->width);
390          nm++;
391        }
392      if (mv_has_range (&v->miss))
393        nm = -nm;
394    
395    sv.n_missing_values = nm;    sv.n_missing_values = nm;
396    write_format_spec (&v->print, &sv.print);    write_format_spec (&v->print, &sv.print);
# Line 445  write_variable (struct sfm_writer *w, st Line 419  write_variable (struct sfm_writer *w, st
419          return 0;          return 0;
420      }      }
421    
422    if (nm && !buf_write (w, m, sizeof *m * nm))    if (nm && !buf_write (w, m, sizeof *m * abs (nm)))
423      return 0;      return 0;
424    
425    if (v->type == ALPHA && v->width > (int) sizeof (flt64))    if (v->type == ALPHA && v->width > (int) sizeof (flt64))

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

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