@@ -953,10 +953,16 @@ static void free_preprocessed_options(struct option *options)
953
953
free (options );
954
954
}
955
955
956
+ #define USAGE_NORMAL 0
957
+ #define USAGE_FULL 1
958
+ #define USAGE_TO_STDOUT 0
959
+ #define USAGE_TO_STDERR 1
960
+
956
961
static enum parse_opt_result usage_with_options_internal (struct parse_opt_ctx_t * ,
957
962
const char * const * ,
958
963
const struct option * ,
959
- int , int );
964
+ int full_usage ,
965
+ int usage_to_stderr );
960
966
961
967
enum parse_opt_result parse_options_step (struct parse_opt_ctx_t * ctx ,
962
968
const struct option * options ,
@@ -1088,7 +1094,8 @@ enum parse_opt_result parse_options_step(struct parse_opt_ctx_t *ctx,
1088
1094
}
1089
1095
1090
1096
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 );
1092
1099
if (internal_help && !strcmp (arg + 2 , "help" ))
1093
1100
goto show_usage ;
1094
1101
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,
1129
1136
return PARSE_OPT_DONE ;
1130
1137
1131
1138
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 );
1133
1141
}
1134
1142
1135
1143
int 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
1444
1452
void NORETURN usage_with_options (const char * const * usagestr ,
1445
1453
const struct option * opts )
1446
1454
{
1447
- usage_with_options_internal (NULL , usagestr , opts , 0 , 1 );
1455
+ usage_with_options_internal (NULL , usagestr , opts ,
1456
+ USAGE_NORMAL , USAGE_TO_STDERR );
1448
1457
exit (129 );
1449
1458
}
1450
1459
1451
1460
void show_usage_with_options_if_asked (int ac , const char * * av ,
1452
1461
const char * const * usagestr ,
1453
1462
const struct option * opts )
1454
1463
{
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
+ }
1458
1474
}
1459
1475
}
1460
1476
0 commit comments