summaryrefslogtreecommitdiffstats
path: root/src/p_lcom_next.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-06 22:12:15 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-06 22:12:15 +0200
commit6805673bff96379c03ba32e681f8fb40aad52adc (patch)
treeb1a9b1978ba4f7577e8544bcccf8ccc08c360037 /src/p_lcom_next.c
parentCool (diff)
download42-minishell-6805673bff96379c03ba32e681f8fb40aad52adc.tar.gz
42-minishell-6805673bff96379c03ba32e681f8fb40aad52adc.tar.bz2
42-minishell-6805673bff96379c03ba32e681f8fb40aad52adc.tar.xz
42-minishell-6805673bff96379c03ba32e681f8fb40aad52adc.tar.zst
42-minishell-6805673bff96379c03ba32e681f8fb40aad52adc.zip
Improvement
Diffstat (limited to 'src/p_lcom_next.c')
-rw-r--r--src/p_lcom_next.c32
1 files changed, 4 insertions, 28 deletions
diff --git a/src/p_lcom_next.c b/src/p_lcom_next.c
index 7ae0331..2f675f3 100644
--- a/src/p_lcom_next.c
+++ b/src/p_lcom_next.c
@@ -25,32 +25,8 @@
/* TODO: norme */
-/* static int8_t */
-/* p_subst_those_vars(int64_t i, */
-/* char **p_words, */
-/* t_msh *msh) */
-/* { */
-/* size_t varlen; */
-/* char *s_varname; */
-/* char *varval; */
-
-/* varval = NULL; */
-/* s_varname = NULL; */
-/* varlen = i + 1; */
-/* while ((*p_words)[varlen] != '\0' && */
-/* ft_ischarset("$=/#@%^*+{}[],.-", (*p_words)[varlen]) == FALSE) */
-/* varlen += 1; */
-/* if (!(s_varname = ft_substr(*p_words, (uint32_t)i, varlen - i))) */
-/* return (-1); */
-/* varval = u_get_var_value(s_varname, msh); */
-/* *p_words = ft_strsubst(*p_words, s_varname, varval); */
-/* ft_memdel((void*)&s_varname); */
-/* ft_memdel((void*)&varval); */
-/* return (0); */
-/* } */
-
static char
- *p_subst_this_var(int64_t i, char word[], t_msh *msh)
+ *p_subst_this_var(char **p, int64_t i, char word[], t_msh *msh)
{
char tmp[4096];
char varval[4096];
@@ -68,9 +44,9 @@ static char
ft_strlcpy(tmp, ptr + varlen, varlen);
word = ft_nrealloc(word, i, i + ft_strlen(varval) + ft_strlen(tmp) + 1);
ft_strlcpy(word + i, varval, ft_strlen(varval) + 1);
- ft_strlcpy(word + i + ft_strlen(varval), tmp, ft_strlen(tmp) + 1);
+ ft_strlcpy(word + (i + ft_strlen(varval)), tmp, ft_strlen(tmp) + 1);
ft_printf("[%s]\n", word);
- exit(0);
+ *(p) = word + (i + ft_strlen(varval) - 1);
return (word);
}
@@ -84,7 +60,7 @@ char
{
if (*ptr == '$' && u_is_not_escaped(word, ptr) == TRUE)
{
- if ((word = p_subst_this_var((ptr - word), word, msh)) == NULL)
+ if ((word = p_subst_this_var(&ptr, (ptr - word), word, msh)) == NULL)
return (NULL);
}
ptr++;