From da80405b345b58f9e1bd83039b1df3771b5ca193 Mon Sep 17 00:00:00 2001 From: Christopher Uhlig Date: Tue, 14 Jan 2025 18:18:58 +0100 Subject: update for exit bit norm removed staic stuff added prompt flag --- src/format_string.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/format_string.c') diff --git a/src/format_string.c b/src/format_string.c index bd7f703..7168ea0 100644 --- a/src/format_string.c +++ b/src/format_string.c @@ -6,7 +6,7 @@ /* By: chuhlig +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/17 19:30:11 by chuhlig #+# #+# */ -/* Updated: 2024/12/17 19:31:54 by chuhlig ### ########.fr */ +/* Updated: 2025/01/14 14:21:36 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,12 +17,6 @@ static void append_slice(char **dst, char *src, int start, int end); static void append_var(char **dst, char *src, int *pos, t_env *env); -enum e_format_mode -{ - LITERAL = 1, - VARIABLE = 2, -}; - char *format_string(char *str, t_env *env) { char *result; @@ -42,14 +36,14 @@ char *format_string(char *str, t_env *env) { append_slice(&result, str, start, pos); start = pos + 1; - mode ^= LITERAL; + mode ^= 1; } - if (str[pos] == '"' && !(mode & LITERAL)) + if (str[pos] == '"' && !(mode & 1)) { append_slice(&result, str, start, pos); start = pos + 1; } - if (str[pos] == '$' && !(mode & LITERAL)) + if (str[pos] == '$' && !(mode & 1)) { append_slice(&result, str, start, pos); append_var(&result, str, &pos, env); @@ -100,7 +94,7 @@ static void append_var(char **dst, char *src, int *pos, t_env *env) i = 0; *pos += 1; while (src[*pos + i] != '\0' && src[*pos + i] != '\'' && src[*pos - + i] != '"' && src[*pos + i] != '$') + + i] != '"' && src[*pos + i] != '$') { i++; } -- cgit v1.2.3