diff options
-rw-r--r-- | src/e_externs.c | 1 | ||||
-rw-r--r-- | src/p_lcom_next.c | 30 | ||||
-rw-r--r-- | src/p_lcom_next.h | 1 | ||||
-rw-r--r-- | src/s_lcom.c | 6 |
4 files changed, 33 insertions, 5 deletions
diff --git a/src/e_externs.c b/src/e_externs.c index 3d55fa9..93d989f 100644 --- a/src/e_externs.c +++ b/src/e_externs.c @@ -76,7 +76,6 @@ void if (fullpath == NULL) { f_fail_command_not_found(ptr->com); - /* TODO: deal if not found etc */ } else { diff --git a/src/p_lcom_next.c b/src/p_lcom_next.c index a0ca8d1..4d0ca72 100644 --- a/src/p_lcom_next.c +++ b/src/p_lcom_next.c @@ -14,6 +14,7 @@ #include <stdlib.h> #include <stdint.h> +#include "d_enum.h" #include "s_struct.h" #include "u_vars.h" @@ -95,3 +96,32 @@ char ft_memdel((void*)&subst); return (words); } + +char + **p_check_first_arg_equals(char *words[]) +{ + t_bool equals; + char *ptr; + + equals = FALSE; + ptr = words[0]; + while (*ptr != '\0') + { + if (*ptr == '=') + { + equals = TRUE; + break ; + } + ptr++; + } + if (equals == TRUE && words[1] != NULL) + { + ft_memdel((void*)&words[0]); + words = words + 1; + return (words); + } + else + { + return (words); + } +} diff --git a/src/p_lcom_next.h b/src/p_lcom_next.h index 3113b6b..ad5c5c5 100644 --- a/src/p_lcom_next.h +++ b/src/p_lcom_next.h @@ -21,5 +21,6 @@ char **subst_vars(char *words[], t_msh *msh); char **subst_args(const char word[], int8_t redir); +char **p_check_first_arg_equals(char *words[]); #endif diff --git a/src/s_lcom.c b/src/s_lcom.c index 31b14d6..773814f 100644 --- a/src/s_lcom.c +++ b/src/s_lcom.c @@ -49,11 +49,8 @@ static int8_t j = 0; while (i > 0 && j < i) { - if (!((*lcom)->argv[j] = - (char*)malloc((ft_strlen(words[j]) + 1) * sizeof(char)))) + if (!((*lcom)->argv[j] = ft_strdup(words[j]))) return (-1); - ft_strlcpy((*lcom)->argv[j], words[j], - ft_strlen(words[j]) + 1); j++; } (*lcom)->argv[j] = 0; @@ -134,6 +131,7 @@ t_lcom return (NULL); if (!(words = subst_vars(words, msh))) return (NULL); + words = p_check_first_arg_equals(words); if (fill_lcom(words, &link) < 0) { ft_delwords(words); |