diff --git a/ft_getline.c b/ft_getline.c index c3b7d8c..38fc3f7 100644 --- a/ft_getline.c +++ b/ft_getline.c @@ -6,11 +6,12 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/07 15:12:59 by tmaze #+# #+# */ -/* Updated: 2019/03/19 13:08:37 by tmaze ### ########.fr */ +/* Updated: 2019/03/19 14:20:25 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +#include static int get_last_ind(char *buff) { @@ -51,6 +52,13 @@ static int flush_buff(char **line, char *buff) return (i); } +static void init_getline(char **line, int *check, int *ret) +{ + *line = NULL; + *check = BUFF_SIZE; + *ret = -2; +} + int ft_getline(char **line) { static char buff[BUFF_SIZE] = "\0"; @@ -60,8 +68,7 @@ int ft_getline(char **line) if (line == NULL || BUFF_SIZE < 1) return (-1); - *line = NULL; - check = BUFF_SIZE; + init_getline(line, &check, &ret); while (check == BUFF_SIZE) { if (buff[0] == '\0') @@ -71,6 +78,7 @@ int ft_getline(char **line) if (ret == 0 && *line == NULL) return (0); } + ft_printf("=== debug ===\nbuff: '%s'\nret: %d\n", buff, ret); if ((i = flush_buff(line, buff)) == -1) return (-1); check = (buff[i] == '\0' && i != ret) ? BUFF_SIZE : i; diff --git a/ft_putendl.c b/ft_putendl.c index c7d1cd6..3418975 100644 --- a/ft_putendl.c +++ b/ft_putendl.c @@ -6,7 +6,7 @@ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/07 22:37:44 by tmaze #+# #+# */ -/* Updated: 2019/01/13 17:44:21 by tmaze ### ########.fr */ +/* Updated: 2019/03/19 14:33:02 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,5 +16,5 @@ void ft_putendl(char const *s) { if (s != NULL) ft_putstr(s); - ft_putchar('\n'); + write(0, "\n", 1); }