diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-12 14:51:23 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-12 14:51:23 +0200 |
commit | 8b15c7b0f233238a53088d8c095bd5af7f7592e7 (patch) | |
tree | b74088caab21732f01268f4c12e4c7bd2a7096b9 /src/p_lblock_next.c | |
parent | In progress (diff) | |
download | 42-minishell-8b15c7b0f233238a53088d8c095bd5af7f7592e7.tar.gz 42-minishell-8b15c7b0f233238a53088d8c095bd5af7f7592e7.tar.bz2 42-minishell-8b15c7b0f233238a53088d8c095bd5af7f7592e7.tar.xz 42-minishell-8b15c7b0f233238a53088d8c095bd5af7f7592e7.tar.zst 42-minishell-8b15c7b0f233238a53088d8c095bd5af7f7592e7.zip |
how tf will I norm this
Diffstat (limited to 'src/p_lblock_next.c')
-rw-r--r-- | src/p_lblock_next.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c index 036d6b5..8b755da 100644 --- a/src/p_lblock_next.c +++ b/src/p_lblock_next.c @@ -100,27 +100,65 @@ static char 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); +} + void p_subst_alias(char word[], t_msh *msh) { char *ptr; - size_t first; + char tmp[255]; + size_t locat[2]; + t_bool good; t_quote_mode mode; (void)msh; mode = Q_NONE; ptr = word; - p_skip_whitespace(ptr); - first = 1; + 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 (ft_iswhitespace(*ptr) == TRUE && p_meet_whitespace((char*)word, ptr, mode) == TRUE) + 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); + ft_printf("(%s)\n", tmp); + } } char |