/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "seq"
-#define AUTHORS "Ulrich Drepper"
+#define WRITTEN_BY _("Written by Ulrich Drepper.")
/* If nonzero print all number with equal width. */
static int equal_width;
static double first;
/* The increment. */
-static double step;
+static double step = 1.0;
/* The last number. */
static double last;
static int
print_numbers (const char *fmt)
{
- if (first > last)
- {
- int i;
-
- if (step >= 0)
- {
- error (0, 0,
- _("when the starting value is larger than the limit,\n\
-the increment must be negative"));
- usage (EXIT_FAILURE);
- }
-
- printf (fmt, first);
- for (i = 1; /* empty */; i++)
- {
- double x = first + i * step;
+ int i;
- if (x < last)
- break;
-
- fputs (separator, stdout);
- printf (fmt, x);
- }
- }
- else
+ for (i = 0; /* empty */; i++)
{
- int i;
-
- if (step <= 0)
- {
- error (0, 0,
- _("when the starting value is smaller than the limit,\n\
-the increment must be positive"));
- usage (EXIT_FAILURE);
- }
-
- printf (fmt, first);
- for (i = 1; /* empty */; i++)
- {
- double x = first + i * step;
-
- if (x > last)
- break;
-
- fputs (separator, stdout);
- printf (fmt, x);
- }
+ double x = first + i * step;
+ if (step < 0 ? x < last : last < x)
+ break;
+ if (i)
+ fputs (separator, stdout);
+ printf (fmt, x);
}
- fputs (terminator, stdout);
+
+ if (i)
+ fputs (terminator, stdout);
return 0;
}
}
sprintf (buffer, "%g", rint (max_val));
- if (buffer[strspn (buffer, "0123456789")] != '\0')
+ if (buffer[strspn (buffer, "-0123456789")] != '\0')
return "%g";
width1 = strlen (buffer);
{
int errs;
int optc;
- int step_is_set;
/* The printf(3) format used for output. */
char *format_str = NULL;
equal_width = 0;
separator = "\n";
first = 1.0;
- step_is_set = 0;
/* Figure out the locale's idea of a decimal point. */
#if HAVE_LOCALECONV
case_GETOPT_HELP_CHAR;
- case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ case_GETOPT_VERSION_CHAR (PROGRAM_NAME, WRITTEN_BY);
default:
usage (EXIT_FAILURE);
if (optind < argc)
{
step = last;
- step_is_set = 1;
last = scan_double_arg (argv[optind++]);
-
}
}
usage (EXIT_FAILURE);
}
- if (!step_is_set)
- {
- step = first <= last ? 1.0 : -1.0;
- }
-
if (format_str == NULL)
{
if (equal_width)