diff options
author | Jim Meyering <jim@meyering.net> | 2000-03-01 12:31:16 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-03-01 12:31:16 +0000 |
commit | 172290c201c93260262770b06a8b50ebb90390e0 (patch) | |
tree | 00424e3c4930843ed544a3de601d634b86a30941 /src | |
parent | 1679d72fee2c172f2458189142781b97f485c7a0 (diff) | |
download | coreutils-172290c201c93260262770b06a8b50ebb90390e0.tar.xz |
(get_width_format): Fix portability problem with `-0' vs. `0'.
Diffstat (limited to 'src')
-rw-r--r-- | src/seq.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; } |