diff options
-rw-r--r-- | src/p_args.c | 2 | ||||
-rw-r--r-- | src/p_lblock_next.c | 46 | ||||
-rw-r--r-- | src/s_com.c | 3 |
3 files changed, 45 insertions, 6 deletions
diff --git a/src/p_args.c b/src/p_args.c index 5276ae1..54a95a7 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -72,7 +72,7 @@ static uint16_t mode = u_meet_dquote(word, ptr, mode); else if (*ptr == C_SQUOTE) mode = u_meet_squote(word, ptr, mode); - if (ft_iswhitespace(*ptr) && + if (ft_iswhitespace(*ptr) == TRUE && p_meet_whitespace((char*)word, ptr, mode) == TRUE) { ptr = p_skip_whitespace(ptr); 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 diff --git a/src/s_com.c b/src/s_com.c index 4d78573..b85905e 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -116,7 +116,8 @@ t_com ft_strlcpy(nword, word, ARG_MAX); if (p_get_redir(nword, &com) != 0) return (NULL); - p_subst_alias(nword, msh); + /* if (msh->alias != NULL) */ + p_subst_alias(nword, msh); p_subst_vars(nword, msh); if ((words = p_split_args(nword, com->redir)) == NULL) return (NULL); |