pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sheet-prep-2 1/3] format: Honor width step in fmt_fix().


From: Ben Pfaff
Subject: [sheet-prep-2 1/3] format: Honor width step in fmt_fix().
Date: Tue, 12 Jul 2011 22:21:47 -0700

This ensures that hexadecimal format widths will be a multiple
of 2 after fmt_fix() finishes with them.

This function is used only by the GUI, which doesn't generally
work with hexadecimal formats, so it might not fix a real bug
in practice.
---
 src/data/format.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/data/format.c b/src/data/format.c
index e15931a..559ab66 100644
--- a/src/data/format.c
+++ b/src/data/format.c
@@ -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. */
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]