summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-03-01 12:31:16 +0000
committerJim Meyering <jim@meyering.net>2000-03-01 12:31:16 +0000
commit172290c201c93260262770b06a8b50ebb90390e0 (patch)
tree00424e3c4930843ed544a3de601d634b86a30941 /src
parent1679d72fee2c172f2458189142781b97f485c7a0 (diff)
downloadcoreutils-172290c201c93260262770b06a8b50ebb90390e0.tar.xz
(get_width_format): Fix portability problem with `-0' vs. `0'.
Diffstat (limited to 'src')
-rw-r--r--src/seq.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/seq.c b/src/seq.c
index f8b7205e2..665461d58 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;
}