Commit 39363f6b authored by pêle-mêle's avatar pêle-mêle
Browse files

fix parsing for ''$var with var=' foo'

parent 047ee29b
......@@ -6,7 +6,7 @@
# By: mvidal-a <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/12/23 13:17:34 by mvidal-a #+# #+# #
# Updated: 2021/02/02 15:56:28 by mvidal-a ### ########.fr #
# Updated: 2021/02/03 22:25:28 by mvidal-a ### ########.fr #
# #
# **************************************************************************** #
......@@ -76,6 +76,7 @@ SRCS_CUSTOM += ft_varnamelen.c
SRCS_CUSTOM += blank_str.c
SRCS_CUSTOM += push_int_to_array.c
SRCS_CUSTOM += ft_isnumber.c
SRCS_CUSTOM += skip_spaces.c
VPATH = part_1:part_2:bonus:custom
......
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* skip_spaces.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/03 22:24:13 by mvidal-a #+# #+# */
/* Updated: 2021/02/03 22:24:43 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *skip_spaces(char *str)
{
while (ft_isspace(*str))
str++;
return (str);
}
......@@ -6,7 +6,7 @@
/* By: mvidal-a <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/04 12:29:06 by mvidal-a #+# #+# */
/* Updated: 2021/02/02 15:56:12 by mvidal-a ### ########.fr */
/* Updated: 2021/02/03 22:25:18 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
......@@ -104,6 +104,7 @@ ssize_t ft_index(char *haystack, char needle);
void ft_swap(void **a, void **b);
int ft_isspace(int c);
char *skip_spaces(char *str);
int blank_str(char *line);
int ft_isset(char c, char *set);
int ft_strcmp(const char *s1, const char *s2);
......
"exit fds" -> exit 2 after 'bad exit return code' error
"exit 42 1431" -> print "exit" before error
========> si appele sans argument, renvoie la valeur de retour de la commande précédente
builtins: set stat_loc for all returns
arthur:
comportement simplifié ^D
EXIT_NAN -> exit anyway
masaki:
a la fin avec rgrep:
......
......@@ -17,10 +17,10 @@ int ft_exit(char **args, t_xe *xe)
}
xe->stat_loc = ft_atoi(args[1]) % 256;
}
else // "exit NaN"
else
{
xe->stat_loc = 2;
return (EXIT_NAN);//another error, to print like bash
return (EXIT_NAN);
}
}
}
......
......@@ -6,7 +6,7 @@
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/27 12:14:56 by mvidal-a #+# #+# */
/* Updated: 2021/02/02 14:21:26 by mvidal-a ### ########.fr */
/* Updated: 2021/02/03 22:26:12 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
......@@ -15,15 +15,15 @@
static int add_var_args(t_state_machine *machine, char *var_value)
{
if (ft_isspace(*var_value) && machine->cur_arg[0] != '\0')
if (ft_isspace(*var_value)
&& (machine->cur_arg[0] != '\0' || machine->quote_state == TRUE))
{
if (add_arg(machine) == FAILURE)
return (FAILURE);
machine->var_token_count++;
var_value++;
}
while (ft_isspace(*var_value))
var_value++;
var_value = skip_spaces(var_value);
while (*var_value != '\0')
{
if (ft_isspace(*var_value))
......@@ -33,8 +33,7 @@ static int add_var_args(t_state_machine *machine, char *var_value)
machine->var_token_count++;
if (blank_str(var_value) == TRUE)
break ;
while (ft_isspace(*var_value))
var_value++;
var_value = skip_spaces(var_value);
}
if (add_to_buf(machine, *var_value++) == FAILURE)
return (FAILURE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment