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

Diff of /pspp/src/format.c

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

revision 1.11 by blp, Mon May 2 06:21:20 2005 UTC revision 1.12 by blp, Wed May 11 03:03:43 2005 UTC
# Line 157  check_input_specifier (const struct fmt_ Line 157  check_input_specifier (const struct fmt_
157    if (f->cat & FCAT_OUTPUT_ONLY)    if (f->cat & FCAT_OUTPUT_ONLY)
158      {      {
159        if (emit_error)        if (emit_error)
160          msg (SE, _("Format %s may not be used as an input format."), f->name);          msg (SE, _("Format %s may not be used for input."), f->name);
161        return 0;        return 0;
162      }      }
163    if (spec->w < f->Imin_w || spec->w > f->Imax_w)    if (spec->w < f->Imin_w || spec->w > f->Imax_w)
# Line 168  check_input_specifier (const struct fmt_ Line 168  check_input_specifier (const struct fmt_
168               str, spec->w, f->name, f->Imin_w, f->Imax_w);               str, spec->w, f->name, f->Imin_w, f->Imax_w);
169        return 0;        return 0;
170      }      }
171      if ((spec->type == FMT_F || spec->type == FMT_COMMA
172              || spec->type == FMT_DOLLAR)
173          && spec->d > spec->w)
174        {
175          if (emit_error)
176            msg (SE, _("Input format %s is invalid because it specifies more "
177                       "decimal places than the field width."), str);
178          return 0;
179        }
180    return 1;    return 1;
181  }  }
182    
# Line 192  check_output_specifier (const struct fmt Line 201  check_output_specifier (const struct fmt
201               str, spec->w, f->name, f->Omin_w, f->Omax_w);               str, spec->w, f->name, f->Omin_w, f->Omax_w);
202        return 0;        return 0;
203      }      }
204    if (spec->d > 1    if ((spec->type == FMT_F || spec->type == FMT_COMMA
       && (spec->type == FMT_F || spec->type == FMT_COMMA  
205            || spec->type == FMT_DOLLAR)            || spec->type == FMT_DOLLAR)
206        && spec->w < f->Omin_w + 1 + spec->d)        && spec->d >= spec->w)
207      {      {
208        if (emit_error)        if (emit_error)
209          msg (SE, _("Output format %s requires minimum width %d to allow "          msg (SE, _("Output format %s is invalid because it specifies as "
210                     "%d decimal places.  Try %s%d.%d instead of %s."),                     "many decimal places as the field width, which "
211               f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,                     "fails to allow space for a decimal point.  "
212               f->Omin_w + 1 + spec->d, spec->d, str);                     "Try %s%d.%d instead."),
213                 str, f->name, f->name, spec->d + 1, spec->d);
214        return 0;        return 0;
215      }      }
216    return 1;    return 1;
# Line 253  check_specifier_width (const struct fmt_ Line 262  check_specifier_width (const struct fmt_
262  void  void
263  convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output)  convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output)
264  {  {
265      assert (check_input_specifier (input, 0));
266    
267    output->type = formats[input->type].output;    output->type = formats[input->type].output;
268    output->w = input->w;    output->w = input->w;
269    if (output->w > formats[output->type].Omax_w)    if (output->w > formats[output->type].Omax_w)
# Line 263  convert_fmt_ItoO (const struct fmt_spec Line 274  convert_fmt_ItoO (const struct fmt_spec
274      {      {
275      case FMT_F:      case FMT_F:
276      case FMT_N:      case FMT_N:
277        if (output->d > 1 && output->w < 2 + output->d)        if (output->d > 0)
278          output->w = 2 + output->d;          output->w++;
279        break;        break;
280      case FMT_E:      case FMT_E:
281        output->w = max (max (input->w, input->d+7), 10);        output->w = max (max (input->w, input->d+7), 10);
# Line 340  convert_fmt_ItoO (const struct fmt_spec Line 351  convert_fmt_ItoO (const struct fmt_spec
351      default:      default:
352        assert (0);        assert (0);
353      }      }
354    
355      assert (check_output_specifier (output, 0));
356  }  }
357    
358  /* Parses a format specifier from the token stream and returns  /* Parses a format specifier from the token stream and returns

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

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