From c27d653eaf56dc3132b21a7d92cf7315a192efb0 Mon Sep 17 00:00:00 2001 From: kinou-p Date: Sat, 12 Mar 2022 00:26:18 +0100 Subject: [PATCH] << start working --- srcs/set_redirection/redirection.c | 26 ++++++++++++++++++-------- srcs/set_redirection/utils.c | 6 +++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/srcs/set_redirection/redirection.c b/srcs/set_redirection/redirection.c index 46f8968..6002332 100644 --- a/srcs/set_redirection/redirection.c +++ b/srcs/set_redirection/redirection.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/03/09 15:18:58 by apommier #+# #+# */ -/* Updated: 2022/03/11 16:57:53 by apommier ### ########.fr */ +/* Updated: 2022/03/11 23:24:09 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -174,23 +174,28 @@ char **add_line(char **tab, char *line) int i; i = 0; - size = double_size(tab); - ret = malloc(sizeof(char *) * size + 2); + size = 0; + ret = 0; + if (tab) + size = double_size(tab); + //printf("size= %d\n", size); + ret = ft_calloc(size + 2, sizeof(char*)); if (!ret) { - if (tab) - free_double(tab); + // if (tab) + // free_double(tab); return (0); } while (tab && tab[i]) { - ret[i] == tab[i]; + printf("tab[i]= %s\n", tab[i]); + ret[i] = ft_strjoin(tab[i], 0); i++; } ret[i] = line; ret[i + 1] = 0; - if (tab) - free_double(tab); + //if (tab) + // free_double(tab); return(ret); } @@ -205,8 +210,13 @@ void wait_prompt(t_s_cmd *cmd) { input = readline("> "); history = add_line(history, input); + print_double(history); } + //print_double(history); + //free_double(history); free(input); + free(cmd->infile); + cmd->infile = 0; } char *set_redirection(t_s_cmd *cmd, char *line) diff --git a/srcs/set_redirection/utils.c b/srcs/set_redirection/utils.c index c600fec..0d221b6 100644 --- a/srcs/set_redirection/utils.c +++ b/srcs/set_redirection/utils.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/03/11 16:35:37 by apommier #+# #+# */ -/* Updated: 2022/03/11 17:04:07 by apommier ### ########.fr */ +/* Updated: 2022/03/11 23:28:49 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,9 +46,9 @@ void print_double(char **tab) { while (tab[i]) { - printf("%d -%s-\n", i, tab[i]); + dprintf(1 , "%d -%s-\n", i, tab[i]); i++; } - printf("end double\n"); + dprintf(1 , "end double\n"); } } \ No newline at end of file