Re: [PATCH] grep: add --max-count command line option
Hi,
On Monday, June 20th, 2022 at 17:57, Paul Eggert <eggert@cs.ucla.edu> wrote:
Show 9 quoted lines
> On 6/20/22 10:49, Carlos L. via GitGitGadget wrote:
>
> > + unsigned max_count;
>
>
> Why not make this intmax_t? That way, you don't have to worry about
> casting -1 to unsigned. Also on typical 64-bit machines you no longer
> have to worry about mishandling counts greater than 232 (the limit
> becomes 263 - 1 which is plenty).
This does not work well with OPTION_INTEGER, since it assumes the value to be int-sized:
parse-options.c:
219 *(int *)opt->value = strtol(arg, (char **)&s, 10);
I also wanted to avoid using signed int so both sides of the comparison with `count` in grep_source_1() have the same sign.