Re: [PATCH v4 05/12] ref-filter: introduce parsing functions for each valid atom
From: Eric Sunshine <hidden>
Date: 2016-06-15 23:08:08
On Sun, Feb 7, 2016 at 4:01 AM, Karthik Nayak [off-list ref] wrote:
On Sun, Feb 7, 2016 at 12:03 PM, Eric Sunshine [off-list ref] wrote:quoted
On Sat, Feb 6, 2016 at 10:15 AM, Karthik Nayak [off-list ref] wrote:quoted
I think the code needs to be changed to: - if ((!arg || len == arg - sp) && + if ((arg || len == ep - sp) && + (!arg || len == arg - sp) &&For completeness, for people reading the mailing list archive, a couple alternate fixes were presented elsewhere[1], with a personal bias toward: arg = memchr(...); if (!arg) arg = ep;There is a slight issue with this solution though, as you see 'arg' gets modified here, hence 'arg' passed to parser functions will never will null. [...] Else we could avoid this assignment and re-assignment by letting 'arg' hold the value it gets from memcmp(...) and use the solution provided by me or Ramsay (preferably) Ramsay's solution being arg = memchr(sp, ':', ep - sp); - if ((!arg || len == arg - sp) && + if ((( arg && len == arg - sp) || + (!arg && len == ep - sp )) && !memcmp(valid_atom[i].name, sp, len)) break;
Yep, Ramsey's fix is preferable.