From d2aaf842b4133088b842012c2637822f44f6a527 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 29 Oct 1995 20:19:26 +0000 Subject: (main): Move function body to end of file. Remove forward dcls. --- src/sum.c | 120 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 61 deletions(-) (limited to 'src/sum.c') 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); +} + -- cgit v1.2.3-54-g00ecf