format: Honor width step in fmt_fix().
[pspp-builds.git] / src / data / format.c
index e15931ad1a2b4764547747945e9399305f2b8946..559ab6628b344b742e8705500364991128dfa169 100644 (file)
@@ -500,6 +500,7 @@ fmt_resize (struct fmt_spec *fmt, int width)
 void
 fmt_fix (struct fmt_spec *fmt, bool for_input)
 {
+  unsigned int step;
   int min_w, max_w;
   int max_d;
 
@@ -511,6 +512,10 @@ fmt_fix (struct fmt_spec *fmt, bool for_input)
   else if (fmt->w > max_w)
     fmt->w = max_w;
 
+  /* Round width to step. */
+  step = fmt_step_width (fmt->type);
+  fmt->w = ROUND_DOWN (fmt->w, step);
+
   /* First, if FMT has more decimal places than allowed, attempt
      to increase FMT's width until that number of decimal places
      can be achieved. */