quote marking: no quotes lead to marker filled with spaces

This commit is contained in:
Khaïs COLIN 2025-03-06 14:53:46 +01:00
parent 4b403c4bf3
commit 2c5d5abdc4
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
3 changed files with 39 additions and 6 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 17:20:36 by khais #+# #+# */
/* Updated: 2025/02/20 14:02:11 by khais ### ########.fr */
/* Updated: 2025/03/06 15:03:56 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,18 +18,28 @@
** allocate a new worddesc with given flags and the given word as word.
**
** return null in case of error, or if word is null
**
** mark_string is initialized as a string of the same length as word, but filled
** with spaces
**
** 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 *retvalue;
t_worddesc *retvalue;
if (word == NULL)
return (NULL);
return (NULL);
retvalue = ft_calloc(1, sizeof(t_worddesc));
if (retvalue == NULL)
return (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));
return (retvalue);
}
@ -41,5 +51,6 @@ void worddesc_destroy(t_worddesc *worddesc)
if (worddesc == NULL)
return ;
free(worddesc->word);
free(worddesc->marker);
free(worddesc);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:47:58 by khais #+# #+# */
/* Updated: 2025/02/20 14:02:21 by khais ### ########.fr */
/* Updated: 2025/03/06 17:20:50 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,6 +41,18 @@ typedef struct s_worddesc
** See above for flag definitions
*/
char flags;
/*
** a character mask for word to designate the status
** of its characters and wether or not they are subject to modifications
**
** Possible flags are ''', '"', '$', ' '
**
** ' ' the default, no flag, no meaning
** ''' corresponding character is single-quoted
** '"' corresponding character is double-quoted
** '$' corresponding character is a result of $var expansion
*/
char *marker;
} t_worddesc;
t_worddesc *worddesc_create(char *word, char flags);