@@ -953,10 +953,16 @@ static void free_preprocessed_options(struct option *options)
953953 free (options );
954954}
955955
956+ #define USAGE_NORMAL 0
957+ #define USAGE_FULL 1
958+ #define USAGE_TO_STDOUT 0
959+ #define USAGE_TO_STDERR 1
960+
956961static enum parse_opt_result usage_with_options_internal (struct parse_opt_ctx_t * ,
957962 const char * const * ,
958963 const struct option * ,
959- int , int );
964+ int full_usage ,
965+ int usage_to_stderr );
960966
961967enum parse_opt_result parse_options_step (struct parse_opt_ctx_t * ctx ,
962968 const struct option * options ,
@@ -1088,7 +1094,8 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
10881094 }
10891095
10901096 if (internal_help && !strcmp (arg + 2 , "help-all" ))
1091- return usage_with_options_internal (ctx , usagestr , options , 1 , 0 );
1097+ return usage_with_options_internal (ctx , usagestr , options ,
1098+ USAGE_FULL , USAGE_TO_STDOUT );
10921099 if (internal_help && !strcmp (arg + 2 , "help" ))
10931100 goto show_usage ;
10941101 switch (parse_long_opt (ctx , arg + 2 , options )) {
@@ -1129,7 +1136,8 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
11291136 return PARSE_OPT_DONE ;
11301137
11311138 show_usage :
1132- return usage_with_options_internal (ctx , usagestr , options , 0 , 0 );
1139+ return usage_with_options_internal (ctx , usagestr , options ,
1140+ USAGE_NORMAL , USAGE_TO_STDOUT );
11331141}
11341142
11351143int parse_options_end (struct parse_opt_ctx_t * ctx )
@@ -1444,17 +1452,25 @@ static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t
14441452void NORETURN usage_with_options (const char * const * usagestr ,
14451453 const struct option * opts )
14461454{
1447- usage_with_options_internal (NULL , usagestr , opts , 0 , 1 );
1455+ usage_with_options_internal (NULL , usagestr , opts ,
1456+ USAGE_NORMAL , USAGE_TO_STDERR );
14481457 exit (129 );
14491458}
14501459
14511460void show_usage_with_options_if_asked (int ac , const char * * av ,
14521461 const char * const * usagestr ,
14531462 const struct option * opts )
14541463{
1455- if (ac == 2 && !strcmp (av [1 ], "-h" )) {
1456- usage_with_options_internal (NULL , usagestr , opts , 0 , 0 );
1457- exit (129 );
1464+ if (ac == 2 ) {
1465+ if (!strcmp (av [1 ], "-h" )) {
1466+ usage_with_options_internal (NULL , usagestr , opts ,
1467+ USAGE_NORMAL , USAGE_TO_STDOUT );
1468+ exit (129 );
1469+ } else if (!strcmp (av [1 ], "--help-all" )) {
1470+ usage_with_options_internal (NULL , usagestr , opts ,
1471+ USAGE_FULL , USAGE_TO_STDOUT );
1472+ exit (129 );
1473+ }
14581474 }
14591475}
14601476
0 commit comments