mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
worddesc_create: take the marker as an argument
This commit is contained in:
parent
14dbabd6ea
commit
e99c7e5986
2 changed files with 10 additions and 13 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 17:20:36 by khais #+# #+# */
|
||||
/* Updated: 2025/03/06 15:03:56 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/06 16:52:44 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
** allocate a new worddesc with given flags and the given word as word.
|
||||
** allocate a new worddesc with given flags, marker, and word.
|
||||
**
|
||||
** return null in case of error, or if word is null
|
||||
**
|
||||
|
|
@ -25,21 +25,18 @@
|
|||
** 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)
|
||||
t_worddesc *worddesc_create(char *word, char flags, char *marker)
|
||||
{
|
||||
t_worddesc *retvalue;
|
||||
t_worddesc *retvalue;
|
||||
|
||||
if (word == NULL)
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
retvalue = ft_calloc(1, sizeof(t_worddesc));
|
||||
if (retvalue == NULL)
|
||||
return (free(word), NULL);
|
||||
return (free(word), NULL);
|
||||
retvalue->word = word;
|
||||
retvalue->flags = flags;
|
||||
retvalue->marker = ft_calloc(ft_strlen(word) + 1, sizeof(char));
|
||||
if (retvalue->marker == NULL)
|
||||
return (free(word), free(retvalue), NULL);
|
||||
ft_memset(retvalue->marker, ' ', ft_strlen(word));
|
||||
retvalue->marker = marker;
|
||||
return (retvalue);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:47:58 by khais #+# #+# */
|
||||
/* Updated: 2025/03/06 17:20:50 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/06 17:21:07 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ typedef struct s_worddesc
|
|||
** '"' corresponding character is double-quoted
|
||||
** '$' corresponding character is a result of $var expansion
|
||||
*/
|
||||
char *marker;
|
||||
char *marker;
|
||||
} t_worddesc;
|
||||
|
||||
t_worddesc *worddesc_create(char *word, char flags);
|
||||
t_worddesc *worddesc_create(char *word, char flags, char *marker);
|
||||
void worddesc_destroy(t_worddesc *worddesc);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue