commit 139522b45e499b58b32e100777af701e75c895f2
Author: Hiltjo Posthuma <[email protected]>
Date:   Fri Apr 4 17:05:16 2014 +0200

    stat: declare initial functions to use at the top
    
    remove Lflag. this will be more clear for terse format later on aswell.
    
    Signed-off-by: Hiltjo Posthuma <[email protected]>

diff --git a/stat.c b/stat.c
index 93c4991..a4e4a67 100644
--- a/stat.c
+++ b/stat.c
@@ -24,13 +24,14 @@ main(int argc, char *argv[])
 {
        struct stat st;
        int i, ret = EXIT_SUCCESS;
-       int Lflag = 0;
-       int (*fn)(const char *, struct stat *);
-       char *fnname;
+       int (*fn)(const char *, struct stat *) = lstat;
+       char *fnname = "lstat";
+       void (*showstat)(const char *, struct stat *) = show_stat;
 
        ARGBEGIN {
        case 'L':
-               Lflag = 1;
+               fn = stat;
+               fnname = "stat";
                break;
        default:
                usage();
@@ -42,14 +43,6 @@ main(int argc, char *argv[])
                show_stat("<stdin>", &st);
        }
 
-       if (Lflag) {
-               fn = stat;
-               fnname = "stat";
-       } else {
-               fn = lstat;
-               fnname = "lstat";
-       }
-
        for (i = 0; i < argc; i++) {
                if (fn(argv[i], &st) == -1) {
                        fprintf(stderr, "%s %s: %s
", fnname,
@@ -57,7 +50,7 @@ main(int argc, char *argv[])
                        ret = EXIT_FAILURE;
                        continue;
                }
-               show_stat(argv[i], &st);
+               showstat(argv[i], &st);
        }
 
        return ret;


Reply via email to