From fc29371a10bf6cfd93c4e9ccfe9193c1311efc98 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 27 Dec 2019 17:24:35 +0100 Subject: updated libft, better Makefile and .gitignore --- src/main.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3237496..618530d 100644 --- a/src/main.c +++ b/src/main.c @@ -21,34 +21,16 @@ int main(void) { - char c; - char *arg; - uint8_t i; + char *arg; + int gnlret; - i = 0; - arg = NULL; - while (1) + ft_putstr(FT_PS1); + while ((gnlret= get_next_line(STDIN_FILENO, &arg)) > 0) { - ft_putstr(FT_PS1); - if (arg) - { - free(arg); - arg = NULL; - } - if (!(arg = (char*)ft_calloc(129, sizeof(char)))) - return (1); - i = 0; - while (read(STDIN_FILENO, &c, 1) > 0) - { - if (c == '\n') - break ; - arg[i] = c; - i++; - } - arg[i] = '\0'; ft_process_arg(arg); + free(arg); + ft_putstr(FT_PS1); } free(arg); - arg = NULL; return (0); } -- cgit v1.2.3