From 579a26f5593039ffbbd1a81e45ecf0ef8797cb5d Mon Sep 17 00:00:00 2001 From: nass1pro Date: Tue, 9 Jun 2020 19:48:34 +0200 Subject: add lexer add single quote --- test_mini/libft/src/str/ft_strtrim.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test_mini/libft/src/str/ft_strtrim.c (limited to 'test_mini/libft/src/str/ft_strtrim.c') diff --git a/test_mini/libft/src/str/ft_strtrim.c b/test_mini/libft/src/str/ft_strtrim.c new file mode 100644 index 0000000..aa48826 --- /dev/null +++ b/test_mini/libft/src/str/ft_strtrim.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/10/07 10:24:16 by cacharle #+# #+# */ +/* Updated: 2019/11/20 03:52:58 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strtrim(char const *s1, char const *set) +{ + size_t start; + size_t len; + + if (s1 == NULL || set == NULL) + return (NULL); + start = 0; + while (s1[start] && ft_strchr(set, s1[start]) != NULL) + start++; + len = ft_strlen(&s1[start]); + if (len != 0) + while (s1[start + len - 1] + && ft_strchr(set, s1[start + len - 1]) != NULL) + len--; + return (ft_substr(s1, start, len)); +} -- cgit