/* 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
if (optind >= argc)
{
- /* FIXME Give reason for failure. */
+ error (0, 0, "too few arguments");
usage (2);
/* NOTREACHED */
}
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;
if (from > last)
{
- /* FIXME: don't use floor!! */
min_val = from - step * floor ((from - last) / step);
max_val = from;
}
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";
}
full_width = width1;
- /* FIXME: don't use modf!! */
(void) sprintf (buffer, "%g", 1.0 + modf (min_val, &temp));
width1 = strlen (buffer);
if (width1 == 1)
width1 -= 2;
}
- /* FIXME: don't use modf!! */
(void) sprintf (buffer, "%g", 1.0 + modf (step, &temp));
width2 = strlen (buffer);
if (width2 == 1)
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