For getopt() arg processing:

- Use exit(0) for -h option as per convention;

For g_option...() arg processing (when USE_GOPTION is set):
 - Fix bug: 'capinfos x' doesn't print any info about x;
   (bug introduced in SVN #48481);
 - Use stderr for error messages related to cmd-line arg parsing;


svn path=/trunk/; revision=54555
This commit is contained in:
Bill Meier 2014-01-02 15:41:45 +00:00
parent be849dcaad
commit 8ef3e2fad3
1 changed files with 98 additions and 93 deletions

View File

@ -1192,18 +1192,23 @@ main(int argc, char *argv[])
argv[0] = (char *)"capinfos";
/* if we have at least one cmdline option, we disable printing all infos */
if (argc>=2 && report_all_infos)
if (argc > 2 && report_all_infos)
disable_all_infos();
if ( !g_option_context_parse(ctx, &argc, &argv, &parse_err) ) {
if(parse_err) g_print ("option parsing failed: %s\n", parse_err->message);
g_print("%s", g_option_context_get_help (ctx, TRUE, NULL));
if (parse_err)
g_printerr ("option parsing failed: %s\n", parse_err->message);
g_printerr("%s", g_option_context_get_help (ctx, TRUE, NULL));
exit(1);
}
if( cap_help || (argc < 2) ) {
if ( cap_help ) {
g_print("%s", g_option_context_get_help (ctx, FALSE, NULL));
exit(0);
}
if ( argc < 2 ) {
g_printerr("%s", g_option_context_get_help (ctx, FALSE, NULL));
exit(1);
}
g_option_context_free(ctx);
#endif /* USE_GOPTION */
@ -1351,7 +1356,7 @@ main(int argc, char *argv[])
case 'h':
usage(FALSE);
exit(1);
exit(0);
break;
case '?': /* Bad flag - print usage message */
@ -1448,10 +1453,10 @@ main(int argc, char *argv[])
*
* Local variables:
* c-basic-offset: 2
* tab-width: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=2 tabstop=2 expandtab:
* :indentSize=2:tabSize=2:noTabs=true:
* vi: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/