After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697780 - memmem -> g_strstr_len
memmem -> g_strstr_len
Status: RESOLVED NOTABUG
Product: tracker
Classification: Core
Component: Extractor
0.16.x
Other OpenBSD
: Normal normal
: ---
Assigned To: tracker-extractor
Depends on:
Blocks:
 
 
Reported: 2013-04-11 11:18 UTC by Antoine Jacoutot
Modified: 2013-05-13 13:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
use g_strstr_len() instead of GNU extension memmem (922 bytes, patch)
2013-04-11 11:18 UTC, Antoine Jacoutot
accepted-commit_now Details | Review

Description Antoine Jacoutot 2013-04-11 11:18:38 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.
Comment 1 Martyn Russell 2013-04-11 18:10:50 UTC
Please go ahead Antoine ;)
Comment 2 Antoine Jacoutot 2013-04-11 18:37:10 UTC
Awesome, thank you Martyn :)
=> 045ede1
Comment 3 Giovanni Campagna 2013-04-12 13:12:24 UTC
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.
Comment 4 Antoine Jacoutot 2013-04-12 14:31:32 UTC
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?
Comment 5 Martyn Russell 2013-04-15 12:02:38 UTC
(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.
Comment 6 Antoine Jacoutot 2013-05-08 06:08:05 UTC
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?
Comment 7 Martyn Russell 2013-05-08 12:39:59 UTC
(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, :)
Comment 8 Antoine Jacoutot 2013-05-08 13:59:49 UTC
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 :)
Comment 9 Martyn Russell 2013-05-13 13:45:10 UTC
(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
Comment 10 Antoine Jacoutot 2013-05-13 13:51:11 UTC
(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