diff options
author | Jim Meyering <jim@meyering.net> | 1995-01-08 20:20:19 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-01-08 20:20:19 +0000 |
commit | 98b530a36d3a718d916a8109b21270c61ee71f6b (patch) | |
tree | 507cea2a37edb82a87abf6f60fbfb7bd50e0adcf /src | |
parent | 9485d96553c6d15fc24615aed6d8a510023bcd75 (diff) | |
download | coreutils-98b530a36d3a718d916a8109b21270c61ee71f6b.tar.xz |
Remove FIXMEs.
(get_width_format): Use stub function if not all of the needed math
functions are available. From Ulrich.
(main): Give reason for failure.
Diffstat (limited to 'src')
-rw-r--r-- | src/seq.c | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -1,5 +1,5 @@ /* seq - print sequence of numbers to standard output. - Copyright (C) 1994 Free Software Foundation, Inc. + Copyright (C) 1994, 1995 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -160,7 +160,7 @@ main (argc, argv) if (optind >= argc) { - /* FIXME Give reason for failure. */ + error (0, 0, "too few arguments"); usage (2); /* NOTREACHED */ } @@ -285,12 +285,14 @@ check_format (format_string) return 1; } -/* Returns the format for that all printed numbers have the same width. */ +#if defined (HAVE_RINT) && defined (HAVE_MODF) && defined (HAVE_FLOOR) + +/* Return a printf-style format string with which all selected numbers + will format to strings of the same width. */ + static char * get_width_format () { - /* FIXME: why is this static? */ - /* FIXME: Are you sure this is guaranteed to be large enough? */ static char buffer[256]; int full_width; int frac_width; @@ -301,7 +303,6 @@ get_width_format () if (from > last) { - /* FIXME: don't use floor!! */ min_val = from - step * floor ((from - last) / step); max_val = from; } @@ -318,7 +319,6 @@ get_width_format () if (min_val < 0.0) { - /* FIXME: don't use rint!! */ (void) sprintf (buffer, "%g", rint (min_val)); if (buffer[strspn (buffer, "-0123456789")] != '\0') return "%g"; @@ -328,7 +328,6 @@ get_width_format () } full_width = width1; - /* FIXME: don't use modf!! */ (void) sprintf (buffer, "%g", 1.0 + modf (min_val, &temp)); width1 = strlen (buffer); if (width1 == 1) @@ -341,7 +340,6 @@ get_width_format () width1 -= 2; } - /* FIXME: don't use modf!! */ (void) sprintf (buffer, "%g", 1.0 + modf (step, &temp)); width2 = strlen (buffer); if (width2 == 1) @@ -363,6 +361,18 @@ get_width_format () return buffer; } +#else /* one of the math functions rint, modf, floor is missing. */ + +static char * +get_width_format () +{ + /* We cannot compute the needed information to determine the correct + answer. So we simply return a value that works for all cases. */ + return "%g"; +} + +#endif + /* Actually print the sequence of numbers in the specified range, with the given or default stepping and format. */ static int |