mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-04-19 21:39:11 +00:00
incase of --help, usage is valid output
This commit is contained in:
parent
2d9bea188f
commit
0fe541b5fb
1 changed files with 7 additions and 6 deletions
13
main.c
13
main.c
|
@ -395,9 +395,9 @@ end:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printhelp(const char *progname)
|
static void printhelp(FILE *out,const char *progname)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(out,
|
||||||
"Usage: %s filter [filter...] [options]\n"
|
"Usage: %s filter [filter...] [options]\n"
|
||||||
" %s -f filterfile [options]\n"
|
" %s -f filterfile [options]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
|
@ -418,10 +418,11 @@ static void printhelp(const char *progname)
|
||||||
"\t-S t - print statistics every specified ammount of seconds\n"
|
"\t-S t - print statistics every specified ammount of seconds\n"
|
||||||
"\t-T - do not reset statistics counters when printing\n"
|
"\t-T - do not reset statistics counters when printing\n"
|
||||||
,progname,progname);
|
,progname,progname);
|
||||||
|
fflush(out);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setworkdir(const char *wd)
|
static void setworkdir(const char *wd)
|
||||||
{
|
{
|
||||||
free(workdir);
|
free(workdir);
|
||||||
size_t l = strlen(wd);
|
size_t l = strlen(wd);
|
||||||
|
@ -478,7 +479,7 @@ int main(int argc,char **argv)
|
||||||
|
|
||||||
const char *progname = argv[0];
|
const char *progname = argv[0];
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
printhelp(progname);
|
printhelp(stderr,progname);
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
|
|
||||||
while (argc--) {
|
while (argc--) {
|
||||||
|
@ -497,7 +498,7 @@ int main(int argc,char **argv)
|
||||||
if (!*arg)
|
if (!*arg)
|
||||||
ignoreargs = 1;
|
ignoreargs = 1;
|
||||||
else if (!strcmp(arg, "help"))
|
else if (!strcmp(arg, "help"))
|
||||||
printhelp(progname);
|
printhelp(stdout,progname);
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "unrecognised argument: --%s\n", arg);
|
fprintf(stderr, "unrecognised argument: --%s\n", arg);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -510,7 +511,7 @@ int main(int argc,char **argv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (*arg == 'h')
|
else if (*arg == 'h')
|
||||||
printhelp(progname);
|
printhelp(stdout,progname);
|
||||||
else if (*arg == 'f') {
|
else if (*arg == 'f') {
|
||||||
if (argc--)
|
if (argc--)
|
||||||
loadfilterfile(*argv++);
|
loadfilterfile(*argv++);
|
||||||
|
|
Loading…
Add table
Reference in a new issue