diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-02 21:39:47 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-02 21:39:47 +0200 |
commit | 3d696077d245713c921956a2be8fd6e12a052d4a (patch) | |
tree | fbe8ffd276fe67a113cbec0b6ce65177f4bd7d4f /src/p_lblock_next.c | |
parent | Update (diff) | |
download | 42-minishell-3d696077d245713c921956a2be8fd6e12a052d4a.tar.gz 42-minishell-3d696077d245713c921956a2be8fd6e12a052d4a.tar.bz2 42-minishell-3d696077d245713c921956a2be8fd6e12a052d4a.tar.xz 42-minishell-3d696077d245713c921956a2be8fd6e12a052d4a.tar.zst 42-minishell-3d696077d245713c921956a2be8fd6e12a052d4a.zip |
In progress
Diffstat (limited to '')
-rw-r--r-- | src/p_lblock_next.c | 102 |
1 files changed, 3 insertions, 99 deletions
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c index d964f11..9def230 100644 --- a/src/p_lblock_next.c +++ b/src/p_lblock_next.c @@ -88,108 +88,12 @@ void p_subst_vars(char word[], t_msh *msh) } } -static char *p_skip_whitespace(char *ptr) -{ - while (*ptr != C_NUL && ft_iswhitespace(*ptr)) - ptr++; - return (ptr); -} -static t_bool p_meet_whitespace(char *head, char *ptr, t_quote_mode mode) -{ - if (mode == Q_NONE && u_is_not_escaped(head, ptr) == TRUE) - { - return (TRUE); - } - return (FALSE); -} -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); - good = TRUE; - locat[0] = (ptr - word); - locat[1] = (ptr - word); - while (*ptr != C_NUL) - { - if (*ptr == C_DQUOTE) - mode = u_meet_dquote(word, ptr, mode); - if (*ptr == C_SQUOTE) - mode = u_meet_squote(word, ptr, mode); - if (mode == Q_NONE && *ptr == C_EQUALS) - good = FALSE; - if (ft_iswhitespace(*ptr) == TRUE && - p_meet_whitespace((char*)word, ptr, mode) == TRUE) - { - locat[1] = (ptr - word); - if (good == TRUE) - break ; - else - { - ptr = p_skip_whitespace(ptr); - locat[0] = (ptr - word); - ptr -= 1; - good = TRUE; - } - } - ptr++; - } - if (*ptr == C_NUL && good == TRUE) - locat[1] = (ptr - word); - if (good == TRUE) - { - ft_strlcpy(tmp, - word + locat[0], - ((locat[1] - locat[0] < 253) ? (locat[1] - locat[0]) : (254)) + 1); - 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); - } - } - } - return (0); -} + + + static char **p_alloc_rewords(char *words[], int64_t j, t_msh *msh) { |