summaryrefslogtreecommitdiff
path: root/src/sum.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-10-29 20:19:26 +0000
committerJim Meyering <jim@meyering.net>1995-10-29 20:19:26 +0000
commitd2aaf842b4133088b842012c2637822f44f6a527 (patch)
treefd815de0922a1e9e128e202eec0c16d9bb95522d /src/sum.c
parent13e93efe916a66b2d12a0802c70fe079eb2b5fe1 (diff)
downloadcoreutils-d2aaf842b4133088b842012c2637822f44f6a527.tar.xz
(main): Move function body to end of file.
Remove forward dcls.
Diffstat (limited to 'src/sum.c')
-rw-r--r--src/sum.c120
1 files changed, 59 insertions, 61 deletions
diff --git a/src/sum.c b/src/sum.c
index a4f448775..890193d28 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -28,9 +28,6 @@
#include "version.h"
#include "error.h"
-static int bsd_sum_file ();
-static int sysv_sum_file ();
-
int safe_read ();
/* The name this program was run with. */
@@ -83,64 +80,6 @@ With no FILE, or when FILE is -, read standard input.\n\
exit (status);
}
-void
-main (argc, argv)
- int argc;
- char **argv;
-{
- int errors = 0;
- int optc;
- int files_given;
- int (*sum_func) () = bsd_sum_file;
-
- program_name = argv[0];
- have_read_stdin = 0;
-
- while ((optc = getopt_long (argc, argv, "rs", longopts, (int *) 0)) != -1)
- {
- switch (optc)
- {
- case 0:
- break;
-
- case 'r': /* For SysV compatibility. */
- sum_func = bsd_sum_file;
- break;
-
- case 's':
- sum_func = sysv_sum_file;
- break;
-
- default:
- usage (1);
- }
- }
-
- if (show_version)
- {
- printf ("sum - %s\n", version_string);
- exit (0);
- }
-
- if (show_help)
- usage (0);
-
- files_given = argc - optind;
- if (files_given == 0)
- {
- if ((*sum_func) ("-", files_given) < 0)
- errors = 1;
- }
- else
- for (; optind < argc; optind++)
- if ((*sum_func) (argv[optind], files_given) < 0)
- errors = 1;
-
- if (have_read_stdin && fclose (stdin) == EOF)
- error (1, errno, "-");
- exit (errors);
-}
-
/* Calculate and print the rotated checksum and the size in 1K blocks
of file FILE, or of the standard input if FILE is "-".
If PRINT_NAME is >1, print FILE next to the checksum and size.
@@ -265,3 +204,62 @@ sysv_sum_file (file, print_name)
return 0;
}
+
+void
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int errors = 0;
+ int optc;
+ int files_given;
+ int (*sum_func) () = bsd_sum_file;
+
+ program_name = argv[0];
+ have_read_stdin = 0;
+
+ while ((optc = getopt_long (argc, argv, "rs", longopts, (int *) 0)) != -1)
+ {
+ switch (optc)
+ {
+ case 0:
+ break;
+
+ case 'r': /* For SysV compatibility. */
+ sum_func = bsd_sum_file;
+ break;
+
+ case 's':
+ sum_func = sysv_sum_file;
+ break;
+
+ default:
+ usage (1);
+ }
+ }
+
+ if (show_version)
+ {
+ printf ("sum - %s\n", version_string);
+ exit (0);
+ }
+
+ if (show_help)
+ usage (0);
+
+ files_given = argc - optind;
+ if (files_given == 0)
+ {
+ if ((*sum_func) ("-", files_given) < 0)
+ errors = 1;
+ }
+ else
+ for (; optind < argc; optind++)
+ if ((*sum_func) (argv[optind], files_given) < 0)
+ errors = 1;
+
+ if (have_read_stdin && fclose (stdin) == EOF)
+ error (1, errno, "-");
+ exit (errors);
+}
+