fix
This commit is contained in:
@@ -56,12 +56,13 @@ void free_linked_list(t_node *stack);
|
|||||||
t_token get_token(char *str);
|
t_token get_token(char *str);
|
||||||
t_pres get_pressision(char *s, t_token token, t_token last_token, t_pres last_pres);
|
t_pres get_pressision(char *s, t_token token, t_token last_token, t_pres last_pres);
|
||||||
int create_node_after(t_node *elem, char *val);
|
int create_node_after(t_node *elem, char *val);
|
||||||
char *copy_meta_xor(char *val, int *copied, int rev);
|
|
||||||
int is_meta(char c);
|
int is_meta(char c);
|
||||||
int is_sticked(char *val);
|
int is_sticked(char *val);
|
||||||
int trim_nodes(t_node *head);
|
int trim_nodes(t_node *head);
|
||||||
void debug_linked_list(t_node *head, char *msg);
|
void debug_linked_list(t_node *head, char *msg);
|
||||||
int find_quote_node(t_node *head, char q);
|
int find_quote_node(t_node *head, char q);
|
||||||
int syntax_error(t_node *head);
|
int syntax_error(t_node *head);
|
||||||
|
char *copy_meta(char *val, int *copied);
|
||||||
|
char *copy_unmeta(char *val, int *copied);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ static int unstick_nodes(t_node *head)
|
|||||||
if (is_sticked(it->val))
|
if (is_sticked(it->val))
|
||||||
{
|
{
|
||||||
if (is_meta(it->val[0]))
|
if (is_meta(it->val[0]))
|
||||||
first_str = copy_meta_xor(it->val, &copied, 0);
|
first_str = copy_meta(it->val, &copied);
|
||||||
else
|
else
|
||||||
first_str = copy_meta_xor(it->val, &copied, 1);
|
first_str = copy_unmeta(it->val, &copied);
|
||||||
second_str = ft_substr(it->val, copied, ft_strlen(it->val)
|
second_str = ft_substr(it->val, copied, ft_strlen(it->val)
|
||||||
- copied);
|
- copied);
|
||||||
ft_free(&it->val);
|
ft_free(&it->val);
|
||||||
@@ -153,6 +153,9 @@ t_node *tokenize(char *str)
|
|||||||
if (!head)
|
if (!head)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
debug_token_list(head, "tokenize_base");
|
debug_token_list(head, "tokenize_base");
|
||||||
|
if (!trim_nodes(head))
|
||||||
|
return (NULL);
|
||||||
|
debug_token_list(head, "trim_nodes");
|
||||||
if (!unstick_nodes(head))
|
if (!unstick_nodes(head))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
debug_token_list(head, "unstick_nodes");
|
debug_token_list(head, "unstick_nodes");
|
||||||
@@ -164,7 +167,7 @@ t_node *tokenize(char *str)
|
|||||||
debug_token_list(head, "trim_nodes");
|
debug_token_list(head, "trim_nodes");
|
||||||
set_token(head);
|
set_token(head);
|
||||||
del_void_nodes(&head);
|
del_void_nodes(&head);
|
||||||
debug_token_list(head, "del_void_nodes");
|
debug_token_list(head, "tokenizer");
|
||||||
if (syntax_error(head))
|
if (syntax_error(head))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (head);
|
return (head);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "../../../includes/minishell.h"
|
#include "../../../includes/minishell.h"
|
||||||
|
|
||||||
char *copy_meta_xor(char *val, int *copied, int rev)
|
char *copy_meta(char *val, int *copied)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@@ -21,7 +21,25 @@ char *copy_meta_xor(char *val, int *copied, int rev)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
ref = val[0];
|
ref = val[0];
|
||||||
while ((is_meta(val[i]) && val[i] == ref) ^ rev)
|
while (val[i] && ((is_meta(val[i]) && val[i] == ref)))
|
||||||
|
i++;
|
||||||
|
*copied = i;
|
||||||
|
out = malloc(i + 1);
|
||||||
|
j = -1;
|
||||||
|
while (++j < i)
|
||||||
|
out[j] = val[j];
|
||||||
|
out[i] = 0;
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *copy_unmeta(char *val, int *copied)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
char *out;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (val[i] && !is_meta(val[i]))
|
||||||
i++;
|
i++;
|
||||||
*copied = i;
|
*copied = i;
|
||||||
out = malloc(i + 1);
|
out = malloc(i + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user