diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-27 17:24:35 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2019-12-27 17:24:35 +0100 |
commit | fc29371a10bf6cfd93c4e9ccfe9193c1311efc98 (patch) | |
tree | e5e67174f06e99d945fa2631bbd0648e1fafeec1 /src/main.c | |
parent | STDIN corrected (diff) | |
download | 42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.gz 42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.bz2 42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.xz 42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.tar.zst 42-minishell-fc29371a10bf6cfd93c4e9ccfe9193c1311efc98.zip |
updated libft, better Makefile and .gitignore
Diffstat (limited to '')
-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); } |