ft_strnstr: return haystack when needle is empty
This commit is contained in:
parent
f5e1bb9fdd
commit
b0e9b728d0
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/05 11:35:03 by tmaze #+# #+# */
|
/* Created: 2018/04/05 11:35:03 by tmaze #+# #+# */
|
||||||
/* Updated: 2018/04/05 11:47:18 by tmaze ### ########.fr */
|
/* Updated: 2018/04/08 15:28:28 by tmaze ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ char *ft_strnstr(const char *haystack, const char *needle, size_t len)
|
|||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
tmp = (char*)haystack;
|
tmp = (char*)haystack;
|
||||||
|
if (ft_strequ(needle, ""))
|
||||||
|
return (tmp);
|
||||||
while ((++i == 0 || tmp[i - 1]) && i < (int)len)
|
while ((++i == 0 || tmp[i - 1]) && i < (int)len)
|
||||||
if (tmp[i] == needle[0] && (j = 1))
|
if (tmp[i] == needle[0] && (j = 1))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user