summaryrefslogtreecommitdiffstats
path: root/src/p_lblock_next.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/p_lblock_next.c')
-rw-r--r--src/p_lblock_next.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/p_lblock_next.c b/src/p_lblock_next.c
index 8b22f7c..21cd4a7 100644
--- a/src/p_lblock_next.c
+++ b/src/p_lblock_next.c
@@ -26,12 +26,31 @@
/* TODO: norme */
static char
+ *p_double_them_bs(char varval[])
+{
+ char *ptr;
+
+ ptr = varval;
+ while (*ptr != C_NUL)
+ {
+ if (*ptr == C_BACKS)
+ {
+ ptr = ft_memmove(ptr + 1, ptr, ft_strlen(ptr) + 1);
+ varval[ptr - varval] = C_BACKS;
+ }
+ ptr++;
+ }
+ return (varval);
+}
+
+static char
*p_subst_this_var(char **p, int64_t i, char word[], t_msh *msh)
{
char tmp[ARG_MAX];
char varval[ARG_MAX];
char *ptr;
size_t varlen;
+ int32_t count;
ptr = word;
varlen = i + 1;
@@ -40,13 +59,15 @@ static char
ft_iswhitespace(ptr[varlen]) == FALSE)
varlen += 1;
ft_strlcpy(tmp, ptr + i, varlen + 1 - i);
- u_get_var_value(varval, tmp, 4096, msh);
+ u_get_var_value(varval, tmp, ARG_MAX, msh);
+ p_double_them_bs(varval);
ft_strlcpy(tmp, ptr + varlen, varlen);
if ((word = ft_nrealloc(word, i, i + ft_strlen(varval) +
ft_strlen(tmp) + 1)) == NULL)
return (NULL);
ft_strlcpy(word + i, varval, ft_strlen(varval) + 1);
ft_strlcpy(word + (i + ft_strlen(varval)), tmp, ft_strlen(tmp) + 1);
+ count = 0;
*(p) = word + (i + ft_strlen(varval) - 1);
return (word);
}