(WRITTEN_BY): Rename from AUTHORS.
[platform/upstream/coreutils.git] / src / seq.c
index b073c3c..6f1cbc7 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -31,7 +31,7 @@
 /* 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;
@@ -55,7 +55,7 @@ static char *decimal_point = ".";
 static double first;
 
 /* The increment.  */
-static double step;
+static double step = 1.0;
 
 /* The last number.  */
 static double last;
@@ -178,55 +178,20 @@ valid_format (const char *fmt)
 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;
 }
@@ -259,7 +224,7 @@ get_width_format ()
     }
 
   sprintf (buffer, "%g", rint (max_val));
-  if (buffer[strspn (buffer, "0123456789")] != '\0')
+  if (buffer[strspn (buffer, "-0123456789")] != '\0')
     return "%g";
   width1 = strlen (buffer);
 
@@ -333,7 +298,6 @@ main (int argc, char **argv)
 {
   int errs;
   int optc;
-  int step_is_set;
 
   /* The printf(3) format used for output.  */
   char *format_str = NULL;
@@ -349,7 +313,6 @@ main (int argc, char **argv)
   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
@@ -399,7 +362,7 @@ main (int argc, char **argv)
 
        case_GETOPT_HELP_CHAR;
 
-       case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+       case_GETOPT_VERSION_CHAR (PROGRAM_NAME, WRITTEN_BY);
 
        default:
          usage (EXIT_FAILURE);
@@ -434,9 +397,7 @@ main (int argc, char **argv)
       if (optind < argc)
        {
          step = last;
-         step_is_set = 1;
          last = scan_double_arg (argv[optind++]);
-
        }
     }
 
@@ -447,11 +408,6 @@ format string may not be specified when printing equal width strings"));
       usage (EXIT_FAILURE);
     }
 
-  if (!step_is_set)
-    {
-      step = first <= last ? 1.0 : -1.0;
-    }
-
   if (format_str == NULL)
     {
       if (equal_width)