norm
This commit is contained in:
@@ -68,5 +68,7 @@ void debug_token_list(t_node *lst, char *msg);
|
|||||||
void set_token(t_node *head);
|
void set_token(t_node *head);
|
||||||
int goto_nxt_space(char *str);
|
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
|
#endif
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ static void add_prevhistory(t_msh *msh)
|
|||||||
|
|
||||||
void handle_sigint(int sig)
|
void handle_sigint(int sig)
|
||||||
{
|
{
|
||||||
(void)sig;
|
|
||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ bool check_unclosed_quote(char *c, t_node *node)
|
|||||||
i = 0;
|
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;
|
in_other_quote = !in_other_quote;
|
||||||
if (cpy->val[i] == c[0] && !in_other_quote)
|
if (cpy->val[i] == c[0] && !in_other_quote)
|
||||||
closed = !closed;
|
closed = !closed;
|
||||||
|
|||||||
@@ -52,42 +52,6 @@ void unstick_main(t_node *it)
|
|||||||
ft_free(&second_str);
|
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)
|
static int unstick_nodes(t_node *head)
|
||||||
{
|
{
|
||||||
t_node *it;
|
t_node *it;
|
||||||
|
|||||||
@@ -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)
|
int find_quote_node(t_node *head, char q)
|
||||||
{
|
{
|
||||||
t_node *it;
|
t_node *it;
|
||||||
|
|||||||
@@ -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) > 0 && !is_only_space(in))
|
||||||
{
|
{
|
||||||
if (ft_strlen(in) != ft_strlen(msh->prev_input) ||
|
if (ft_strlen(in) != ft_strlen(msh->prev_input)
|
||||||
ft_strncmp(in, msh->prev_input, -1) != 0)
|
|| ft_strncmp(in, msh->prev_input, -1) != 0)
|
||||||
{
|
{
|
||||||
add_history(in);
|
add_history(in);
|
||||||
ft_fprintf(msh->hist, "%s\n", in);
|
ft_fprintf(msh->hist, "%s\n", in);
|
||||||
|
|||||||
Reference in New Issue
Block a user