while (expanded_split[i])
len += ft_strlen(expanded_split[i++]) + 1;
*str = malloc(len + 1 + 1);
+ if (!str)
+ {
+ *str = tmp;
+ return (1);
+ }
str[0][0] = '\0';
+ i = 0;
+ while (expanded_split[i])
+ {
+ ft_strlcat(*str, expanded_split[i++], len + 1 + 1);
+ ft_strlcat(*str, " ", len + 1 + 1);
+ }
+ free(tmp);
+ return (0);
+}
+
+int replace_str_by_joint_quoted_split(char **str, char **expanded_split)
+{
+ char *tmp;
+ size_t len;
+ size_t i;
+
+ tmp = *str;
+ len = 0;
+ i = 0;
+ while (expanded_split[i])
+ len += ft_strlen(expanded_split[i++]) + 2 + 1;
+ *str = malloc(len + 1 + 1);
if (!str)
{
*str = tmp;
return (1);
}
+ str[0][0] = '\0';
i = 0;
while (expanded_split[i])
{
+ ft_strlcat(*str, "'", len + 1 + 1);
ft_strlcat(*str, expanded_split[i++], len + 1 + 1);
+ ft_strlcat(*str, "'", len + 1 + 1);
ft_strlcat(*str, " ", len + 1 + 1);
}
free(tmp);
++info.to_expand;
res = expand_dir(&matched, &info);
res = res || (ft_vec_append(&matched, &nullptr) != success);
- res = res || replace_str_by_joint_split(str, matched.vec);
+ res = res || replace_str_by_joint_quoted_split(str, matched.vec);
ft_vec_free(&matched, free_str);
free((char *)info.path);
if (last_char == '\n')