Parse-cmd: fix and add comment

This commit is contained in:
Jérôme Guélen 2025-03-28 19:01:17 +01:00 committed by Jerome
parent 0a80b9fbe3
commit 10d7b65b08
2 changed files with 17 additions and 6 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* minishell.h :+: :+: :+: */ /* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/28 14:55/31 by khais #+# #+# */ /* Created: 2025/03/28 14:55:31 by khais #+# #+# */
/* Updated: 2025/03/28 14:55:31 by khais ### ########.fr */ /* Updated: 2025/03/28 16:42:57 by jguelen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -57,6 +57,9 @@ typedef enum e_cmd_type
typedef struct s_cmd typedef struct s_cmd
{ {
t_cmd_type type; t_cmd_type type;
/*
** flags will probably be useless to us for now.
*/
int flags; int flags;
/* /*
** Line number the command starts on -> will probably be unused. ** Line number the command starts on -> will probably be unused.
@ -73,6 +76,7 @@ typedef struct s_cmd
typedef enum e_connector typedef enum e_connector
{ {
FT_INVALID_CONNECTOR,
FT_PIPE, FT_PIPE,
FT_AND, FT_AND,
FT_OR, FT_OR,

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* remove_quotes.c :+: :+: :+: */ /* remove_quotes.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/28 13:52:02 by khais #+# #+# */ /* Created: 2025/02/28 13:52:02 by khais #+# #+# */
/* Updated: 2025/03/07 11:20:48 by khais ### ########.fr */ /* Updated: 2025/03/28 16:05:25 by jguelen ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,6 +15,13 @@
#include "../matchers/quote.h" #include "../matchers/quote.h"
#include <stdlib.h> #include <stdlib.h>
static bool is_ignore_mark(char c)
{
if (c == '\'' || c == '"' || c == '$' || c == '&')
return (true);
return (false);
}
/* /*
** use the marker in the given worddesc to create a new worddesc by removing ** use the marker in the given worddesc to create a new worddesc by removing
** unquoted quotes. ** unquoted quotes.
@ -37,7 +44,7 @@ t_worddesc *remove_quotes(t_worddesc *word)
i = 0; i = 0;
while (word->word[i] != '\0') while (word->word[i] != '\0')
{ {
if (!is_quote(word->word[i]) || is_quote(word->marker[i])) if (!is_quote(word->word[i]) || is_ignore_mark(word->marker[i]))
buf = ft_buffer_pushchar(buf, word->word[i]); buf = ft_buffer_pushchar(buf, word->word[i]);
i++; i++;
} }