Skip to content
Snippets Groups Projects
Commit 1d8b86c6 authored by Lyndon Brown's avatar Lyndon Brown
Browse files

help: avoid printing range for simple positive numeric cases

(min: 0, max: int-max (signed max due to underlying signed var)).

printing a numeric type's range was already skipped when the range was
the default type min/max, however there are lots of such options that
only accept absolute values, setting zero as the lower bound and leaving
the upper bound as the type max, and for which help output is messier than
desirable both with an arguably unnecessary range output and also the large
value of INT_MAX/FLT_MAX.

this change additionally avoids printing the range in such cases, giving
cleaner and just as useful output.

it should be typically obvious from context that an option's lower bound
is zero in these cases, so significant user confusion is not expected.
furthermore, negative values are just silent capped currently at zero
anyway.
parent 183c8d99
Branches help2
No related tags found
No related merge requests found
......@@ -460,7 +460,7 @@ static void print_item(const module_t *m, const module_config_t *item,
free(pi_values);
free(ppsz_texts);
}
else if (item->min.i != INT64_MIN || item->max.i != INT64_MAX )
else if (item->max.i != INT64_MAX || (item->min.i != INT64_MIN && item->min.i != 0) )
{
if (asprintf(&typebuf, "%s [%"PRId64" .. %"PRId64"]",
type, item->min.i, item->max.i) >= 0)
......@@ -472,7 +472,7 @@ static void print_item(const module_t *m, const module_config_t *item,
}
case CONFIG_ITEM_FLOAT:
type = _("float");
if (item->min.f != -FLT_MAX || item->max.f != FLT_MAX)
if (item->max.f != FLT_MAX || (item->min.f != -FLT_MAX && item->min.f != 0.0) )
{
if (asprintf(&typebuf, "%s [%f .. %f]", type,
item->min.f, item->max.f) >= 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment