summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2019-12-27 17:24:35 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2019-12-27 17:24:35 +0100
commitfc29371a10bf6cfd93c4e9ccfe9193c1311efc98 (patch)
treee5e67174f06e99d945fa2631bbd0648e1fafeec1 /src/main.c
parentSTDIN corrected (diff)
download42-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.c30
1 files changed, 6 insertions, 24 deletions
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);
}