summaryrefslogtreecommitdiffstats
path: root/src/ft_p_lcom_next.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_p_lcom_next.c')
-rw-r--r--src/ft_p_lcom_next.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ft_p_lcom_next.c b/src/ft_p_lcom_next.c
index df312bc..d1ab206 100644
--- a/src/ft_p_lcom_next.c
+++ b/src/ft_p_lcom_next.c
@@ -14,6 +14,44 @@
#include <stdlib.h>
#include <stdint.h>
+#include "ft_s_struct.h"
+#include "ft_u_utils.h"
+
+char
+ **ft_subst_vars(char *words[],
+ t_msh *msh)
+{
+ /* TODO: norme */
+ char **p_words;
+ char **p_env;
+ char *s_varname;
+ int64_t i;
+ size_t varlen;
+
+ p_words = words;
+ varlen = 0;
+ while (*p_words)
+ {
+ while (varlen < ft_strlen(*p_words) &&
+ (i = ft_strlchr((*p_words) + varlen, '$')))
+ {
+ if (i == -1)
+ break ;
+ varlen = i + 1;
+ while ((*p_words)[varlen] != '\0' && (*p_words)[varlen] != '$')
+ varlen += 1;
+ if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen)))
+ return (NULL);
+ ft_printf("{%s} | {%s}\n", s_varname, ft_subst_var_value(s_varname, msh));
+ p_env = msh->envp;
+ ft_memdel((void*)&s_varname);
+ varlen += 1;
+ }
+ p_words += 1;
+ }
+ return (words);
+}
+
char
**ft_subst_args(const char word[],
int8_t redir)