Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #3615

Re: memmem()

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: memmem()
Date 2011-05-09 08:45 -0700
Organization None to speak of
Message-ID <lnbozbq3nc.fsf@nuthaus.mib.org> (permalink)
References (1 earlier) <31d5f6ce-fca0-46f7-b18d-7148076e0f4f@v8g2000yqb.googlegroups.com> <iq6ac6$qu5$1@dont-email.me> <slrnisdf97.870.angel+news@pearlgates.net> <iq6esi$58j$1@dont-email.me> <82b10059-ef2b-426e-b578-58de4881b952@32g2000vbe.googlegroups.com>

Show all headers | View raw


puppi <fabricio.puppi@gmail.com> writes:
> 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.

Or you could use memcmp() in a loop.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

memmem() barcaroller <barcaroller@music.net> - 2011-05-07 22:53 -0400
  Re: memmem() "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-08 02:33 -0400
  Re: memmem() puppi <fabricio.puppi@gmail.com> - 2011-05-08 00:11 -0700
    Re: memmem() "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-08 04:36 -0400
    Re: memmem() James Kuyper <jameskuyper@verizon.net> - 2011-05-08 09:33 -0400
      Re: memmem() barcaroller <barcaroller@music.net> - 2011-05-08 10:48 -0400
    Re: memmem() barcaroller <barcaroller@gmail.com> - 2011-05-08 10:46 -0400
      Re: memmem() Angel <angel+news@spamcop.net> - 2011-05-08 15:56 +0000
        Re: memmem() barcaroller <barcaroller@music.net> - 2011-05-08 12:03 -0400
          Re: memmem() puppi <fabricio.puppi@gmail.com> - 2011-05-09 04:58 -0700
            Re: memmem() Keith Thompson <kst-u@mib.org> - 2011-05-09 08:45 -0700
      Re: memmem() puppi <fabricio.puppi@gmail.com> - 2011-05-09 04:47 -0700
  Re: memmem() blp@cs.stanford.edu (Ben Pfaff) - 2011-05-09 09:45 -0700
    Re: memmem() Nobody <nobody@nowhere.com> - 2011-05-10 07:19 +0100
      Re: memmem() Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-10 07:35 +0100
        Re: memmem() pete <pfiland@mindspring.com> - 2011-05-10 04:27 -0400
      Re: memmem() Ben Pfaff <blp@cs.stanford.edu> - 2011-05-10 07:16 -0700
        Re: memmem() Nobody <nobody@nowhere.com> - 2011-05-10 21:07 +0100

csiph-web