GNOME Bugzilla – Bug 697780
memmem -> g_strstr_len
Last modified: 2013-05-13 13:51:11 UTC
Created attachment 241243 [details] [review] use g_strstr_len() instead of GNU extension memmem Hi. This patch replaces the use of memmem with g_strstr_len. memmem is a GNU extension that is not available on all OSes.
Please go ahead Antoine ;)
Awesome, thank you Martyn :) => 045ede1
Guys, g_strstr_len accepts a nul-terminated string, and len is just a limiting factor on the size of @haystack. You cannot use it if either @haystack or @needle have embedded NULs.
Hi Giovanni. Thanks for the hint. It looks like in this situation we cannot replace memmem() by g_strstr_len() that easily... Any alternative on your mind?
(In reply to comment #3) > Guys, g_strstr_len accepts a nul-terminated string, and len is just a limiting > factor on the size of @haystack. > You cannot use it if either @haystack or @needle have embedded NULs. Shit. I didn't notice the part about NULLs. My bad. Sorry Antoine.
Hi Martyn. Coming back to you on that memmem() thing. As far as I can see, from the major BSDs, only OpenBSD is missing this function. So what I am proposing is to revert this commit and I'll work on implementing memmem() on OpenBSD. Would it be alright for you?
(In reply to comment #6) > Hi Martyn. > > Coming back to you on that memmem() thing. As far as I can see, from the major > BSDs, only OpenBSD is missing this function. So what I am proposing is to > revert this commit and I'll work on implementing memmem() on OpenBSD. > Would it be alright for you? I agree. A copy/paste of the code and a comment referencing where we got it from might suffice if we need to modify it. Please go ahead. I think this is another candidate for the libtracker-common/tracker-os-dependant.h area so we keep these cases isolated. Thanks, :)
Ok, it's reverted. I'm not sure what you meant by the copy/paste of the code... what I meant in my former message was that I would work on including memmem() to our libc in OpenBSD, which means nothing to change on the tracker side :)
(In reply to comment #8) > Ok, it's reverted. > I'm not sure what you meant by the copy/paste of the code... what I meant in my > former message was that I would work on including memmem() to our libc in > OpenBSD, which means nothing to change on the tracker side :) That is indeed a better solution. By copy/paste I meant taking what we use on Linux and making it available on OpenBSD by copying the memmem() function into our libtracker-common. e.g. #ifndef memmem ... #endif
(In reply to comment #9) > (In reply to comment #8) > > Ok, it's reverted. > > I'm not sure what you meant by the copy/paste of the code... what I meant in my > > former message was that I would work on including memmem() to our libc in > > OpenBSD, which means nothing to change on the tracker side :) > > That is indeed a better solution. > > By copy/paste I meant taking what we use on Linux and making it available on > OpenBSD by copying the memmem() function into our libtracker-common. e.g. > #ifndef memmem > ... > #endif Yeah that's what I though :-) Anyway, issue fixed at the core today: http://anoncvs.estpak.ee/cgi-bin/cgit/openbsd-src/commit/?id=960b560e29eab2c3849023de1d05751d3cf156e6