diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-08-31 14:52:48 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-08-31 14:52:48 +0200 |
commit | 7cad49bd96a1798b5e742ff85084ddc188f7362b (patch) | |
tree | dd66f7b8300674264605f1db7248cfa8d258a262 /src/s_com.c | |
parent | no more SEGV on e_externs_pipes if prog member is nonsense (diff) | |
download | 42-minishell-7cad49bd96a1798b5e742ff85084ddc188f7362b.tar.gz 42-minishell-7cad49bd96a1798b5e742ff85084ddc188f7362b.tar.bz2 42-minishell-7cad49bd96a1798b5e742ff85084ddc188f7362b.tar.xz 42-minishell-7cad49bd96a1798b5e742ff85084ddc188f7362b.tar.zst 42-minishell-7cad49bd96a1798b5e742ff85084ddc188f7362b.zip |
start normng
Diffstat (limited to '')
-rw-r--r-- | src/s_com.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/s_com.c b/src/s_com.c index 550616c..a9d8f84 100644 --- a/src/s_com.c +++ b/src/s_com.c @@ -16,17 +16,18 @@ #include "f_fail.h" #include "p_lcom.h" #include "p_lcom_next.h" +#include "p_lcom_vars.h" #include "s_struct.h" static int8_t fill_com(char *words[], t_com **com) { - /* TODO: norme */ - uint64_t i; - uint64_t j; + /* TODO: norme is bav (for now)*/ + int64_t i; + int64_t j; - i = 0; + i = -1; if (words[0]) { if (((*com)->bin = (char*)malloc((ft_strlen(words[0]) + 1) * @@ -36,23 +37,19 @@ static int8_t } else return (0); - while(words[i]) + while(words[++i]) { /* TODO: cut fd number "msh ~> echo a 2>file" */ /* ^ */ if (ft_ischarset("<>", words[i][0]) == TRUE) break ; - i++; } if (!((*com)->argv = (char**)malloc((i + 1) * sizeof(char*)))) return (-1); - j = 0; - while (i > 0 && j < i) - { + j = -1; + while (++j < i) if (!((*com)->argv[j] = ft_strdup(words[j]))) return (-1); - j++; - } (*com)->argv[j] = 0; return (0); } |