mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
32 lines
1.4 KiB
C
32 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* wordsplit.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/02/13 17:02:32 by khais #+# #+# */
|
|
/* Updated: 2025/02/14 14:19:30 by khais ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "wordsplit.h"
|
|
#include "libft.h"
|
|
|
|
/*
|
|
** split a string into words, respecting quotes etc.
|
|
**
|
|
** cf. Token Recognition section at
|
|
** https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
|
|
*/
|
|
t_wordlist *minishell_wordsplit(char *original)
|
|
{
|
|
size_t start;
|
|
size_t length;
|
|
char *outstr;
|
|
|
|
start = ft_strnchridx(original, ' ');
|
|
length = ft_strchridx(original + start, ' ');
|
|
outstr = ft_substr(original, start, length);
|
|
return (wordlist_create(worddesc_create(outstr)));
|
|
}
|