diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/builtin/builtin.c | 12 | ||||
| -rw-r--r-- | src/builtin/cd.c | 9 | ||||
| -rw-r--r-- | src/builtin/echo.c | 9 | ||||
| -rw-r--r-- | src/builtin/env.c | 9 | ||||
| -rw-r--r-- | src/builtin/exit.c | 13 | ||||
| -rw-r--r-- | src/builtin/export.c | 14 | ||||
| -rw-r--r-- | src/builtin/pwd.c | 9 | ||||
| -rw-r--r-- | src/builtin/unset.c | 9 | ||||
| -rw-r--r-- | src/eval/cmd.c | 78 | ||||
| -rw-r--r-- | src/eval/eval.c | 75 | ||||
| -rw-r--r-- | src/eval/local.c | 68 | ||||
| -rw-r--r-- | src/eval/operation.c (renamed from src/eval/op.c) | 47 | ||||
| -rw-r--r-- | src/eval/parenthesis.c | 37 | ||||
| -rw-r--r-- | src/lexer/tok_lst.c | 10 | ||||
| -rw-r--r-- | src/lexer/trim.c | 6 |
15 files changed, 223 insertions, 182 deletions
diff --git a/src/builtin/builtin.c b/src/builtin/builtin.c index 08abcd8..23a5f44 100644 --- a/src/builtin/builtin.c +++ b/src/builtin/builtin.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:11:01 by charles #+# #+# */ -/* Updated: 2020/07/17 11:16:57 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:18:32 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ #include "minishell.h" /* -** \brief Array storing builtin executable name and associated functions +** \brief Array storing builtin executable name, associated functions +** and if they should be executed in a fork */ static t_builtin_entry g_builtin_lookup[] = { @@ -31,6 +32,13 @@ static t_builtin_entry g_builtin_lookup[] = { {"exit", builtin_exit, false}, }; +/* +** \brief Search a builtin by name in g_builtin_lookup +** \param name Name of the searched builtin +** \return the builtin entry of the associated name +** or NULL if name is not a builtin. +*/ + t_builtin_entry *builtin_search_func(char *name) { size_t i; diff --git a/src/builtin/cd.c b/src/builtin/cd.c index de1eeb9..3be77ea 100644 --- a/src/builtin/cd.c +++ b/src/builtin/cd.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:20 by charles #+# #+# */ -/* Updated: 2020/09/12 11:09:49 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:20:13 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,13 @@ #include "minishell.h" +/* +** \brief Change directory +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_cd(char **argv, t_env env) { char buf[PATH_MAX + 1]; diff --git a/src/builtin/echo.c b/src/builtin/echo.c index 9ad427a..f15a7f2 100644 --- a/src/builtin/echo.c +++ b/src/builtin/echo.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:47 by charles #+# #+# */ -/* Updated: 2020/09/12 15:24:34 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:24:34 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,13 @@ #include "minishell.h" +/* +** \brief Print it's arguments out +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_echo(char **argv, t_env env) { bool newline; diff --git a/src/builtin/env.c b/src/builtin/env.c index 5854828..6b430c4 100644 --- a/src/builtin/env.c +++ b/src/builtin/env.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:32 by charles #+# #+# */ -/* Updated: 2020/04/01 22:25:43 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:23:59 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,13 @@ #include "minishell.h" +/* +** \brief Print the environment variables (one on each line) +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_env(char **argv, t_env env) { (void)argv; diff --git a/src/builtin/exit.c b/src/builtin/exit.c index a24efad..51c8013 100644 --- a/src/builtin/exit.c +++ b/src/builtin/exit.c @@ -6,17 +6,24 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:16 by charles #+# #+# */ -/* Updated: 2020/09/10 19:41:03 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:25:55 by charles ### ########.fr */ /* */ /* ************************************************************************** */ -#include "minishell.h" - /* ** \file exit.c ** \brief `exit` builtin */ +#include "minishell.h" + +/* +** \brief Exit the current process with a status +** \param argv arguments +** \param env environment +** \return always 0 +*/ + int builtin_exit(char **argv, t_env env) { long status; diff --git a/src/builtin/export.c b/src/builtin/export.c index f19842e..4ac6626 100644 --- a/src/builtin/export.c +++ b/src/builtin/export.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:11:34 by charles #+# #+# */ -/* Updated: 2020/09/13 14:16:28 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:22:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,11 @@ #include "minishell.h" +/* +** \brief Put an environment variable in the format "declare -x id=value" of bash +** \param s Full variable (id=value) +*/ + static void st_put_declare_x(char *s) { char *equal_ptr; @@ -51,6 +56,13 @@ static void st_put_declare_x(char *s) ft_putchar('\n'); } +/* +** \brief Export variables to the environment +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_export(char **argv, t_env env) { int status; diff --git a/src/builtin/pwd.c b/src/builtin/pwd.c index 46c69a9..0d8a7f1 100644 --- a/src/builtin/pwd.c +++ b/src/builtin/pwd.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:40 by charles #+# #+# */ -/* Updated: 2020/07/19 20:27:28 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:23:15 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,13 @@ #include "minishell.h" +/* +** \brief Print the current directory +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_pwd(char **argv, t_env env) { char buf[PATH_MAX]; diff --git a/src/builtin/unset.c b/src/builtin/unset.c index 30facd3..9d0c66f 100644 --- a/src/builtin/unset.c +++ b/src/builtin/unset.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:10:51 by charles #+# #+# */ -/* Updated: 2020/09/10 13:49:58 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:22:35 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,13 @@ #include "minishell.h" +/* +** \brief Remove variables from the environment +** \param argv arguments +** \param env environment +** \return a status code or EVAL_FATAL on fatal error +*/ + int builtin_unset(char **argv, t_env env) { size_t i; diff --git a/src/eval/cmd.c b/src/eval/cmd.c index 82e30c9..223725c 100644 --- a/src/eval/cmd.c +++ b/src/eval/cmd.c @@ -6,7 +6,7 @@ /* By: charles <charles@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/14 10:41:31 by charles #+# #+# */ -/* Updated: 2020/09/13 14:19:37 by charles ### ########.fr */ +/* Updated: 2020/09/13 21:00:38 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,68 +17,16 @@ int g_last_status = 0; void token_debug(void *v); -/* -** \brief Wrap a function in a fork -** \param fd_in fork input file descriptor -** \param fd_out fork output file descriptor -** \param passed param of the wrapped function -** \param wrapped function to wrap -*/ - -int fork_wrap( - int fds[2], - void *passed, - int (*wrapped)(void *param), - pid_t *child_pid -) -{ - int status; - bool waiting; - pid_t pid; - - waiting = child_pid == NULL; - if (waiting) - child_pid = &pid; - if ((*child_pid = fork()) == -1) - return (EVAL_FATAL); - if (*child_pid == 0) - { - if ((fds[FD_READ] != FD_NONE && dup2(fds[FD_READ], STDIN_FILENO) == -1) || - (fds[FD_WRITE] != FD_NONE && dup2(fds[FD_WRITE], STDOUT_FILENO) == -1)) - exit(EXIT_FAILURE); - if ((status = wrapped(passed)) == EVAL_FATAL) // FIXME detect fatal in child (pipe ?) - exit(EXIT_FAILURE); - exit(status); - } - g_child_pid = *child_pid; - if (waiting) - { - waitpid(*child_pid, child_pid, 0); - close(fds[FD_WRITE]); - /* close(fds[FD_READ]); */ - return (WEXITSTATUS(*child_pid)); - } - return (0); -} - -int forked_cmd(void *void_param) +int wrapped_cmd(void *void_param) { t_fork_param_cmd *param; int status; - struct stat statbuf; param = void_param; if (param->builtin != NULL) return (param->builtin->func(param->argv, param->env)); else { - if (stat(param->exec_path, &statbuf) == -1) - return (errorf_ret(126, "%s: %s\n", param->exec_path, strerror(errno))); - if (S_ISDIR(statbuf.st_mode)) - return (errorf_ret(126, "%s: Is a directory\n", param->exec_path)); - if (!(statbuf.st_mode & 0444)) - return (errorf_ret(126, "%s: %s\n", param->exec_path, strerror(EACCES))); - errno = 0; status = execve(param->exec_path, param->argv, (char**)param->env->data); if (status == -1) { @@ -90,6 +38,19 @@ int forked_cmd(void *void_param) } } +int check_exec_path(char *exec_path) +{ + struct stat statbuf; + + if (stat(exec_path, &statbuf) == -1) + return (errorf_ret(126, "%s: %s\n", exec_path, strerror(errno))); + if (S_ISDIR(statbuf.st_mode)) + return (errorf_ret(126, "%s: Is a directory\n", exec_path)); + if (!(statbuf.st_mode & 0444)) + return (errorf_ret(126, "%s: %s\n", exec_path, strerror(EACCES))); + return (0); +} + int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) { t_fork_param_cmd param; @@ -108,6 +69,9 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) if (argv[0] == NULL) return (0); param.builtin = builtin_search_func(argv[0]); + if (param.builtin != NULL && !param.builtin->forked && child_pid == NULL) + return (param.builtin->func(argv, env)); + if (param.builtin == NULL) { param.exec_path = exec_search_path(path, env_search(env, "PATH"), argv[0]); @@ -117,13 +81,13 @@ int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) ft_split_destroy(argv); return (127); } + if ((status = check_exec_path(param.exec_path)) != 0) + return (status); } - else if (!param.builtin->forked && child_pid == NULL) - return (param.builtin->func(argv, env)); param.argv = argv; param.env = env; - status = fork_wrap(fds, ¶m, &forked_cmd, child_pid); + status = fork_wrap(fds, ¶m, &wrapped_cmd, child_pid); ft_split_destroy(argv); g_last_status = status; return (status); diff --git a/src/eval/eval.c b/src/eval/eval.c new file mode 100644 index 0000000..d35d491 --- /dev/null +++ b/src/eval/eval.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* eval.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/13 20:38:06 by charles #+# #+# */ +/* Updated: 2020/09/13 20:45:20 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "eval.h" + +/* +** \brief Wrap a function in a fork +** \param fds fork read/write file descriptors +** \param passed param of the wrapped function +** \param wrapped function to wrap +** \param child_pid Pointer where to store the child pid +** or NULL if the child should be waited +** \return The child status code or EVAL_FATAL on error +*/ + +int fork_wrap( + int fds[2], + void *passed, + int (*wrapped)(void *param), + pid_t *child_pid +) +{ + int status; + bool waiting; + pid_t pid; + + waiting = child_pid == NULL; + if (waiting) + child_pid = &pid; + if ((*child_pid = fork()) == -1) + return (EVAL_FATAL); + if (*child_pid == 0) + { + if ((fds[FD_READ] != FD_NONE && dup2(fds[FD_READ], STDIN_FILENO) == -1) || + (fds[FD_WRITE] != FD_NONE && dup2(fds[FD_WRITE], STDOUT_FILENO) == -1)) + exit(EXIT_FAILURE); + if ((status = wrapped(passed)) == EVAL_FATAL) // FIXME detect fatal in child (pipe ?) + exit(EXIT_FAILURE); + exit(status); + } + g_child_pid = *child_pid; + if (waiting) + { + waitpid(*child_pid, child_pid, 0); + close(fds[FD_WRITE]); + /* close(fds[FD_READ]); */ + return (WEXITSTATUS(*child_pid)); + } + return (0); +} + +/* +** \brief Evaluate and AST +** \return The last command status or EVAL_FATAL on error +*/ + +int eval(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) +{ + if (ast->tag == AST_PARENT) + return (eval_parenthesis(fds, env, path, ast)); + if (ast->tag == AST_OP) + return (eval_operation(fds, env, path, ast)); + if (ast->tag == AST_CMD) + return (eval_cmd(fds, env, path, ast, child_pid)); + return (EVAL_FATAL); +} diff --git a/src/eval/local.c b/src/eval/local.c deleted file mode 100644 index 089a0c7..0000000 --- a/src/eval/local.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* local.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/08/28 16:52:54 by charles #+# #+# */ -/* Updated: 2020/08/28 16:53:04 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "eval.h" - - /* while (ast->cmd_argv != NULL */ - /* && ((t_token*)ast->cmd_argv->data)->tag & TAG_IS_STR */ - /* && utils_start_with_valid_identifier(((t_token*)ast->cmd_argv->data)->content)) */ - /* { */ - /* t_ftlst *start; */ - /* */ - /* id = ((t_token*)ast->cmd_argv->data)->content; */ - /* *ft_strchr(id, '=') = '\0'; */ - /* ((t_token*)ast->cmd_argv->data)->content = ft_strchr(id, '\0') + 1; */ - /* if (*((t_token*)ast->cmd_argv->data)->content == '\0') */ - /* ft_lstpop_front(&ast->cmd_argv, NULL); */ - /* else */ - /* { */ - /* t_ftlst *curr = ast->cmd_argv; */ - /* t_ftlst *prev = curr; */ - /* */ - /* while (curr != NULL */ - /* && ((t_token*)curr->data)->tag & TAG_STICK && ((t_token*)curr->data)->tag & TAG_IS_STR) */ - /* { */ - /* prev = curr; */ - /* curr = curr->next; */ - /* } */ - /* if (curr != NULL && ((t_token*)curr->data)->tag & TAG_IS_STR) */ - /* { */ - /* prev = curr; */ - /* curr = curr->next; */ - /* } */ - /* */ - /* start = ast->cmd_argv; */ - /* ast->cmd_argv = prev->next; */ - /* prev->next = NULL; */ - /* } */ - /* */ - /* #<{(| ft_lstiter(start, token_debug); |)}># */ - /* #<{(| puts(""); |)}># */ - /* #<{(| ft_lstiter(ast->cmd_argv, token_debug); |)}># */ - /* */ - /* char **strs = preprocess(&start, env); */ - /* */ - /* if (env_export(param.env_local, id, strs[0]) == NULL) */ - /* return (-1); */ - /* } */ - /* if (ast->cmd_argv == NULL) // FIXME special env not passed to child processes */ - /* { */ - /* ft_vecpop(param.env_local, NULL); */ - /* if (ft_vecswallow_at(env, env->size - 1, param.env_local) == NULL) */ - /* { */ - /* ft_vecdestroy(param.env_local, free); */ - /* return (-1); */ - /* } */ - /* g_last_status = 0; */ - /* return (0); */ - /* } */ - diff --git a/src/eval/op.c b/src/eval/operation.c index 7181e83..eaafcf8 100644 --- a/src/eval/op.c +++ b/src/eval/operation.c @@ -1,18 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* op.c :+: :+: :+: */ +/* operation.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 15:27:22 by charles #+# #+# */ -/* Updated: 2020/09/13 14:22:45 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:38:26 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "eval.h" -int eval_op(int fds[2], t_env env, t_path path, t_ast *ast) +int eval_operation(int fds[2], t_env env, t_path path, t_ast *ast) { int status; int left_fds[2]; @@ -58,44 +58,3 @@ int eval_op(int fds[2], t_env env, t_path path, t_ast *ast) return (status); return (eval(right_fds, env, path, ast->op.right, NULL)); } - -int wrapped_eval(void *void_param) -{ - t_fork_param_args *param; - - param = void_param; - return (eval(param->fds, param->env, param->path, param->ast, NULL)); -} - -int eval_parent(int fds[2], t_env env, t_path path, t_ast *ast) -{ - int status; - - if ((status = redir_extract(&ast->redirs, env, fds)) != 0) - return (status); - ast->tag ^= AST_PARENT; - return (eval_forked(fds, env, path, ast->parent_ast, NULL)); -} - -int eval_forked(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) -{ - t_fork_param_args param; - - param.fds[0] = fds[0]; - param.fds[1] = fds[1]; - param.env = env; - param.path = path; - param.ast = ast; - return (fork_wrap(fds, ¶m, wrapped_eval, child_pid)); -} - -int eval(int fds[2], t_env env, t_path path, t_ast *ast, pid_t *child_pid) -{ - if (ast->tag == AST_PARENT) - return (eval_parent(fds, env, path, ast)); - if (ast->tag == AST_OP) - return (eval_op(fds, env, path, ast)); - if (ast->tag == AST_CMD) - return (eval_cmd(fds, env, path, ast, child_pid)); - return (EVAL_FATAL); -} diff --git a/src/eval/parenthesis.c b/src/eval/parenthesis.c new file mode 100644 index 0000000..8983378 --- /dev/null +++ b/src/eval/parenthesis.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parenthesis.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/13 20:38:29 by charles #+# #+# */ +/* Updated: 2020/09/13 20:40:19 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "eval.h" + +int wrapped_eval(void *void_param) +{ + t_fork_param_args *param; + + param = void_param; + return (eval(param->fds, param->env, param->path, param->ast, NULL)); +} + +int eval_parenthesis(int fds[2], t_env env, t_path path, t_ast *ast) +{ + int status; + t_fork_param_args param; + + if ((status = redir_extract(&ast->redirs, env, fds)) != 0) + return (status); + ast->tag ^= AST_PARENT; + param.fds[0] = fds[0]; + param.fds[1] = fds[1]; + param.env = env; + param.path = path; + param.ast = ast->parent_ast; + return (fork_wrap(fds, ¶m, wrapped_eval, NULL)); +} diff --git a/src/lexer/tok_lst.c b/src/lexer/tok_lst.c index debeb9a..4f5b2dc 100644 --- a/src/lexer/tok_lst.c +++ b/src/lexer/tok_lst.c @@ -6,7 +6,7 @@ /* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/08/27 09:32:58 by charles #+# #+# */ -/* Updated: 2020/09/11 19:11:20 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:31:53 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,14 @@ t_tok_lst *tok_lst_new(enum e_tok tag, char *content) return (tok_lst_new_until(tag, content, content == NULL ? 0 : ft_strlen(content))); } +/* +** \brief Create a new tok_lst +** \param tag tok_lst tag +** \param content tok_lst content +** \param n The maximum number of character to take from content +** \return An allocated tok_lst or NULL on error +*/ + t_tok_lst *tok_lst_new_until(enum e_tok tag, char *content, size_t n) { t_tok_lst *ret; diff --git a/src/lexer/trim.c b/src/lexer/trim.c index b343d69..d6eea5e 100644 --- a/src/lexer/trim.c +++ b/src/lexer/trim.c @@ -6,7 +6,7 @@ /* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/07/16 08:18:36 by nahaddac #+# #+# */ -/* Updated: 2020/09/13 18:14:59 by charles ### ########.fr */ +/* Updated: 2020/09/13 20:42:05 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,7 @@ void del_quote(char *str) i = 0; if (str[0] == '\'') + { while (str[i++] != '\0') { if (str[i] == '\\') @@ -44,7 +45,9 @@ void del_quote(char *str) if (str[i] == '\'') break ; } + } else if (str[0] == '"') + { while (str[i++] != '\0') { if (str[i] == '\\') @@ -52,6 +55,7 @@ void del_quote(char *str) if (str[i] == '"') break ; } + } str[i] = '\0'; ft_memmove(str, str + 1, ft_strlen(str + 1) + 1); } |
