extern int string_to_bitarray(const char *list, char *ary,
int (*name2bit)(const char *, size_t));
-extern int parse_range(const char *str, int *lower, int *upper);
+extern int parse_range(const char *str, int *lower, int *upper, int def);
#endif
/*
* Parse the lower and higher values in a string containing
* "lower:higher" or "lower-higher" format. Note that either
- * the lower or the higher values may be missing.
+ * the lower or the higher values may be missing, and the def
+ * value will be assigned to it by default.
*
* Returns: 0 on success, <0 on error.
*/
-int parse_range(const char *str, int *lower, int *upper)
+int parse_range(const char *str, int *lower, int *upper, int def)
{
char *end = NULL;
if (!str)
return 0;
- *upper = *lower = 0;
+ *upper = *lower = def;
errno = 0;
if (*str == ':') { /* <:N> */
what = ACT_LIST;
break;
case 'n':
- if (parse_range(optarg, &lower, &upper))
+ if (parse_range(optarg, &lower, &upper, 0))
errx(EXIT_FAILURE, _("failed to parse --nr <M-N> range"));
break;
case 'o':