Topologically sort the functions and remove fwd declarations.
authorJim Meyering <jim@meyering.net>
Sat, 22 Jan 2000 12:36:35 +0000 (12:36 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 22 Jan 2000 12:36:35 +0000 (12:36 +0000)
src/seq.c

index a9f0f06..a33907f 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -51,11 +51,6 @@ typedef enum Format_type Format_type;
     }                                          \
   while (0)
 
-static double scan_arg PARAMS ((const char *arg));
-static int check_format PARAMS ((const char *format_string, Format_type *format_type));
-static char *get_width_format PARAMS ((void));
-static int print_numbers PARAMS ((const char *format_str));
-
 /* If nonzero print all number with equal width.  */
 static int equal_width;
 
@@ -130,153 +125,6 @@ integer output formats %%d, %%u, %%o, %%x, %%X.\n\
   exit (status);
 }
 
-int
-main (int argc, char **argv)
-{
-  int errs;
-  int optc;
-  int step_is_set;
-  int format_ok;
-
-  /* The printf(3) format used for output.  */
-  char *format_str = NULL;
-
-  program_name = argv[0];
-  setlocale (LC_ALL, "");
-  bindtextdomain (PACKAGE, LOCALEDIR);
-  textdomain (PACKAGE);
-
-  equal_width = 0;
-  separator = "\n";
-  first = 1.0;
-  step_is_set = 0;
-
-  /* Figure out the locale's idea of a decimal point.  */
-#ifdef HAVE_LOCALECONV
-  {
-    struct lconv *locale;
-
-    locale = localeconv ();
-    /* Paranoia.  */
-    if (locale && locale->decimal_point && locale->decimal_point[0] != '\0')
-      decimal_point = locale->decimal_point;
-  }
-#endif
-
-  /* We have to handle negative numbers in the command line but this
-     conflicts with the command line arguments.  So explicitly check first
-     whether the next argument looks like a negative number.  */
-  while (optind < argc)
-    {
-      if (argv[optind][0] == '-'
-         && ((optc = argv[optind][1]) == decimal_point[0]
-             || ISDIGIT (optc)))
-       {
-         /* means negative number */
-         break;
-       }
-
-      optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);
-      if (optc == -1)
-       break;
-
-      switch (optc)
-       {
-       case 0:
-         break;
-
-       case 'f':
-         format_str = optarg;
-         break;
-
-       case 's':
-         separator = optarg;
-         break;
-
-       case 'w':
-         equal_width = 1;
-         break;
-
-       case_GETOPT_HELP_CHAR;
-
-       case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
-
-       default:
-         usage (1);
-         /* NOTREACHED */
-       }
-    }
-
-  /* Set format_type before calling scan_arg.  */
-  if (format_str != NULL)
-    format_ok = check_format (format_str, &format_type);
-  else
-    {
-      format_ok = 1;
-      format_type = FT_DOUBLE;
-    }
-
-  if (optind >= argc)
-    {
-      error (0, 0, _("too few arguments"));
-      usage (1);
-      /* NOTREACHED */
-    }
-  last = scan_arg (argv[optind++]);
-
-  if (optind < argc)
-    {
-      first = last;
-      last = scan_arg (argv[optind++]);
-
-      if (optind < argc)
-       {
-         step = last;
-         step_is_set = 1;
-         last = scan_arg (argv[optind++]);
-
-         if (optind < argc)
-           {
-             usage (1);
-             /* NOTREACHED */
-           }
-       }
-    }
-
-  if (format_str != NULL && equal_width)
-    {
-      error (0, 0, _("\
-format string may not be specified when printing equal width strings"));
-      usage (1);
-    }
-
-  if (!step_is_set)
-    {
-      step = first <= last ? 1.0 : -1.0;
-    }
-
-  if (format_str != NULL)
-    {
-      if (!format_ok)
-       {
-         error (0, 0, _("invalid format string: `%s'"), format_str);
-         usage (1);
-       }
-    }
-  else
-    {
-      if (equal_width)
-       format_str = get_width_format ();
-      else
-       format_str = "%g";
-    }
-
-  errs = print_numbers (format_str);
-
-  exit (errs);
-  /* NOTREACHED */
-}
-
 /* Read a double value from the command line.
    Return if the string is correct else signal error.  */
 
@@ -385,6 +233,66 @@ check_format (const char *fmt, Format_type *format_type_ptr)
   return 1;
 }
 
