summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
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);
}