diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 6 insertions, 24 deletions
@@ -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); } |