aboutsummaryrefslogtreecommitdiff
path: root/src/format_string.c
diff options
context:
space:
mode:
authorChristopher Uhlig2025-01-25 13:01:10 +0100
committerChristopher Uhlig2025-01-25 13:01:10 +0100
commit87b90103930d83d74baa998866b0995cb8887d51 (patch)
tree0eb876341c2794f2165b83c1d339fb3b38e9f711 /src/format_string.c
parent18fb7cb8ae69fc3439266a154aa6b0f947d6805d (diff)
downloadminishell-87b90103930d83d74baa998866b0995cb8887d51.tar.gz
minishell-87b90103930d83d74baa998866b0995cb8887d51.zip
fixed leaks in tokenizer and collectargs also fixed seg for < > and improved value add by $ use
Diffstat (limited to 'src/format_string.c')
-rw-r--r--src/format_string.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/format_string.c b/src/format_string.c
index 06e5210..e649fdb 100644
--- a/src/format_string.c
+++ b/src/format_string.c
@@ -6,7 +6,7 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/17 19:30:11 by chuhlig #+# #+# */
-/* Updated: 2025/01/23 14:34:35 by chuhlig ### ########.fr */
+/* Updated: 2025/01/25 11:57:27 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -49,11 +49,8 @@ static void append_slice(char **dst, char *src, int start, int end)
i++;
}
result[len + i] = '\0';
- // if (*dst != NULL)
- // free(*dst);
+ free(*dst);
*dst = result;
- // free(src);
- // src = *dst;
}
static void append_var(char **dst, char *src, int *pos, t_env *env)
@@ -73,6 +70,8 @@ static void append_var(char **dst, char *src, int *pos, t_env *env)
value = env_get(env, var);
if (value)
{
+ while (*value == ' ')
+ value++;
result = ft_strjoin(*dst, value);
free(*dst);
*dst = result;
@@ -81,7 +80,8 @@ static void append_var(char **dst, char *src, int *pos, t_env *env)
free(var);
}
-static void handle_dollar_sign(char **result, char *str, int *pos, t_env *env)
+static void handle_dollar_sign(char **result, char *str, int *pos,
+ t_env *env)
{
if (str[*pos + 1] == '?')
{