From ccea1166bfae1a28373f479d8a44d6617c2a3e35 Mon Sep 17 00:00:00 2001 From: minsuki2 Date: Wed, 14 Sep 2022 23:02:54 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20add=5Fdict=20=EC=9D=B8=EC=9E=90=203?= =?UTF-8?q?=EA=B0=9C=EB=A1=9C=20=EC=88=98=EC=A0=95,=20erase=5Fdict=20const?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9->=EB=84=90=EA=B0=80=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#36?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dict_utils.c | 16 +++++++++------- envp_utils.c | 4 +++- minishell.c | 21 ++++++++------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/dict_utils.c b/dict_utils.c index cb2a5a0..aad141d 100644 --- a/dict_utils.c +++ b/dict_utils.c @@ -6,7 +6,7 @@ /* By: minsuki2 prev; - t_dict *find_node; + int idx; + t_dict *last_node; + t_dict *find_node; + if (!name) + return ; + idx = chr_to_idx(*name); find_node = find_dict(&g_dict[idx], name); if (!find_node) return ; find_node->prev->next = find_node->next; if (find_node->next) find_node->next->prev = find_node->prev; + last_node = g_dict[idx].prev; if (find_node == last_node) - head_node->prev = find_node->prev; + g_dict[idx].prev = find_node->prev; my_multi_free(find_node->name, find_node->value, find_node, NULL); } diff --git a/envp_utils.c b/envp_utils.c index b0329e0..ac55d5b 100644 --- a/envp_utils.c +++ b/envp_utils.c @@ -6,7 +6,7 @@ /* By: jaesjeon +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/09/09 15:25:42 by minsuki2 #+# #+# */ -/* Updated: 2022/09/14 22:28:39 by minsuki2 ### ########.fr */ +/* Updated: 2022/09/14 22:35:44 by minsuki2 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,6 +92,8 @@ void dict_lstadd_order(t_dict *head, t_dict *new) val = comapre_order_dict(cur->next, new); if (val > 0) dict_lstadd_next(cur, new); + else if (val == 0) + return ; cur = cur->next; } } diff --git a/minishell.c b/minishell.c index ccdd6c7..63bb6bf 100644 --- a/minishell.c +++ b/minishell.c @@ -6,7 +6,7 @@ /* By: jaesjeon +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/08/25 11:00:34 by jaesjeon #+# #+# */ -/* Updated: 2022/09/14 22:30:56 by minsuki2 ### ########.fr */ +/* Updated: 2022/09/14 22:47:00 by minsuki2 ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,19 +44,14 @@ int main(int argc, char *argv[], char *envp[]) terminal_off_control_chars(); set_exit_status(0); envp_to_dict(envp); - - put_dict(ft_strdup("a"), ft_strdup("123")); - print_dictionary_lst(); -printf("------------------------------------------------------------\n"); -printf("------------------------------------------------------------\n"); - // add_dict(NULL, NULL, "a=34"); - put_dict(ft_strdup("a"), ft_strdup("341")); + printf("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n"); print_dictionary_lst(); - // printf("\nreal_total = %d\n", print_strs(envp)); - // printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); - // strs = dict_to_envp(); - // printf("\nmy_total = %d\n", print_strs(strs)); - // char_dimen2_free(strs); + printf("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n"); + strs = dict_to_envp(); + printf("\nmy_total = %d\n", print_strs(strs)); + char_dimen2_free(strs); + printf("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n"); + while (true) { full_line = liner(&oflag);