Simplify getopt switch parsing.
Only one of these flags can be set. Just add them together and check the value. Also, get rid of the listall variable. The code is already filled with direct *flag-comparisons. Obtained from: Alexander Best (though modified)
This commit is contained in:
parent
ed1f6dc235
commit
66c5875a45
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=227335
@ -88,7 +88,6 @@ main(int argc, char *argv[])
|
|||||||
off_t savednumber, curblocks;
|
off_t savednumber, curblocks;
|
||||||
off_t threshold, threshold_sign;
|
off_t threshold, threshold_sign;
|
||||||
int ftsoptions;
|
int ftsoptions;
|
||||||
int listall;
|
|
||||||
int depth;
|
int depth;
|
||||||
int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag;
|
int Hflag, Lflag, Pflag, aflag, sflag, dflag, cflag;
|
||||||
int hflag, lflag, ch, notused, rval;
|
int hflag, lflag, ch, notused, rval;
|
||||||
@ -229,17 +228,10 @@ main(int argc, char *argv[])
|
|||||||
if (!Aflag && (cblocksize % DEV_BSIZE) != 0)
|
if (!Aflag && (cblocksize % DEV_BSIZE) != 0)
|
||||||
cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE;
|
cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE;
|
||||||
|
|
||||||
listall = 0;
|
if (aflag + dflag + sflag > 1)
|
||||||
|
usage();
|
||||||
if (aflag) {
|
if (sflag)
|
||||||
if (sflag || dflag)
|
|
||||||
usage();
|
|
||||||
listall = 1;
|
|
||||||
} else if (sflag) {
|
|
||||||
if (dflag)
|
|
||||||
usage();
|
|
||||||
depth = 0;
|
depth = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!*argv) {
|
if (!*argv) {
|
||||||
argv = save;
|
argv = save;
|
||||||
@ -320,7 +312,7 @@ main(int argc, char *argv[])
|
|||||||
howmany(p->fts_statp->st_size, cblocksize) :
|
howmany(p->fts_statp->st_size, cblocksize) :
|
||||||
howmany(p->fts_statp->st_blocks, cblocksize);
|
howmany(p->fts_statp->st_blocks, cblocksize);
|
||||||
|
|
||||||
if (listall || p->fts_level == 0) {
|
if (aflag || p->fts_level == 0) {
|
||||||
if (hflag) {
|
if (hflag) {
|
||||||
prthumanval(curblocks);
|
prthumanval(curblocks);
|
||||||
(void)printf("\t%s\n", p->fts_path);
|
(void)printf("\t%s\n", p->fts_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user