diff options
-rw-r--r-- | src/p_args.c | 38 | ||||
-rw-r--r-- | src/p_args.h | 6 |
2 files changed, 16 insertions, 28 deletions
diff --git a/src/p_args.c b/src/p_args.c index fc676a1..6431cfc 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -21,8 +21,7 @@ #include "u_parse.h" #include "u_utils.h" -static void - p_meet_bs(char *ptr, t_quote_mode mode) +static void p_meet_bs(char *ptr, t_quote_mode mode) { if (mode != Q_SINGLE) { @@ -34,8 +33,7 @@ static void } } -static t_bool - p_meet_whitespace(char *head, char *ptr, t_quote_mode mode) +static t_bool p_meet_whitespace(char *head, char *ptr, t_quote_mode mode) { if (mode == Q_NONE && u_is_not_escaped(head, ptr) == TRUE) { @@ -44,16 +42,18 @@ static t_bool return (FALSE); } -static char - *p_skip_whitespace(char *ptr) +static char *p_skip_whitespace(char *ptr) { while (*ptr != C_NUL && ft_iswhitespace(*ptr)) ptr++; return (ptr); } -static uint16_t - p_count_args(const char word[], size_t start[]) +/* +** TODO: quotes parse error +*/ + +static uint16_t p_count_args(const char word[], size_t start[]) { char *ptr; t_quote_mode mode; @@ -72,8 +72,8 @@ static uint16_t mode = u_meet_dquote(word, ptr, mode); else if (*ptr == C_SQUOTE) mode = u_meet_squote(word, ptr, mode); - if (ft_iswhitespace(*ptr) == TRUE && - p_meet_whitespace((char*)word, ptr, mode) == TRUE) + if (ft_iswhitespace(*ptr) == TRUE + && p_meet_whitespace((char*)word, ptr, mode) == TRUE) { ptr = p_skip_whitespace(ptr); start[count] = (ptr - word); @@ -84,17 +84,16 @@ static uint16_t ptr++; } return (count); - /* TODO: quotes parse error */ } -static char - **p_split_words(const char word[]) +char **p_split_args(char word[]) { - char **words; + char **words; size_t start[512]; uint16_t argc; uint16_t to_del; + words = NULL; argc = p_count_args(word, start); if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL) return (NULL); @@ -107,14 +106,3 @@ static char p_args_escape_chars_and_quotes(words); return (words); } - -char - **p_split_args(char word[]) -{ - char **words; - - words = NULL; - if ((words = p_split_words(word)) == NULL) - return (NULL); - return (words); -} diff --git a/src/p_args.h b/src/p_args.h index 42db6c0..a399c35 100644 --- a/src/p_args.h +++ b/src/p_args.h @@ -10,10 +10,10 @@ /* */ /* ************************************************************************** */ -#ifndef P_ARGS_H -#define P_ARGS_H +#ifndef FT_P_ARGS_H +# define FT_P_ARGS_H -#include <stdint.h> +# include <stdint.h> char **p_split_args(char word[]); |