mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
quote removal: if given null, return null
This commit is contained in:
parent
0fecded23b
commit
7b76c1a71f
2 changed files with 14 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@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:09:17 by khais ### ########.fr */
|
/* Updated: 2025/03/07 11:09:30 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,11 +18,15 @@
|
||||||
** unquoted quotes.
|
** unquoted quotes.
|
||||||
**
|
**
|
||||||
** The new worddesc will have the marker set to NULL.
|
** The new worddesc will have the marker set to NULL.
|
||||||
|
**
|
||||||
|
** If word is null return null.
|
||||||
*/
|
*/
|
||||||
t_worddesc *remove_quotes(t_worddesc *word)
|
t_worddesc *remove_quotes(t_worddesc *word)
|
||||||
{
|
{
|
||||||
t_worddesc *output;
|
t_worddesc *output;
|
||||||
|
|
||||||
|
if (word == NULL)
|
||||||
|
return (NULL);
|
||||||
output = worddesc_create(ft_strdup(word->word), word->flags, NULL);
|
output = worddesc_create(ft_strdup(word->word), word->flags, NULL);
|
||||||
if (output->word == NULL)
|
if (output->word == NULL)
|
||||||
return (worddesc_destroy(output), NULL);
|
return (worddesc_destroy(output), NULL);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/28 13:46:56 by khais #+# #+# */
|
/* Created: 2025/02/28 13:46:56 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/07 10:59:54 by khais ### ########.fr */
|
/* Updated: 2025/03/07 11:07:59 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -35,7 +35,15 @@ static void test_quote_removal_no_quotes_single_word(void)
|
||||||
worddesc_destroy(got_word);
|
worddesc_destroy(got_word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_quote_removal_null(void)
|
||||||
|
{
|
||||||
|
t_worddesc *word = NULL;
|
||||||
|
t_worddesc *got_word = remove_quotes(word);
|
||||||
|
assert(got_word == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
test_quote_removal_no_quotes_single_word();
|
test_quote_removal_no_quotes_single_word();
|
||||||
|
test_quote_removal_null();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue