/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* p_args_quotes.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include "d_define.h" /* static void */ /* p_arg_squotes(char word[]) */ /* { */ /* char *ptr; */ /* ptr = word; */ /* while ((ptr = ft_strchr(ptr, C_SQUOTE)) != NULL) */ /* { */ /* ft_memmove(word + (ptr - word), ptr + 1, ft_strlen(ptr + 1) + 1); */ /* } */ /* } */ static void p_arg_dquotes(char word[]) { char *ptr; ptr = word; while ((ptr = ft_strchr(ptr, C_DQUOTE)) != NULL) { if (ptr - word == 0) ft_memmove(word, word + 1, ft_strlen(word)); else if (ptr - word == 1 && *(ptr - 1) == C_BACKSLASH) ptr++; else if (ptr - word > 1 && *(ptr - 1) == C_BACKSLASH && *(ptr - 2) != C_BACKSLASH) ptr++; else ft_memmove(word + (ptr - word), ptr + 1, ft_strlen(ptr + 1) + 1); } } void p_args_quotes(char *words[]) { char **ptr; char *dq_ptr; char *sq_ptr; ptr = words; dq_ptr = NULL; sq_ptr = NULL; while (*ptr != NULL) { dq_ptr = ft_strchr(*ptr, C_DQUOTE); sq_ptr = ft_strchr(*ptr, C_SQUOTE); if (dq_ptr != NULL && sq_ptr != NULL) { if (dq_ptr < sq_ptr) p_arg_dquotes(*ptr); } /* if (**ptr == C_SQUOTE) */ /* p_arg_squotes(*ptr); */ /* else if (**ptr == C_DQUOTE) */ /* p_arg_dquotes(*ptr); */ ptr++; dq_ptr = NULL; sq_ptr = NULL; } }