ft_strstr: return haystack when needle is empty

This commit is contained in:
Tanguy MAZE 2018-04-08 15:27:14 +02:00
parent c0972ea18b
commit f5e1bb9fdd

View File

@ -6,7 +6,7 @@
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 10:54:41 by tmaze #+# #+# */
/* Updated: 2018/04/05 11:19:02 by tmaze ### ########.fr */
/* Updated: 2018/04/08 15:25:55 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,6 +20,8 @@ char *ft_strstr(const char *haystack, const char *needle)
i = -1;
tmp = (char*)haystack;
if (ft_strequ(needle, ""))
return (tmp);
while (++i == 0 || tmp[i - 1])
if (tmp[i] == needle[0] && (j = 1))
{