]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Display version information after parsing every option
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 17:39:44 +0000 (19:39 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 9 Jun 2015 17:39:44 +0000 (19:39 +0200)
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.

log.c

diff --git a/log.c b/log.c
index 905fa294e4b1f5d2804c7b21c28299942613387c..30561a0a8c148099fb285bc19727a19f74995bea 100644 (file)
--- 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);