From: Lukas Jiriste Date: Fri, 13 Oct 2023 14:03:41 +0000 (+0200) Subject: Fix bug that makes lines stick together X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=9d7a077a055bc9aa3769c281ba360cf91cd390de;p=42%2Fget_next_line.git Fix bug that makes lines stick together This bug is caused by ignoring newline character that appears exactly on the end of buffer. It is ignored because of a wrong logical operator. --- diff --git a/get_next_line.c b/get_next_line.c index 8d431e7..ebfa277 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/08/28 00:01:15 by ljiriste #+# #+# */ -/* Updated: 2023/09/11 18:39:13 by ljiriste ### ########.fr */ +/* Updated: 2023/10/13 16:01:58 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,7 +79,7 @@ static int transfer_string(char **res, char *buffer) i += nl; ft_strncat_alloc(res, buffer, i); ft_memmove(buffer, buffer + i, BUFFER_SIZE + 1 - i); - return (buffer[0] && nl); + return (buffer[0] || nl); } char *get_next_line(int fd)