diff options
Diffstat (limited to 'src/format_string.c')
| -rw-r--r-- | src/format_string.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/format_string.c b/src/format_string.c index 7e64039..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/19 20:24:05 by chuhlig ### ########.fr */ +/* Updated: 2025/01/25 11:57:27 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,8 +49,7 @@ 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; } @@ -71,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; @@ -79,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] == '?') { |
