Subject: Re: bug#34951: [PATCH] grep: a kwset matcher not work in a grep matcher

From: [email-masked]
Date: Thu, 12 Dec 2019 00:23:06 -0700

Hi Paul.

Paul Eggert <[email-masked]> wrote:

> On 3/22/19 7:49 PM, Norihiro Tanaka wrote:
> > Missing a patch for dfa.  Re-send correct patch file.
>
> Thanks, I installed the DFA-relevant parts of your proposed fix into 
> Gnulib. (The grep parts still need doing.) I also installed the attached 
> commentary followup.
>
> While I was at it I installed a patch to fix an unlikely integer 
> overflow that I noticed while reviewing your fix. I also installed some 
> internal changes to prefer signed to unsigned integers for indexes, as 
> this should make future integer overflows easier to catch. See:
>
> https://lists.gnu.org/r/bug-gnulib/2019-12/msg00058.html
> https://lists.gnu.org/r/bug-gnulib/2019-12/msg00059.html

I am reviewing these. In general using signed integers internally
looks OK to me.

> I'd also like to change dfa.h's API to prefer ptrdiff_t to size_t, for 
> the same integer-overflow reason. This would be a (minor) API change so 
> I thought I'd ask first. Any objections?

Yes. I object. Strongly.

We're passing length and count values and those are supposed
to be size_t.  If you REALLY want signed values, then I could
live with ssize_t (as returned by read(2), for example), but I
would find ptrdiff_t to be ugly and unintuitive.

> PS. Arnold, the above discusses all the changes I know about for dfa.c 
> and dfa.h. The proposed API change (size_t->ptrdiff_t) could be 
> installed either before or after the next Gawk release.

Thanks. I'm skimming the other changes now.

Arnold