diff options
| author | Christopher Uhlig | 2025-01-14 18:18:58 +0100 |
|---|---|---|
| committer | Christopher Uhlig | 2025-01-14 18:18:58 +0100 |
| commit | da80405b345b58f9e1bd83039b1df3771b5ca193 (patch) | |
| tree | d8ddb9fa078fa353dc55992dd9609a0c798e56ad /src/format_string.c | |
| parent | 8c37f835ba29bcecc1d779edb396d97b18667026 (diff) | |
| download | minishell-da80405b345b58f9e1bd83039b1df3771b5ca193.tar.gz minishell-da80405b345b58f9e1bd83039b1df3771b5ca193.zip | |
update for exit bit norm removed staic stuff added prompt flag
Diffstat (limited to 'src/format_string.c')
| -rw-r--r-- | src/format_string.c | 16 |
1 files changed, 5 insertions, 11 deletions
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 <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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++; } |
