diff --git a/includes/parser/tokenizer.h b/includes/parser/tokenizer.h index 4e0cc5d..0dfb3f8 100644 --- a/includes/parser/tokenizer.h +++ b/includes/parser/tokenizer.h @@ -67,6 +67,8 @@ char *copy_unmeta(char *val, int *copied); void debug_token_list(t_node *lst, char *msg); void set_token(t_node *head); int goto_nxt_space(char *str); -void update_quote(char *quote, char cmp); +void update_quote(char *quote, char cmp); +int quote_sticked(char *str); +bool unstick_quote(int count, t_node *it); #endif diff --git a/srcs/expander/expand_var.c b/srcs/expander/expand_var.c index 5f92e46..2e8642a 100644 --- a/srcs/expander/expand_var.c +++ b/srcs/expander/expand_var.c @@ -85,7 +85,7 @@ void expander_var(t_ast_n *nd, int j, int i) int l; k = i; - if (expand_exit(nd, j , i)) + if (expand_exit(nd, j, i)) return ; new = ft_calloc(ft_strlen(nd->args[j]) + get_var_len(nd, j, &k), 1); if (!new) diff --git a/srcs/main.c b/srcs/main.c index 9b3ba7e..22a87ac 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -39,8 +39,7 @@ static void add_prevhistory(t_msh *msh) void handle_sigint(int sig) { - (void)sig; - int status; + int status; pid_t pid; pid = waitpid(-1, &status, 0); diff --git a/srcs/parsing/syntax/syntax_utils2.c b/srcs/parsing/syntax/syntax_utils2.c index 2a2dc22..c54a37f 100644 --- a/srcs/parsing/syntax/syntax_utils2.c +++ b/srcs/parsing/syntax/syntax_utils2.c @@ -68,9 +68,10 @@ bool check_unclosed_quote(char *c, t_node *node) while (cpy) { i = 0; - while(cpy->val[i]) + while (cpy->val[i]) { - if ((cpy->val[i] == '"' || cpy->val[i] == '\'') && cpy->val[i] != c[0] && closed) + if ((cpy->val[i] == '"' || cpy->val[i] == '\'') + && cpy->val[i] != c[0] && closed) in_other_quote = !in_other_quote; if (cpy->val[i] == c[0] && !in_other_quote) closed = !closed; diff --git a/srcs/parsing/tokenizer/tokenizer.c b/srcs/parsing/tokenizer/tokenizer.c index dfb9f63..e6a59b9 100644 --- a/srcs/parsing/tokenizer/tokenizer.c +++ b/srcs/parsing/tokenizer/tokenizer.c @@ -33,7 +33,7 @@ static t_node *tokenize_base(char *str) return (lst); } -void unstick_main(t_node *it) +void unstick_main(t_node *it) { char *first_str; char *second_str; @@ -52,42 +52,6 @@ void unstick_main(t_node *it) ft_free(&second_str); } -bool unstick_quote(int count, t_node *it) -{ - char *first_str; - char *second_str; - - if (count == 0) - return (false); - first_str = ft_substr(it->val, 0, count + 1); - second_str = ft_substr(it->val, count + 1, ft_strlen(it->val)); - ft_free(&it->val); - it->val = ft_strdup(first_str); - create_node_after(it, second_str); - ft_free(&first_str); - ft_free(&second_str); - return (true); -} - -int quote_sticked(char *str) -{ - int i; - char quote; - - i = 1; - quote = 0; - update_quote("e, str[0]); - while (str[i]) - { - if (quote && str[i] == quote) - if (str[i + 1] && is_meta(str[i + 1])) - return(i); - update_quote("e, str[i]); - i++; - } - return (0); -} - static int unstick_nodes(t_node *head) { t_node *it; diff --git a/srcs/parsing/tokenizer/tokenizer_utils.c b/srcs/parsing/tokenizer/tokenizer_utils.c index a367b98..6e6bf47 100644 --- a/srcs/parsing/tokenizer/tokenizer_utils.c +++ b/srcs/parsing/tokenizer/tokenizer_utils.c @@ -39,12 +39,12 @@ int trim_nodes(t_node *head) return (1); } -static bool is_space(char c) +static bool is_space(char c) { if ((c >= 9 && c <= 13) || c == 32) return (true); else - return (false); + return (false); } int goto_nxt_space(char *str) diff --git a/srcs/parsing/tokenizer/tokenizer_utils2.c b/srcs/parsing/tokenizer/tokenizer_utils2.c index 8423b02..c37a363 100644 --- a/srcs/parsing/tokenizer/tokenizer_utils2.c +++ b/srcs/parsing/tokenizer/tokenizer_utils2.c @@ -53,6 +53,42 @@ void set_token(t_node *head) } } +bool unstick_quote(int count, t_node *it) +{ + char *first_str; + char *second_str; + + if (count == 0) + return (false); + first_str = ft_substr(it->val, 0, count + 1); + second_str = ft_substr(it->val, count + 1, ft_strlen(it->val)); + ft_free(&it->val); + it->val = ft_strdup(first_str); + create_node_after(it, second_str); + ft_free(&first_str); + ft_free(&second_str); + return (true); +} + +int quote_sticked(char *str) +{ + int i; + char quote; + + i = 1; + quote = 0; + update_quote("e, str[0]); + while (str[i]) + { + if (quote && str[i] == quote) + if (str[i + 1] && is_meta(str[i + 1])) + return (i); + update_quote("e, str[i]); + i++; + } + return (0); +} + int find_quote_node(t_node *head, char q) { t_node *it; diff --git a/srcs/parsing/tokenizer/unstick_node_utils.c b/srcs/parsing/tokenizer/unstick_node_utils.c index f5a6330..3b34636 100644 --- a/srcs/parsing/tokenizer/unstick_node_utils.c +++ b/srcs/parsing/tokenizer/unstick_node_utils.c @@ -68,7 +68,7 @@ int unic(int *meta) return (1); } -void update_quote(char *quote, char cmp) +void update_quote(char *quote, char cmp) { if (*quote == 0 && (cmp == '"' || cmp == '\'')) *quote = cmp; diff --git a/srcs/powerline.c b/srcs/powerline.c index 4b75833..21188b4 100644 --- a/srcs/powerline.c +++ b/srcs/powerline.c @@ -17,8 +17,8 @@ static void handle_input(char *in, t_msh *msh) { if (ft_strlen(in) > 0 && !is_only_space(in)) { - if (ft_strlen(in) != ft_strlen(msh->prev_input) || - ft_strncmp(in, msh->prev_input, -1) != 0) + if (ft_strlen(in) != ft_strlen(msh->prev_input) + || ft_strncmp(in, msh->prev_input, -1) != 0) { add_history(in); ft_fprintf(msh->hist, "%s\n", in);