fix history bugs with quotes
This commit is contained in:
parent
2bb33fe50c
commit
2440443588
1 changed files with 17 additions and 1 deletions
|
|
@ -34,10 +34,22 @@ static int history_parsing_nb_and_previous(char *str, int *i)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int check_validity(char *str, int i)
|
||||||
|
{
|
||||||
|
if (i && str[i - 1] == '\\')
|
||||||
|
return (0);
|
||||||
|
else if (str[i + 1] == '"')
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int history_parsing_nb_and_name(char *str, int *i)
|
static int history_parsing_nb_and_name(char *str, int *i)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
|
if (!check_validity(str, *i))
|
||||||
|
return (0);
|
||||||
if (history_parsing_nb_and_previous(str, i))
|
if (history_parsing_nb_and_previous(str, i))
|
||||||
return (1);
|
return (1);
|
||||||
else if (ft_isdigit(str[(*i) + 1]) && (size_t)ft_atoi(str + (*i) + 1) <
|
else if (ft_isdigit(str[(*i) + 1]) && (size_t)ft_atoi(str + (*i) + 1) <
|
||||||
|
|
@ -80,14 +92,18 @@ int ft_history_parsing(int has_prompt, char **input)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char boolean;
|
char boolean;
|
||||||
|
char quote;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
quote = 0;
|
||||||
boolean = 0;
|
boolean = 0;
|
||||||
if (!data_singleton()->line.input)
|
if (!data_singleton()->line.input)
|
||||||
return (0);
|
return (0);
|
||||||
while (data_singleton()->line.input && data_singleton()->line.input[i])
|
while (data_singleton()->line.input && data_singleton()->line.input[i])
|
||||||
{
|
{
|
||||||
if (data_singleton()->line.input[i] == '!')
|
if (data_singleton()->line.input[i] == '\'')
|
||||||
|
quote = quote ? 0 : 1;
|
||||||
|
else if (!quote && data_singleton()->line.input[i] == '!')
|
||||||
{
|
{
|
||||||
boolean = 1;
|
boolean = 1;
|
||||||
if (!history_parsing_nb_and_name(data_singleton()->line.input, &i))
|
if (!history_parsing_nb_and_name(data_singleton()->line.input, &i))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue