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>
This commit is contained in:
Hiltjo Posthuma 2014-04-04 17:05:16 +02:00 committed by sin
parent 6529caebe2
commit 139522b45e

19
stat.c
View File

@ -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;