This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] lmemmem.patch


On Mon, Mar 24, 2008 at 10:37 AM, DJ Delorie <dj@redhat.com> wrote:
>
>  Why not just provide a memmem() when it's needed?

This is the road I originally went down.  Wanting to not try to
provide a prototype when the system provided one made me switch to
lmemmem.

> The l*() functions
>  exist when the OS's functionality may differ, and we need something
>  more consistent, in which case we never call the OS version anyway.

Ah.  I didn't know this was a hard and fast rule.  Is this documented somewhere?

>  Note also that the Linux memmem man page says not to use memmem() as
>  the various versions of glibc have widely varying prototypes and
>  functionality:
>
>  BUGS
>        This function was broken in Linux libraries up to and including
>        libc 5.0.9; there the needle and haystack arguments were
>        interchanged, and a pointer to the end of the first occurrence
>        of needle was returned.  Since libc 5.0.9 is still widely used,
>        this is a dangerous function to use.
>
>        Both old and new libc's have the bug that if needle is empty
>        haystack-1 (instead of haystack) is returned.  And glibc 2.0
>        makes it worse, and returns a pointer to the last byte of
>        haystack.  This is fixed in glibc 2.1.

How old is this?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]