<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Aug 17, 2017 8:19 AM, "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="elided-text">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 ++++++++++++++++++++++++++++++<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 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 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 the<br>
> + * documentation and/or other materials provided with the distribution.<br>
> + * 3. Neither the name of the University nor the names of its contributors<br>
> + * may be used to endorse or promote products derived from this software<br>
> + * without specific prior written permission.<br>
> + *<br>
> + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 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 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>
</div>This can definitely be added in newlib. Aditya may be able to assist<br>
in the process?<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Agreed. This should be as widely available to RTEMS applications as possible.</div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="elided-text"><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>
</div></blockquote></div><br></div></div></div>