testing
This commit is contained in:
parent
daeae8bb0f
commit
071672f7c1
14
ft_getline.c
14
ft_getline.c
@ -6,11 +6,12 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/03/07 15:12:59 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 "libft.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
static int get_last_ind(char *buff)
|
static int get_last_ind(char *buff)
|
||||||
{
|
{
|
||||||
@ -51,6 +52,13 @@ static int flush_buff(char **line, char *buff)
|
|||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void init_getline(char **line, int *check, int *ret)
|
||||||
|
{
|
||||||
|
*line = NULL;
|
||||||
|
*check = BUFF_SIZE;
|
||||||
|
*ret = -2;
|
||||||
|
}
|
||||||
|
|
||||||
int ft_getline(char **line)
|
int ft_getline(char **line)
|
||||||
{
|
{
|
||||||
static char buff[BUFF_SIZE] = "\0";
|
static char buff[BUFF_SIZE] = "\0";
|
||||||
@ -60,8 +68,7 @@ int ft_getline(char **line)
|
|||||||
|
|
||||||
if (line == NULL || BUFF_SIZE < 1)
|
if (line == NULL || BUFF_SIZE < 1)
|
||||||
return (-1);
|
return (-1);
|
||||||
*line = NULL;
|
init_getline(line, &check, &ret);
|
||||||
check = BUFF_SIZE;
|
|
||||||
while (check == BUFF_SIZE)
|
while (check == BUFF_SIZE)
|
||||||
{
|
{
|
||||||
if (buff[0] == '\0')
|
if (buff[0] == '\0')
|
||||||
@ -71,6 +78,7 @@ int ft_getline(char **line)
|
|||||||
if (ret == 0 && *line == NULL)
|
if (ret == 0 && *line == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
ft_printf("=== debug ===\nbuff: '%s'\nret: %d\n", buff, ret);
|
||||||
if ((i = flush_buff(line, buff)) == -1)
|
if ((i = flush_buff(line, buff)) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
check = (buff[i] == '\0' && i != ret) ? BUFF_SIZE : i;
|
check = (buff[i] == '\0' && i != ret) ? BUFF_SIZE : i;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/04/07 22:37:44 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)
|
if (s != NULL)
|
||||||
ft_putstr(s);
|
ft_putstr(s);
|
||||||
ft_putchar('\n');
|
write(0, "\n", 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user