diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-10-23 17:40:46 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-10-23 17:40:46 +0200 |
commit | abd3bd0b2d2c3869d81706d0266cfc561e4bc925 (patch) | |
tree | de58eb28ccb5c7679e2cb38d0d94eee8a2100479 /src/m_loop_next.c | |
parent | makeshift (diff) | |
download | 42-minishell-abd3bd0b2d2c3869d81706d0266cfc561e4bc925.tar.gz 42-minishell-abd3bd0b2d2c3869d81706d0266cfc561e4bc925.tar.bz2 42-minishell-abd3bd0b2d2c3869d81706d0266cfc561e4bc925.tar.xz 42-minishell-abd3bd0b2d2c3869d81706d0266cfc561e4bc925.tar.zst 42-minishell-abd3bd0b2d2c3869d81706d0266cfc561e4bc925.zip |
loadsamoney
Diffstat (limited to 'src/m_loop_next.c')
-rw-r--r-- | src/m_loop_next.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/m_loop_next.c b/src/m_loop_next.c index 90ffc01..6c0888f 100644 --- a/src/m_loop_next.c +++ b/src/m_loop_next.c @@ -24,12 +24,15 @@ static char char *counter_line; c_gnl(fd, &counter_line, psx, msh); - line = ft_nrealloc(line, - ft_strlen(line) + 1, - ft_strlen(line) + ft_strlen(counter_line)); - ft_memcpy(line + ft_strlen(line) - 1, - counter_line, - ft_strlen(counter_line) + 1); + if (counter_line[0] != 0) + { + line = ft_nrealloc(line, + ft_strlen(line) + 1, + ft_strlen(line) + ft_strlen(counter_line)); + ft_memcpy(line + ft_strlen(line) - 1, + counter_line, + ft_strlen(counter_line) + 1); + } ft_memdel((void*)&counter_line); return (line); } @@ -39,8 +42,6 @@ static char { char *counter_line; - if (fd == STDIN_FILENO) - m_prompt_psx(psx, msh); c_gnl(fd, &counter_line, psx, msh); if (counter_line[0] != 0) { |