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

Diff of /pspp/src/print.c

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

revision 1.18 by blp, Mon Mar 7 03:04:50 2005 UTC revision 1.19 by blp, Sat Mar 12 01:08:33 2005 UTC
# Line 478  fail: Line 478  fail:
478    return 0;    return 0;
479  }  }
480    
481    /* Verifies that FORMAT doesn't need a variable wider than WIDTH.
482       Returns true iff that is the case. */
483    static bool
484    check_string_width (const struct fmt_spec *format, const struct variable *v)
485    {
486      if (get_format_var_width (format) > v->width)
487        {
488          msg (SE, _("Variable %s has width %d so it cannot be output "
489                     "as format %s."),
490               v->name, v->width, fmt_to_string (format));
491          return false;
492        }
493      return true;
494    }
495    
496  /* Parses a column specification for parse_specs(). */  /* Parses a column specification for parse_specs(). */
497  static int  static int
498  fixed_parse_compatible (void)  fixed_parse_compatible (void)
# Line 599  fixed_parse_compatible (void) Line 614  fixed_parse_compatible (void)
614    
615    dividend = (fx.lc - fx.fc + 1) / fx.nv;    dividend = (fx.lc - fx.fc + 1) / fx.nv;
616    fx.spec.u.v.f.w = dividend;    fx.spec.u.v.f.w = dividend;
617    if (!check_output_specifier (&fx.spec.u.v.f, 1))    if (!check_output_specifier (&fx.spec.u.v.f, true)
618          || !check_specifier_type (&fx.spec.u.v.f, type, true))
619      return 0;      return 0;
   if ((type == ALPHA) ^ (formats[fx.spec.u.v.f.type].cat & FCAT_STRING))  
     {  
       msg (SE, _("%s variables cannot be displayed with format %s."),  
            type == ALPHA ? _("String") : _("Numeric"),  
            fmt_to_string (&fx.spec.u.v.f));  
       return 0;  
     }  
   
   /* Check that, for string variables, the user didn't specify a width  
      longer than an actual string width. */  
620    if (type == ALPHA)    if (type == ALPHA)
621      {      {
622        /* Minimum width of all the string variables specified. */        for (i = 0; i < fx.nv; i++)
623        int min_len = fx.v[0]->width;          if (!check_string_width (&fx.spec.u.v.f, fx.v[i]))
624              return false;
       for (i = 1; i < fx.nv; i++)  
         min_len = min (min_len, fx.v[i]->width);  
       if (!check_string_specifier (&fx.spec.u.v.f, min_len))  
         return 0;  
625      }      }
626    
627    fx.spec.type = PRT_VAR;    fx.spec.type = PRT_VAR;
# Line 688  dump_fmt_list (struct fmt_list * f) Line 690  dump_fmt_list (struct fmt_list * f)
690                }                }
691    
692              v = fx.v[fx.cv++];              v = fx.v[fx.cv++];
693              if ((v->type == ALPHA) ^ (formats[f->f.type].cat & FCAT_STRING))              if (!check_output_specifier (&f->f, true)
694                {                  || !check_specifier_type (&f->f, v->type, true)
695                  msg (SE, _("Display format %s may not be used with a "                  || !check_string_width (&f->f, v))
696                             "%s variable."), fmt_to_string (&f->f),                return false;
                      v->type == ALPHA ? _("string") : _("numeric"));  
                 return 0;  
               }  
             if (!check_string_specifier (&f->f, v->width))  
               return 0;  
697    
698              fx.spec.type = PRT_VAR;              fx.spec.type = PRT_VAR;
699              fx.spec.u.v.v = v;              fx.spec.u.v.v = v;

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