From: Jim Meyering Date: Wed, 1 Mar 2000 12:31:16 +0000 (+0000) Subject: (get_width_format): Fix portability problem with `-0' vs. `0'. X-Git-Tag: TEXTUTILS-2_0e~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=172290c201c93260262770b06a8b50ebb90390e0;p=thirdparty%2Fcoreutils.git (get_width_format): Fix portability problem with `-0' vs. `0'. --- diff --git a/src/seq.c b/src/seq.c index f8b7205e2a..665461d589 100644 --- a/src/seq.c +++ b/src/seq.c @@ -260,10 +260,13 @@ get_width_format () if (min_val < 0.0) { - sprintf (buffer, "%g", rint (min_val)); + double int_min_val = rint (min_val); + sprintf (buffer, "%g", int_min_val); if (buffer[strspn (buffer, "-0123456789")] != '\0') return "%g"; - width2 = strlen (buffer); + /* On some systems, `seq -w -.1 .1 .1' results in buffer being `-0'. + On others, it is just `0'. The former results in better output. */ + width2 = (int_min_val == 0 ? 2 : strlen (buffer)); width1 = width1 > width2 ? width1 : width2; }