Fix bug that makes lines stick together
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 13 Oct 2023 14:03:41 +0000 (16:03 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 13 Oct 2023 14:03:41 +0000 (16:03 +0200)
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.

get_next_line.c

index 8d431e79826c5f6eb14f3aba042c505946499f34..ebfa2779cf651e8008d657783388236bd163e3f0 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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)