From: Ben Pfaff Date: Mon, 4 Jul 2011 21:12:42 +0000 (-0700) Subject: format: Honor width step in fmt_fix(). X-Git-Tag: v0.7.9~214 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=676891a38608a91595d7af418785d045bb831f92;p=pspp-builds.git format: Honor width step in fmt_fix(). 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. --- diff --git a/src/data/format.c b/src/data/format.c index e15931ad..559ab662 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. */