diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-12 16:33:02 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-12 16:33:02 +0200 |
commit | 949f93b57b6411b07eb12110e0db37cdf393db0c (patch) | |
tree | ce90ac0b84cbdab7c3ea2c47c8397310045db386 /src/p_lblock_next.c | |
parent | Fix (diff) | |
download | 42-minishell-949f93b57b6411b07eb12110e0db37cdf393db0c.tar.gz 42-minishell-949f93b57b6411b07eb12110e0db37cdf393db0c.tar.bz2 42-minishell-949f93b57b6411b07eb12110e0db37cdf393db0c.tar.xz 42-minishell-949f93b57b6411b07eb12110e0db37cdf393db0c.tar.zst 42-minishell-949f93b57b6411b07eb12110e0db37cdf393db0c.zip |
Fuck
Diffstat (limited to '')
-rw-r--r-- | src/p_lblock_next.c | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c index 3fa0ea5..0c1c1f4 100644 --- a/src/p_lblock_next.c +++ b/src/p_lblock_next.c @@ -110,16 +110,30 @@ static t_bool return (FALSE); } -void - p_subst_alias(char word[], t_msh *msh) +size_t + p_subst_alias(char word[], t_bool reset, t_msh *msh) { + static size_t used[4096]; + static size_t i = 0; char value[ARG_MAX]; char tmp[255]; size_t locat[2]; + size_t j; + size_t usedcmp; char *ptr; t_bool good; t_quote_mode mode; + if (reset == TRUE) + { + i = 0; + while (i < 4096) + { + used[i] = 0; + i++; + } + i = 0; + } mode = Q_NONE; ptr = word; ptr = p_skip_whitespace(ptr); @@ -157,15 +171,36 @@ void ft_strlcpy(tmp, word + locat[0], ((locat[1] - locat[0] < 253) ? (locat[1] - locat[0]) : (254)) + 1); - if (u_get_alias_value(value, tmp, ARG_MAX, msh) != 0) - return ; - (void)ft_memmove(word + (locat[0] + ft_strlen(value)), - word + locat[1], - ft_strlen(word + locat[1]) + 1 * sizeof(char)); - (void)ft_memmove(word + locat[0], - value, - ft_strlen(value) * sizeof(char)); + if ((usedcmp = u_get_alias_value(value, tmp, ARG_MAX, msh)) != 0) + { + j = 0; + good = TRUE; + while (j < i) + { + if (used[j] == usedcmp) + good = FALSE; + j++; + } + if (good == TRUE) + { + (void)ft_memmove(word + (locat[0] + ft_strlen(value)), + word + locat[1], + ft_strlen(word + locat[1]) + 1 * sizeof(char)); + (void)ft_memmove(word + locat[0], + value, + ft_strlen(value) * sizeof(char)); + used[i] = usedcmp; + i++; + return (usedcmp); + } + } + /* ptr = value; */ + /* save = value; */ + /* while (*ptr != C_NUL && ft_iswhitespace(*ptr) == FALSE) */ + /* ptr++; */ + /* ft_strlcpy(tmp, save, (ptr - save) + 1); */ } + return (0); } char |