From: Frederic Marchal Date: Tue, 9 Jun 2015 17:39:44 +0000 (+0200) Subject: Display version information after parsing every option X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d6d7c7807b008a4db9899317cae835e999ae665b;p=thirdparty%2Fsarg.git Display version information after parsing every option The version can be displayed with command line option --version or -V but it is necessary to parse every option in case -x is provided. It is intended to display what features are available when -x is passed along with -V. --- diff --git a/log.c b/log.c index 905fa29..30561a0 100644 --- a/log.c +++ b/log.c @@ -80,6 +80,7 @@ int main(int argc,char *argv[]) static int convert=0; static int output_css=0; static int show_statis=0; + static int show_version=0; int option_index; static struct option long_options[]= { @@ -91,7 +92,7 @@ int main(int argc,char *argv[]) {"split",no_argument,&split,1}, {"splitprefix",required_argument,NULL,'P'}, {"statistics",no_argument,&show_statis,1}, - {"version",no_argument,NULL,'V'}, + {"version",no_argument,&show_version,'V'}, {0,0,0,0} }; @@ -396,7 +397,7 @@ int main(int argc,char *argv[]) safe_strcpy(us,optarg,sizeof(us)); break; case 'V': - version(); + show_version=1; break; case 'w': safe_strcpy(tmp,optarg,sizeof(tmp)); @@ -425,6 +426,9 @@ int main(int argc,char *argv[]) usage(argv[0]); exit(2); } + if (show_version) { + version(); + } if(output_css) { css_content(stdout);