wordsplit: handle a sigle word separated surrounded by blanks

a blank here is as defined by POSIX
https://pubs.opengroup.org/onlinepubs/9699919799/
section 7.3.1
This commit is contained in:
Khaïs COLIN 2025-02-14 15:06:01 +01:00
parent aa12f7c971
commit 00fd2380cf
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
2 changed files with 12 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/02/14 13:35:26 by khais ### ########.fr */
/* Updated: 2025/02/14 15:06:50 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,11 +28,11 @@ void test_wordsplit_singleword(void)
wordlist_destroy(words);
}
void test_wordsplit_singleword_with_spaces(void)
void test_wordsplit_singleword_with_blanks(void)
{
t_wordlist *words;
words = minishell_wordsplit(" echo ");
words = minishell_wordsplit("\t \t echo \t\t ");
assert_strequal("echo", wordlist_get(words, 0)->word);
assert(NULL == wordlist_get(words, 1));
wordlist_destroy(words);
@ -55,6 +55,6 @@ void test_wordsplit_basic(void)
int main(void) {
test_wordsplit_singleword();
test_wordsplit_singleword_with_spaces();
test_wordsplit_singleword_with_blanks();
return (0);
}