feat: patching stuff

This commit is contained in:
Raphael 2024-10-06 15:22:35 +02:00
parent 9441d119ad
commit 0df91727b0

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/02 19:04:32 by maiboyer #+# #+# */ /* Created: 2024/10/02 19:04:32 by maiboyer #+# #+# */
/* Updated: 2024/10/06 15:13:45 by rparodi ### ########.fr */ /* Updated: 2024/10/06 15:21:47 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,7 +30,9 @@
bool _type_extansion(enum e_token type) bool _type_extansion(enum e_token type)
{ {
if (type == TOK_DOLLAR || type == TOK_DQUOTE || type == TOK_SQUOTE) if (type == TOK_DOLLAR)
return (true);
if (type == TOK_NQUOTE || type == TOK_DQUOTE || type == TOK_SQUOTE)
return (true); return (true);
return (false); return (false);
} }
@ -49,11 +51,11 @@ t_error ts_fold_double_quote(t_vec_token input, t_vec_token *output)
if (token_is_noquote(input.buffer[i].type)) if (token_is_noquote(input.buffer[i].type))
{ {
j = 0; j = 0;
tmp = token_new(TOK_NQUOTE); tmp = token_new(TOK_WORD);
while (i + j < input.len \ while (i + j < input.len \
&& token_is_noquote(input.buffer[i + j].type)) && token_is_noquote(input.buffer[i + j].type))
if (type_extansion(input.buffer->type)) if (_type_extansion(input.buffer->type))
string_push(&tmp.string, input.buffer[i + j++].subtokens.buffer); vec_token_push(&tmp.subtokens, token_clone(&input.buffer[i+j]));
vec_token_push(&out, tmp); vec_token_push(&out, tmp);
i += j; i += j;
} }