aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornass1pro <nass1pro@gmail.com>2020-07-14 09:59:47 +0200
committernass1pro <nass1pro@gmail.com>2020-07-14 09:59:47 +0200
commit3ea9f3e7e9b40c8e0b17ab394576c82f7b92c0b4 (patch)
tree6ec7d179aeddc96a470148336947979c4010b2ec /src
parent4ad25e7fe330df66725bf74a662a49bcd31b8a8a (diff)
downloadminishell-3ea9f3e7e9b40c8e0b17ab394576c82f7b92c0b4.tar.gz
minishell-3ea9f3e7e9b40c8e0b17ab394576c82f7b92c0b4.tar.bz2
minishell-3ea9f3e7e9b40c8e0b17ab394576c82f7b92c0b4.zip
uptdate error
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
-rw-r--r--src/parse/parse.c6
-rw-r--r--src/parse/parse_error.c8
-rw-r--r--src/utils.c6
4 files changed, 14 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index 16c6267..e5c9bf9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,7 +6,7 @@
/* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:45:44 by cacharle #+# #+# */
-/* Updated: 2020/07/13 14:55:16 by nahaddac ### ########.fr */
+/* Updated: 2020/07/14 09:41:42 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
@@ -85,7 +85,6 @@ int main(int argc, char **argv, char **envp)
/* ft_lstiter(lex_out, token_debug); */
t_ret *parser_out = parse(lex_out);
- printf("%s\n","ssss" );
if (parser_out == NULL || parser_out->unexpected != NULL)
return (1);
@@ -98,7 +97,6 @@ int main(int argc, char **argv, char **envp)
/* ft_lstiter(parser_out->ast->cmd_argv, token_debug); */
/* printf("===redirs===\n"); */
/* ft_lstiter(parser_out->ast->redirs, token_debug); */
- printf("%s\n", "salut ");
int fds[2] = {MS_NO_FD, MS_NO_FD};
int eval_out = eval(fds, env, path, parser_out->ast);
(void)eval_out;
@@ -121,6 +119,11 @@ int main(int argc, char **argv, char **envp)
return (1);
t_ret *parser_out = parse(lex_out);
+ if (parser_out == NULL || parser_out->unexpected != NULL)
+ {
+ printf("%s\n",((t_token *)parser_out->unexpected)->content);
+ return (1);
+ }
int fds[2] = {MS_NO_FD, MS_NO_FD};
int eval_out = eval(fds, env, path, parser_out->ast);
diff --git a/src/parse/parse.c b/src/parse/parse.c
index 610b640..6e4721a 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -6,7 +6,7 @@
/* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/17 18:09:04 by nahaddac #+# #+# */
-/* Updated: 2020/07/13 14:54:37 by nahaddac ### ########.fr */
+/* Updated: 2020/07/14 09:43:41 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
@@ -174,12 +174,8 @@ t_ret *parse(t_ftlst *input)
return (NULL);
ret->ast = NULL;
ret->rest = NULL;
-
if((ret->unexpected = error_syntax_simple(input)))
return (ret);
- printf("%s\n",((t_token *)ret->unexpected)->content);
ret = parse_op(input);
- //ast_destroy(ret->ast);
- //ft_lstdestroy(&ret->rest, (void (*)(void*))token_destroy);
return (ret);
}
diff --git a/src/parse/parse_error.c b/src/parse/parse_error.c
index e48eda2..b63715d 100644
--- a/src/parse/parse_error.c
+++ b/src/parse/parse_error.c
@@ -6,7 +6,7 @@
/* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/18 15:09:48 by nahaddac #+# #+# */
-/* Updated: 2020/07/13 14:30:39 by nahaddac ### ########.fr */
+/* Updated: 2020/07/14 09:43:35 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
@@ -81,15 +81,15 @@ t_token *error_syntax_simple(t_ftlst *in)
tk = in->next->data;
i = ft_strlen(tk->content);
if (i >= 3)
- tk->content[3] = '\0';
+ tk->content[2] = '\0';
tk->content =
ft_strjoin3("minishell: syntax error near unexpected token `",
tk->content, "'");
+ printf("%s\n",tk->content );
return(tk);
}
}
in = in->next;
}
- return first;
-
+ return 0;
}
diff --git a/src/utils.c b/src/utils.c
index 2eaac3e..84a1920 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:56:31 by cacharle #+# #+# */
-/* Updated: 2020/06/18 13:46:26 by charles ### ########.fr */
+/* Updated: 2020/07/14 09:42:14 by nahaddac ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,7 +27,7 @@ int utils_directory_iter(
struct dirent *entry;
if ((dir = opendir(dirname)) == NULL) // add fail safe
- return (-1);
+ return (0);
while ((entry = readdir(dir)) != NULL)
if (f(dirname, entry, param) == -1)
{