diff options
Diffstat (limited to 'src/p_lblock_next.c')
-rw-r--r-- | src/p_lblock_next.c | 96 |
1 files changed, 35 insertions, 61 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); } |