From ff845bada3fe6898a228c10422f0561e2a532622 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 11 Sep 2020 21:18:27 +0200 Subject: Fuck this --- src/p_lblock_next.c | 96 +++++++++++++++++++---------------------------------- src/s_com.c | 4 +-- src/s_struct.h | 2 +- 3 files changed, 38 insertions(+), 64 deletions(-) diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c index 6f5f00d..10c4d84 100644 --- a/src/p_lblock_next.c +++ b/src/p_lblock_next.c @@ -93,20 +93,8 @@ void void p_subst_alias(char word[], t_msh *msh) { - /* char subst[ARG_MAX]; */ - char *ptr; - - ptr = word; + (void)word; (void)msh; - ft_printf("[%s]\n", ptr); - /* while (*ptr != C_NUL) */ - /* { */ - /* ptr++; */ - /* } */ - /* if (u_get_alias_value(subst, ?, ARG_MAX, msh) == 0) */ - /* { */ - /* /\* copy *\/ */ - /* } */ } char @@ -219,56 +207,42 @@ static void msh->env_fork_tmp[j][0] = '\0'; } -void - p_check_args_equals(char word[], t_msh *msh) +char + **p_check_args_equals(char *words[], t_msh *msh) { - char *ptr; - t_quote_mode mode; + char *ptr; + t_bool reg; + t_bool isvar; + int64_t i; - mode = Q_NONE; - ptr = word; - while (*ptr != C_NUL) + i = 0; + reg = FALSE; + isvar = FALSE; + while (words[i]) { - if (*ptr == C_DQUOTE) - mode = u_meet_dquote(word, ptr, mode); - else if (*ptr == C_SQUOTE) - mode = u_meet_squote(word, ptr, mode); - else if (mode == Q_NONE && *ptr == C_EQUALS) - ptr++; + ptr = words[i]; + while (*ptr != '\0' && *ptr != '=') + ptr++; + if (*ptr == '=') + { + reg = TRUE; + isvar = TRUE; + } + if (*ptr == '\0' || words[i][0] == '=' || + ft_isdigit(words[i][0]) == TRUE) + { + reg = FALSE; + if (i == 0) + isvar = FALSE; + if (isvar == TRUE) + p_add_to_env_fork(i, words, msh); + else + msh->env_fork_tmp[0][0] = '\0'; + break ; + } + i++; } - /* char *ptr; */ - /* t_bool reg; */ - /* t_bool isvar; */ - /* int64_t i; */ - - /* i = 0; */ - /* reg = FALSE; */ - /* isvar = FALSE; */ - /* while (words[i]) */ - /* { */ - /* ptr = words[i]; */ - /* while (*ptr != '\0' && *ptr != '=') */ - /* ptr++; */ - /* if (*ptr == '=') */ - /* { */ - /* reg = TRUE; */ - /* isvar = TRUE; */ - /* } */ - /* if (*ptr == '\0' || words[i][0] == '=' || */ - /* ft_isdigit(words[i][0]) == TRUE) */ - /* { */ - /* reg = FALSE; */ - /* if (i == 0) */ - /* isvar = FALSE; */ - /* if (isvar == TRUE) */ - /* p_add_to_env_fork(i, words, msh); */ - /* else */ - /* msh->env_fork_tmp[0][0] = '\0'; */ - /* break ; */ - /* } */ - /* i++; */ - /* } */ - /* if (isvar == TRUE) */ - /* return (p_add_to_variables_and_delete(words, reg, i, msh)); */ - /* return (words); */ + if (isvar == TRUE) + return (p_add_to_variables_and_delete(words, reg, i, msh)); + return (words); } diff --git a/src/s_com.c b/src/s_com.c index 51b2500..4d78573 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -116,13 +116,13 @@ t_com ft_strlcpy(nword, word, ARG_MAX); if (p_get_redir(nword, &com) != 0) return (NULL); - p_subst_vars(nword, msh); - p_check_args_equals(nword, msh); p_subst_alias(nword, msh); + p_subst_vars(nword, msh); if ((words = p_split_args(nword, com->redir)) == NULL) return (NULL); if ((words = p_subst_home(words, msh)) == NULL) return (NULL); + words = p_check_args_equals(words, msh); if (msh->env_fork_tmp[0][0] != '\0') s_com_cpy_env_fork(&com, msh); if (s_fill_com(words, &com) < 0) diff --git a/src/s_struct.h b/src/s_struct.h index 963d5ad..310c5f4 100644 --- a/src/s_struct.h +++ b/src/s_struct.h @@ -82,7 +82,7 @@ typedef struct s_msh char **envp; char **bu_ref; char ps[4][1024]; - char env_fork_tmp[128][1024]; + char env_fork_tmp[128][4096]; char sqb_ref[FT_ID_SQB_COUNT][4]; char *shname; char *cwd; -- cgit v1.2.3