From b17e34e030da007956be7f3c003d1d6b570e3b1e Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Sat, 1 Jun 2024 13:54:32 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20w?= =?UTF-8?q?ip:=20testing=20things,=20might=20broke.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parsing/tokenizer/__to_token.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/parsing/tokenizer/__to_token.c b/src/parsing/tokenizer/__to_token.c index c493745..f873c70 100644 --- a/src/parsing/tokenizer/__to_token.c +++ b/src/parsing/tokenizer/__to_token.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/20 21:05:04 by adjoly #+# #+# */ -/* Updated: 2024/05/30 16:37:16 by adjoly ### ########.fr */ +/* Updated: 2024/05/31 19:55:28 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,8 +31,6 @@ size_t __get_sizeof_redir(char *redir_s, t_redirection *redir) while (*++tmp && *tmp == ' ') i++; i += ft_strlen(redir->file_name); - //if (redir->sign == OUT_APPEND || redir->sign == HEREDOC) - //i++; return (i); } From e6e7a823d4f19d035d409f921f3308d9211203b1 Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Tue, 4 Jun 2024 13:20:51 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20Cha?= =?UTF-8?q?nge=20argv=20from=20char*=20to=20char**?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/parsing.h | 4 ++-- src/parsing/debug_print.c | 11 ++++++++++- src/parsing/split_cmd.c | 7 ++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/parsing.h b/include/parsing.h index 3467091..d64b975 100644 --- a/include/parsing.h +++ b/include/parsing.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */ -/* Updated: 2024/05/31 13:17:38 by adjoly ### ########.fr */ +/* Updated: 2024/06/04 13:15:24 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ typedef struct s_cmd { char *cmd; - char *argv; + char **argv; int infile; int outfile; } t_cmd; diff --git a/src/parsing/debug_print.c b/src/parsing/debug_print.c index 38a93c6..51a8599 100644 --- a/src/parsing/debug_print.c +++ b/src/parsing/debug_print.c @@ -48,6 +48,9 @@ void print_token(t_token *token) void print_cmd(t_cmd *cmd) { + char **tmp; + + tmp = cmd->argv; ft_putstr_fd("INFILE fd : ", STDOUT_FILENO); ft_putnbr_fd(cmd->infile, STDOUT_FILENO); ft_putchar_fd('\n', STDOUT_FILENO); @@ -57,5 +60,11 @@ void print_cmd(t_cmd *cmd) ft_putstr_fd("cmd : ", STDOUT_FILENO); ft_putendl_fd(cmd->cmd, STDOUT_FILENO); ft_putstr_fd("argv : ", STDOUT_FILENO); - ft_putendl_fd(cmd->argv, STDOUT_FILENO); + while (*tmp) + { + ft_putstr_fd(*tmp, STDOUT_FILENO); + ft_putchar_fd(' ', STDOUT_FILENO); + tmp++; + } + ft_putchar_fd('\n', STDOUT_FILENO); } diff --git a/src/parsing/split_cmd.c b/src/parsing/split_cmd.c index cb754ad..6422f07 100644 --- a/src/parsing/split_cmd.c +++ b/src/parsing/split_cmd.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/04 15:00:32 by adjoly #+# #+# */ -/* Updated: 2024/05/31 12:57:18 by adjoly ### ########.fr */ +/* Updated: 2024/06/04 13:15:47 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,9 +21,6 @@ t_cmd *split_cmd(char *cmd_av, t_cmd *cmd) tmp = cmd_av; split = ft_split(cmd_av, ' '); cmd->cmd = ft_strdup(*split); - ft_free("a", &split); - while (*tmp && *tmp == ' ') - tmp++; - cmd->argv = ft_strdup(tmp); + cmd->argv = split; return (cmd); }