From 64d4a2807d46a85cfe5ab7eb99b3e91b9a75d5ab Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Fri, 23 Nov 2012 03:06:07 +0000 Subject: seq: ensure correct output width for scientific notation input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/seq.c (scan_arg): Calculate the width more accurately for numbers specified using scientific notation. * tests/misc/seq.pl: Add tests for cases that were mishandled. * NEWS: Mention the fix. * THANKS.in: Reported by Marcel Böhme. Fixes http://bugs.gnu.org/12959 --- src/seq.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/seq.c b/src/seq.c index e5788caab..9c2c51fbe 100644 --- a/src/seq.c +++ b/src/seq.c @@ -166,6 +166,21 @@ scan_arg (const char *arg) { long exponent = strtol (e + 1, NULL, 10); ret.precision += exponent < 0 ? -exponent : 0; + /* Don't account for e.... in the width since this is not output. */ + ret.width -= strlen (arg) - (e - arg); + /* Adjust the width as per the exponent. */ + if (exponent < 0) + { + if (decimal_point) + { + if (e == decimal_point + 1) /* undo #. -> # above */ + ret.width++; + } + else + ret.width++; + exponent = -exponent; + } + ret.width += exponent; } } -- cgit v1.2.3-70-g09d2