From 676891a38608a91595d7af418785d045bb831f92 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 4 Jul 2011 14:12:42 -0700 Subject: [PATCH] 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. --- src/data/format.c | 5 +++++ 1 file changed, 5 insertions(+) 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. */ -- 2.30.2