Fix here file delimiter recognition
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 1 Aug 2024 07:52:57 +0000 (09:52 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 1 Aug 2024 07:52:57 +0000 (09:52 +0200)
Because the input line always contains newline character, it has to only
be compared to the last but one character.

src/execution.c

index ce5ea5352fb62358f68cf431960a4cebdf75e405..e62fee4757911e6e8470e26dc23e62b852beb84f 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 08:57:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/08/01 09:47:44 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/08/01 09:51:23 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -274,7 +274,7 @@ int here_file_to_pipe(int pipe_fd, const char *delimiter, const t_execution_env
        expand = !ft_strcmp(unquoted_delimiter, delimiter);
        ft_printf("> ");
        line = get_next_line(STDIN_FILENO);
-       while (line && ft_strcmp(line, unquoted_delimiter))
+       while (line && ft_strncmp(line, unquoted_delimiter, ft_strlen(line) - 1))
        {
                if (write_line_to_pipe(pipe_fd, line, env, expand))
                {