puppi
5/9/2011 11:59:00 AM
On May 8, 1:03 pm, barcaroller <barcarol...@music.net> wrote:
> On 2011-05-08 11:56:23 -0400, Angel said:
>
> > You might want to be careful with that, memmem() is broken in several
> > versions of libc.
>
> I know that it was broken at some point in the past (in fact, it says
> so in the manpage) but my understanding is that it has now been fixed.
> If you know otherwise, please let me know (or point me to a source).
You could also bitwise AND with 0x01 each byte of the sequences to be
compared, filtering out the low bits (and preferably packing them 8 by
8 in a single byte), then bitwise OR the original sequences with 0x01,
put a sentinel 0x00 at the end and use 2 strstr()s (or 1 strstr() and
1 plain equality test for each possible match). Of course it wouldn't
be as efficient, but at least it's as alternative.