<div dir="auto">Yes, I can. </div><div class="gmail_extra"><br><div class="gmail_quote">On 17 Aug 2017 8:32 p.m., "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Aditya,<br>
<br>
Can you help Sichen to put the file in the right place in newlib and<br>
add to the build? Either help him understand how to do it, or do it<br>
with/for him?<br>
<br>
On Thu, Aug 17, 2017 at 10:58 AM, Aditya Upadhyay <<a href="mailto:aadit0402@gmail.com">aadit0402@gmail.com</a>> wrote:<br>
> Yes.. Definitely i will do. Sichen can directly send the patch for strnstr<br>
> to newlib ml.<br>
><br>
> Thanks,<br>
> Aditya Upadhyay<br>
><br>
> On 17 Aug 2017 7:03 p.m., "Joel Sherrill" <<a href="mailto:joel@rtems.org">joel@rtems.org</a>> wrote:<br>
>><br>
>><br>
>><br>
>> On Aug 17, 2017 8:19 AM, "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br>
>><br>
>> On Wed, Aug 16, 2017 at 8:14 PM, Sichen Zhao <<a href="mailto:1473996754@qq.com">1473996754@qq.com</a>> wrote:<br>
>> > ---<br>
>> >  freebsd/lib/libc/string/<wbr>strnstr.c | 67<br>
>> > ++++++++++++++++++++++++++++++<wbr>+++++++++<br>
>> >  1 file changed, 67 insertions(+)<br>
>> >  create mode 100644 freebsd/lib/libc/string/<wbr>strnstr.c<br>
>> ><br>
>> > diff --git a/freebsd/lib/libc/string/<wbr>strnstr.c<br>
>> > b/freebsd/lib/libc/string/<wbr>strnstr.c<br>
>> > new file mode 100644<br>
>> > index 0000000..247a2b5<br>
>> > --- /dev/null<br>
>> > +++ b/freebsd/lib/libc/string/<wbr>strnstr.c<br>
>> > @@ -0,0 +1,67 @@<br>
>> > +#include <machine/rtems-bsd-user-space.<wbr>h><br>
>> > +<br>
>> > +/*-<br>
>> > + * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org><br>
>> > + * Copyright (c) 1990, 1993<br>
>> > + *     The Regents of the University of California.  All rights<br>
>> > reserved.<br>
>> > + *<br>
>> > + * This code is derived from software contributed to Berkeley by<br>
>> > + * Chris Torek.<br>
>> > + *<br>
>> > + * Redistribution and use in source and binary forms, with or without<br>
>> > + * modification, are permitted provided that the following conditions<br>
>> > + * are met:<br>
>> > + * 1. Redistributions of source code must retain the above copyright<br>
>> > + *    notice, this list of conditions and the following disclaimer.<br>
>> > + * 2. Redistributions in binary form must reproduce the above copyright<br>
>> > + *    notice, this list of conditions and the following disclaimer in<br>
>> > the<br>
>> > + *    documentation and/or other materials provided with the<br>
>> > distribution.<br>
>> > + * 3. Neither the name of the University nor the names of its<br>
>> > contributors<br>
>> > + *    may be used to endorse or promote products derived from this<br>
>> > software<br>
>> > + *    without specific prior written permission.<br>
>> > + *<br>
>> > + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''<br>
>> > AND<br>
>> > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,<br>
>> > THE<br>
>> > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR<br>
>> > PURPOSE<br>
>> > + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE<br>
>> > LIABLE<br>
>> > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>
>> > CONSEQUENTIAL<br>
>> > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE<br>
>> > GOODS<br>
>> > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
>> > INTERRUPTION)<br>
>> > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,<br>
>> > STRICT<br>
>> > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN<br>
>> > ANY WAY<br>
>> > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY<br>
>> > OF<br>
>> > + * SUCH DAMAGE.<br>
>> > + */<br>
>> > +<br>
>> > +#if defined(LIBC_SCCS) && !defined(lint)<br>
>> > +static char sccsid[] = "@(#)strstr.c   8.1 (Berkeley) 6/4/93";<br>
>> > +#endif /* LIBC_SCCS and not lint */<br>
>> > +#include <sys/cdefs.h><br>
>> > +__FBSDID("$FreeBSD$");<br>
>> > +<br>
>> > +#include <string.h><br>
>> > +<br>
>> > +/*<br>
>> > + * Find the first occurrence of find in s, where the search is limited<br>
>> > to the<br>
>> > + * first slen characters of s.<br>
>> > + */<br>
>> > +char *<br>
>> > +strnstr(const char *s, const char *find, size_t slen)<br>
>> > +{<br>
>> > +       char c, sc;<br>
>> > +       size_t len;<br>
>> > +<br>
>> > +       if ((c = *find++) != '\0') {<br>
>> > +               len = strlen(find);<br>
>> > +               do {<br>
>> > +                       do {<br>
>> > +                               if (slen-- < 1 || (sc = *s++) == '\0')<br>
>> > +                                       return (NULL);<br>
>> > +                       } while (sc != c);<br>
>> > +                       if (len > slen)<br>
>> > +                               return (NULL);<br>
>> > +               } while (strncmp(s, find, len) != 0);<br>
>> > +               s--;<br>
>> > +       }<br>
>> > +       return ((char *)s);<br>
>> > +}<br>
>><br>
>> This can definitely be added in newlib. Aditya may be able to assist<br>
>> in the process?<br>
>><br>
>><br>
>> Agreed. This should be as widely available to RTEMS applications as<br>
>> possible.<br>
>><br>
>><br>
>><br>
>> > --<br>
>> > 2.7.4<br>
>> ><br>
>> > ______________________________<wbr>_________________<br>
>> > devel mailing list<br>
>> > <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
>> > <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
>> ______________________________<wbr>_________________<br>
>> devel mailing list<br>
>> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
>> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
>><br>
>><br>
><br>
</blockquote></div></div>