summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-11 21:18:27 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-11 21:18:27 +0200
commitff845bada3fe6898a228c10422f0561e2a532622 (patch)
treeb6c407875f7a87bc28e55426a7f3d2fd101be47a
parentqwe (diff)
download42-minishell-ff845bada3fe6898a228c10422f0561e2a532622.tar.gz
42-minishell-ff845bada3fe6898a228c10422f0561e2a532622.tar.bz2
42-minishell-ff845bada3fe6898a228c10422f0561e2a532622.tar.xz
42-minishell-ff845bada3fe6898a228c10422f0561e2a532622.tar.zst
42-minishell-ff845bada3fe6898a228c10422f0561e2a532622.zip
Fuck this
-rw-r--r--src/p_lblock_next.c96
-rw-r--r--src/s_com.c4
-rw-r--r--src/s_struct.h2
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;