[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] Changes to pspp/src/format.c
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] Changes to pspp/src/format.c |
Date: |
Tue, 10 May 2005 23:03:45 -0400 |
Index: pspp/src/format.c
diff -u pspp/src/format.c:1.11 pspp/src/format.c:1.12
--- pspp/src/format.c:1.11 Mon May 2 06:21:20 2005
+++ pspp/src/format.c Wed May 11 03:03:43 2005
@@ -157,7 +157,7 @@
if (f->cat & FCAT_OUTPUT_ONLY)
{
if (emit_error)
- 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);
return 0;
}
if (spec->w < f->Imin_w || spec->w > f->Imax_w)
@@ -168,6 +168,15 @@
str, spec->w, f->name, f->Imin_w, f->Imax_w);
return 0;
}
+ if ((spec->type == FMT_F || spec->type == FMT_COMMA
+ || spec->type == FMT_DOLLAR)
+ && spec->d > spec->w)
+ {
+ if (emit_error)
+ msg (SE, _("Input format %s is invalid because it specifies more "
+ "decimal places than the field width."), str);
+ return 0;
+ }
return 1;
}
@@ -192,16 +201,16 @@
str, spec->w, f->name, f->Omin_w, f->Omax_w);
return 0;
}
- if (spec->d > 1
- && (spec->type == FMT_F || spec->type == FMT_COMMA
+ if ((spec->type == FMT_F || spec->type == FMT_COMMA
|| spec->type == FMT_DOLLAR)
- && spec->w < f->Omin_w + 1 + spec->d)
+ && spec->d >= spec->w)
{
if (emit_error)
- msg (SE, _("Output format %s requires minimum width %d to allow "
- "%d decimal places. Try %s%d.%d instead of %s."),
- f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,
- f->Omin_w + 1 + spec->d, spec->d, str);
+ msg (SE, _("Output format %s is invalid because it specifies as "
+ "many decimal places as the field width, which "
+ "fails to allow space for a decimal point. "
+ "Try %s%d.%d instead."),
+ str, f->name, f->name, spec->d + 1, spec->d);
return 0;
}
return 1;
@@ -253,6 +262,8 @@
void
convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output)
{
+ assert (check_input_specifier (input, 0));
+
output->type = formats[input->type].output;
output->w = input->w;
if (output->w > formats[output->type].Omax_w)
@@ -263,8 +274,8 @@
{
case FMT_F:
case FMT_N:
- if (output->d > 1 && output->w < 2 + output->d)
- output->w = 2 + output->d;
+ if (output->d > 0)
+ output->w++;
break;
case FMT_E:
output->w = max (max (input->w, input->d+7), 10);
@@ -340,6 +351,8 @@
default:
assert (0);
}
+
+ assert (check_output_specifier (output, 0));
}
/* Parses a format specifier from the token stream and returns