ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 139522b45e499b58b32e100777af701e75c895f2
parent 6529caebe20540a403522e30057f258d56a2b5ed
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  4 Apr 2014 17:05:16 +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 <hiltjo@codemadness.org>

Diffstat:
Mstat.c | 19++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)

diff --git 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\n", 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;