diff --git a/src/executing/here_doc/here_doc_expand_line.c b/src/executing/here_doc/here_doc_expand_line.c index 125139c..93299a4 100644 --- a/src/executing/here_doc/here_doc_expand_line.c +++ b/src/executing/here_doc/here_doc_expand_line.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/28 16:43:11 by khais #+# #+# */ -/* Updated: 2025/03/28 16:43:41 by khais ### ########.fr */ +/* Updated: 2025/04/08 16:32:32 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,7 @@ char *expand_line(char *line, t_minishell *app) t_worddesc *word; word = worddesc_create(line, W_HASDOLLAR, - construct_repeting_char_string(' ', ft_strlen(line))); + construct_repeting_char_string(' ', ft_strlen(line)), WORD_TOKEN); word_var_expansion(word, app); line = ft_strdup(word->word); worddesc_destroy(word); diff --git a/src/parser/remove_quotes/remove_quotes.c b/src/parser/remove_quotes/remove_quotes.c index 215c50d..d203c16 100644 --- a/src/parser/remove_quotes/remove_quotes.c +++ b/src/parser/remove_quotes/remove_quotes.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* remove_quotes.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jguelen +#+ +:+ +#+ */ +/* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/02/28 13:52:02 by khais #+# #+# */ -/* Updated: 2025/03/28 16:05:25 by jguelen ### ########.fr */ +/* Created: 2025/04/15 12:00/08 by khais #+# #+# */ +/* Updated: 2025/04/15 12:00:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -50,7 +50,7 @@ t_worddesc *remove_quotes(t_worddesc *word) } if (buf == NULL) return (NULL); - output = worddesc_create(buf->buffer, word->flags, NULL); + output = worddesc_create(buf->buffer, word->flags, NULL, word->token_type); free(buf); return (output); } diff --git a/src/parser/worddesc/worddesc.c b/src/parser/worddesc/worddesc.c index 42ba721..e5f3aa6 100644 --- a/src/parser/worddesc/worddesc.c +++ b/src/parser/worddesc/worddesc.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* worddesc.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jguelen +#+ +:+ +#+ */ +/* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/02/13 17:20:36 by khais #+# #+# */ -/* Updated: 2025/04/07 17:40:03 by jguelen ### ########.fr */ +/* Created: 2025/04/15 12:00/08 by khais #+# #+# */ +/* Updated: 2025/04/15 12:00:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,8 @@ ** In case of allocation error, word is freed, as well as any memory allocated ** in this function */ -t_worddesc *worddesc_create(char *word, char flags, char *marker) +t_worddesc *worddesc_create(char *word, char flags, char *marker, + t_token_type type) { t_worddesc *retvalue; @@ -38,6 +39,7 @@ t_worddesc *worddesc_create(char *word, char flags, char *marker) retvalue->word = word; retvalue->flags = flags; retvalue->marker = marker; + retvalue->token_type = type; return (retvalue); } diff --git a/src/parser/worddesc/worddesc.h b/src/parser/worddesc/worddesc.h index 11f2f37..f93cd7f 100644 --- a/src/parser/worddesc/worddesc.h +++ b/src/parser/worddesc/worddesc.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* worddesc.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jguelen +#+ +:+ +#+ */ +/* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2025/03/27 13:57:44 by khais #+# #+# */ -/* Updated: 2025/04/08 16:25:37 by jguelen ### ########.fr */ +/* Created: 2025/04/15 12:00/08 by khais #+# #+# */ +/* Updated: 2025/04/15 12:00:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,7 +74,8 @@ typedef struct s_worddesc t_token_type token_type; } t_worddesc; -t_worddesc *worddesc_create(char *word, char flags, char *marker); +t_worddesc *worddesc_create(char *word, char flags, char *marker, + t_token_type type); void worddesc_destroy(t_worddesc *worddesc); t_worddesc *worddesc_copy(t_worddesc *worddesc); void worddesc_debug(t_worddesc *worddesc, t_buffer *leader, diff --git a/src/parser/wordsplit/wordsplit_utils.c b/src/parser/wordsplit/wordsplit_utils.c index e4a82c6..5664343 100644 --- a/src/parser/wordsplit/wordsplit_utils.c +++ b/src/parser/wordsplit/wordsplit_utils.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/20 14:02:29 by khais #+# #+# */ -/* Updated: 2025/03/10 16:55:33 by khais ### ########.fr */ +/* Updated: 2025/04/08 16:29:49 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,11 +15,14 @@ void delimit(t_token_build *builder) { + t_token_type type; + + type = WORD_TOKEN; if (builder->cur_token == NULL) return ; builder->wordlist = wordlist_push(builder->wordlist, worddesc_create(builder->cur_token->buffer, - builder->cur_flags, builder->cur_marker->buffer)); + builder->cur_flags, builder->cur_marker->buffer, type)); free(builder->cur_token); free(builder->cur_marker); builder->cur_flags = 0; diff --git a/src/postprocess/fieldsplit/fieldsplit.c b/src/postprocess/fieldsplit/fieldsplit.c index 035e1bf..d592d69 100644 --- a/src/postprocess/fieldsplit/fieldsplit.c +++ b/src/postprocess/fieldsplit/fieldsplit.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/03 15:48:52 by khais #+# #+# */ -/* Updated: 2025/04/15 11:51:33 by khais ### ########.fr */ +/* Updated: 2025/04/15 11:59:23 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,8 @@ static void fieldsplit_delimit(t_buffer *word, t_buffer *marker, { t_worddesc *out; - out = worddesc_create(word->buffer, original->flags, marker->buffer); + out = worddesc_create(word->buffer, original->flags, marker->buffer, + WORD_TOKEN); (*outlist) = wordlist_push(*outlist, out); free(word); free(marker); diff --git a/src/subst/wildcard_exp.c b/src/subst/wildcard_exp.c index 4ae2981..31d751e 100644 --- a/src/subst/wildcard_exp.c +++ b/src/subst/wildcard_exp.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */ -/* Updated: 2025/04/03 19:58:36 by khais ### ########.fr */ +/* Updated: 2025/04/08 16:31:46 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,7 +69,7 @@ static t_wordlist *add_file_to_list(t_wordlist **list, char *filename) marker = construct_repeting_char_string('\'', ft_strlen(copy)); if (!marker) return (wordlist_destroy(*list), free(copy), NULL); - file_desc = worddesc_create(copy, '\0', marker); + file_desc = worddesc_create(copy, '\0', marker, WORD_TOKEN); if (!file_desc) { wordlist_destroy(*list); diff --git a/tests/test_here_doc.c b/tests/test_here_doc.c index c160a55..ce020e4 100644 --- a/tests/test_here_doc.c +++ b/tests/test_here_doc.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 11:43:32 by khais #+# #+# */ -/* Updated: 2025/03/28 19:05:55 by khais ### ########.fr */ +/* Updated: 2025/04/08 16:34:50 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,10 +45,10 @@ static void test_here_doc_invalid_args(void) ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); ft_errno(FT_ESUCCESS); assert(-1 == here_doc(NULL, 0, NULL)); - marker = worddesc_create(NULL, 0, NULL); + marker = worddesc_create(NULL, 0, NULL, WORD_TOKEN); assert(-1 == here_doc(marker, 0, NULL)); worddesc_destroy(marker); - marker = worddesc_create(ft_strdup("EOF"), 0, NULL); + marker = worddesc_create(ft_strdup("EOF"), 0, NULL, WORD_TOKEN); assert(-1 == here_doc(marker, -1, NULL)); worddesc_destroy(marker); do_leak_check(); @@ -62,7 +62,7 @@ static void test_here_doc_only_end_marker(void) ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); ft_errno(FT_ESUCCESS); - marker = worddesc_create(ft_strdup("EOF"), 0, NULL); + marker = worddesc_create(ft_strdup("EOF"), 0, NULL, WORD_TOKEN); infile = open("./here_doc_only_eof.input", O_RDONLY); result = here_doc(marker, infile, NULL); close(infile); @@ -81,7 +81,7 @@ static void test_here_doc_input_plus_end_marker(void) ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); ft_errno(FT_ESUCCESS); - marker = worddesc_create(ft_strdup("EOF"), 0, NULL); + marker = worddesc_create(ft_strdup("EOF"), 0, NULL, WORD_TOKEN); infile = open("./here_doc_input_plus_eof.input", O_RDONLY); result = here_doc(marker, infile, NULL); close(infile); @@ -99,7 +99,7 @@ static void test_here_doc_input_no_end_marker(void) int result; ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); - marker = worddesc_create(ft_strdup("EOF"), 0, NULL); + marker = worddesc_create(ft_strdup("EOF"), 0, NULL, WORD_TOKEN); infile = open("./here_doc_input_no_eof.input", O_RDONLY); result = here_doc(marker, infile, NULL); close(infile); @@ -121,7 +121,7 @@ static void test_here_doc_with_expansion(void) app.env = env_set_entry(&app.env, ft_strdup("USER"), ft_strdup("kcolin")); ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); ft_errno(FT_ESUCCESS); - marker = worddesc_create(ft_strdup("EOF"), 0, NULL); + marker = worddesc_create(ft_strdup("EOF"), 0, NULL, WORD_TOKEN); infile = open("./here_doc_with_expansion.input", O_RDONLY); result = here_doc(marker, infile, &app); close(infile); @@ -144,7 +144,7 @@ static void test_here_doc_with_no_expansion(void) ft_bzero(&app, sizeof(t_minishell)); app.env = env_set_entry(&app.env, ft_strdup("USER"), ft_strdup("kcolin")); ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); - marker = worddesc_create(ft_strdup("EOF"), W_QUOTED, NULL); + marker = worddesc_create(ft_strdup("EOF"), W_QUOTED, NULL, WORD_TOKEN); infile = open("./here_doc_with_expansion.input", O_RDONLY); result = here_doc(marker, infile, &app); close(infile); diff --git a/tests/test_wordlist_idx.c b/tests/test_wordlist_idx.c index c8a4d77..a03da8a 100644 --- a/tests/test_wordlist_idx.c +++ b/tests/test_wordlist_idx.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/10 14:59:19 by khais #+# #+# */ -/* Updated: 2025/03/10 16:02:01 by khais ### ########.fr */ +/* Updated: 2025/04/08 16:35:12 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ static void test_wordlist_idx_pop_single_elem(void) t_worddesc *got; ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); - list = wordlist_create(worddesc_create(ft_strdup("hello"), 0, ft_strdup(""))); + list = wordlist_create(worddesc_create(ft_strdup("hello"), 0, ft_strdup(""), WORD_TOKEN)); assert(NULL == wordlist_pop_idx(&list, 1)); got = wordlist_pop_idx(&list, 0); assert(NULL != got); @@ -48,8 +48,8 @@ static void test_wordlist_idx_pop_second_then_first(void) t_worddesc *got; ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__); - list = wordlist_create(worddesc_create(ft_strdup("hello"), 0, NULL)); - list = wordlist_push(list, worddesc_create(ft_strdup("world"), 0, NULL)); + list = wordlist_create(worddesc_create(ft_strdup("hello"), 0, NULL, WORD_TOKEN)); + list = wordlist_push(list, worddesc_create(ft_strdup("world"), 0, NULL, WORD_TOKEN)); wordlist_debug(list); got = wordlist_pop_idx(&list, 1); assert(NULL != got);