diff options
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) { |