Re: [PATCH 1/2] [GSOC] ref-filter: add %(raw) atom
- From
Felipe Contreras <felipe.contreras@gmail.com>
- Date
- May 29, 2021, 15:24 UTC
- Message-ID
- <60b25ca7a01c2_265088208af@natae.notmuch>
- In-Reply-To
- <13c63e79-27fd-58d5-9a4c-6b58c40ef4b8@gmail.com>
Phillip Wood wrote:
Show 11 quoted lines
> On 27/05/2021 17:36, Felipe Contreras wrote: > > ZheNing Hu via GitGitGadget wrote: > > [...] > >> +static int memcasecmp(const void *vs1, const void *vs2, size_t n) > > > > Why void *? We can delcare as char *. > > If you look at how this function is used you'll see > int (*cmp_fn)(const void *, const void *, size_t); > cmp_fn = s->sort_flags & REF_SORTING_ICASE > ? memcasecmp : memcmp;
Yeah, but why?
We know we are comparing two char *. Presumably the reason is that memcmp and memcasecmp use void *, but that could be remedied with:
cmp_fn = (int (*)(const char *, const char *, size_t))memcmp;
That way the same cmp_fn could be used for the two cases.
Either way I don't care particularly much. It also could be possible to use void * and do the casting in tolower().
Show 5 quoted lines
> > (and I personally prefer lower to upper) > > We should be using tolower() as that is what POSIX specifies for > strcasecmp() [1] which we are trying to emulate and there are cases[2] where > (tolower(c1) == tolower(c2)) != (toupper(c1) == toupper(c2))
That's true.
-- Felipe Contreras