summaryrefslogtreecommitdiffstats
path: root/src/s_com.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s_com.c')
-rw-r--r--src/s_com.c19
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);
}