+/* Actually print the sequence of numbers in the specified range, with the
+   given or default stepping and format.  */
+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 (1);
+         /* NOTREACHED */
+       }
+
+      DO_printf (fmt, first);
+      for (i = 1; /* empty */; i++)
+       {
+         double x = first + i * step;
+
+         if (x < last)
+           break;
+
+         fputs (separator, stdout);
+         DO_printf (fmt, x);
+       }
+    }
+  else
+    {
+      int i;
+
+      if (step <= 0)
+       {
+         error (0, 0,
+                _("when the starting value is smaller than the limit,\n\
+the increment must be positive"));
+         usage (1);
+         /* NOTREACHED */
+       }
+
+      DO_printf (fmt, first);
+      for (i = 1; /* empty */; i++)
+       {
+         double x = first + i * step;
+
+         if (x > last)
+           break;
+
+         fputs (separator, stdout);
+         DO_printf (fmt, x);
+       }
+    }
+  fputs (terminator, stdout);
+
+  return 0;
+}
+
 #if defined (HAVE_RINT) && defined (HAVE_MODF) && defined (HAVE_FLOOR)
 
 /* Return a printf-style format string with which all selected numbers
@@ -479,62 +387,149 @@ get_width_format (void)
 
 #endif
 
-/* Actually print the sequence of numbers in the specified range, with the
-   given or default stepping and format.  */
-static int
-print_numbers (const char *fmt)
+int
+main (int argc, char **argv)
 {
-  if (first > last)
-    {
-      int i;
+  int errs;
+  int optc;
+  int step_is_set;
+  int format_ok;
 
-      if (step >= 0)
+  /* The printf(3) format used for output.  */
+  char *format_str = NULL;
+
+  program_name = argv[0];
+  setlocale (LC_ALL, "");
+  bindtextdomain (PACKAGE, LOCALEDIR);
+  textdomain (PACKAGE);
+
+  equal_width = 0;
+  separator = "\n";
+  first = 1.0;
+  step_is_set = 0;
+
+  /* Figure out the locale's idea of a decimal point.  */
+#ifdef HAVE_LOCALECONV
+  {
+    struct lconv *locale;
+
+    locale = localeconv ();
+    /* Paranoia.  */
+    if (locale && locale->decimal_point && locale->decimal_point[0] != '\0')
+      decimal_point = locale->decimal_point;
+  }
+#endif
+
+  /* We have to handle negative numbers in the command line but this
+     conflicts with the command line arguments.  So explicitly check first
+     whether the next argument looks like a negative number.  */
+  while (optind < argc)
+    {
+      if (argv[optind][0] == '-'
+         && ((optc = argv[optind][1]) == decimal_point[0]
+             || ISDIGIT (optc)))
        {
-         error (0, 0,
-                _("when the starting value is larger than the limit,\n\
-the increment must be negative"));
-         usage (1);
-         /* NOTREACHED */
+         /* means negative number */
+         break;
        }
 
-      DO_printf (fmt, first);
-      for (i = 1; /* empty */; i++)
+      optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);
+      if (optc == -1)
+       break;
+
+      switch (optc)
        {
-         double x = first + i * step;
+       case 0:
+         break;
 
-         if (x < last)
-           break;
+       case 'f':
+         format_str = optarg;
+         break;
 
-         fputs (separator, stdout);
-         DO_printf (fmt, x);
+       case 's':
+         separator = optarg;
+         break;
+
+       case 'w':
+         equal_width = 1;
+         break;
+
+       case_GETOPT_HELP_CHAR;
+
+       case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+
+       default:
+         usage (1);
+         /* NOTREACHED */
        }
     }
+
+  /* Set format_type before calling scan_arg.  */
+  if (format_str != NULL)
+    format_ok = check_format (format_str, &format_type);
   else
     {
-      int i;
+      format_ok = 1;
+      format_type = FT_DOUBLE;
+    }
 
-      if (step <= 0)
+  if (optind >= argc)
+    {
+      error (0, 0, _("too few arguments"));
+      usage (1);
+      /* NOTREACHED */
+    }
+  last = scan_arg (argv[optind++]);
+
+  if (optind < argc)
+    {
+      first = last;
+      last = scan_arg (argv[optind++]);
+
+      if (optind < argc)
        {
-         error (0, 0,
-                _("when the starting value is smaller than the limit,\n\
-the increment must be positive"));
-         usage (1);
-         /* NOTREACHED */
+         step = last;
+         step_is_set = 1;
+         last = scan_arg (argv[optind++]);
+
+         if (optind < argc)
+           {
+             usage (1);
+             /* NOTREACHED */
+           }
        }
+    }
 
-      DO_printf (fmt, first);
-      for (i = 1; /* empty */; i++)
-       {
-         double x = first + i * step;
+  if (format_str != NULL && equal_width)
+    {
+      error (0, 0, _("\
+format string may not be specified when printing equal width strings"));
+      usage (1);
+    }
 
-         if (x > last)
-           break;
+  if (!step_is_set)
+    {
+      step = first <= last ? 1.0 : -1.0;
+    }
 
-         fputs (separator, stdout);
-         DO_printf (fmt, x);
+  if (format_str != NULL)
+    {
+      if (!format_ok)
+       {
+         error (0, 0, _("invalid format string: `%s'"), format_str);
+         usage (1);
        }
     }
-  fputs (terminator, stdout);
+  else
+    {
+      if (equal_width)
+       format_str = get_width_format ();
+      else
+       format_str = "%g";
+    }
 
-  return 0;
+  errs = print_numbers (format_str);
+
+  exit (errs);
+  /* NOTREACHED */
 }