cmdlist parse: fix issues reported by @Odroth

This commit is contained in:
Khaïs COLIN 2025-03-09 14:28:54 +01:00 committed by Khaïs COLIN
parent 7595562597
commit 4fa56b45b6
3 changed files with 12 additions and 8 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/24 17:45:01 by khais #+# #+# */
/* Updated: 2025/03/04 13:25:44 by khais ### ########.fr */
/* Updated: 2025/03/09 14:22:19 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -46,7 +46,7 @@
** A && B
** ```
**
** B is execute if and only if A has an exit status of 0 (succes).
** B is executed if and only if A has an exit status of 0 (succes).
**
** An OR list has the form
**
@ -54,7 +54,7 @@
** A || B
** ```
**
** B is execute if and only if A has a non-zero exit status (failure).
** B is executed if and only if A has a non-zero exit status (failure).
**
** The return status of AND and OR lists is the exit status of the last command
** executed in the list.
@ -62,7 +62,7 @@
typedef struct s_cmdlist
{
/*
** List of pipelines contained in this command list.
** Array of pipelines contained in this command list.
**
** These should be executed left to right.
*/

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/26 13:51:18 by khais #+# #+# */
/* Updated: 2025/03/04 15:23:06 by khais ### ########.fr */
/* Updated: 2025/03/09 14:24:05 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,8 +66,8 @@ static t_cmdlist *allocate_command_list(t_wordlist *words)
}
/*
** setup a cmdlist_builder by allocating needed memory, and performing other
** initialization steps.
** setup a given cmdlist_builder by allocating additional needed memory, and
** performing other initialization steps.
*/
t_cmdlist_builder *setup_cmdlist_builder(
t_cmdlist_builder *builder,

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/04 12:07:53 by khais #+# #+# */
/* Updated: 2025/03/04 13:31:08 by khais ### ########.fr */
/* Updated: 2025/03/09 14:29:36 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,12 +25,16 @@ t_wordlist *wordlist_copy(const t_wordlist *wordlist)
if (wordlist == NULL)
return (NULL);
outlist = ft_calloc(1, sizeof(t_wordlist));
if (outlist == NULL)
return (NULL);
outlist->word = worddesc_copy(wordlist->word);
current = outlist;
while (wordlist != NULL)
{
if (wordlist->next != NULL)
current->next = ft_calloc(1, sizeof(t_wordlist));
if (current->next == NULL)
return (wordlist_destroy(outlist), NULL);
wordlist = wordlist->next;
current = current->next;
if (wordlist == NULL)