diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-31 21:41:33 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-31 21:41:33 +0200 |
| commit | b15ab562d74b5111ac7c9bd6e0ec185435902472 (patch) | |
| tree | 664a55a24d7e36a5f56bf1ce7b0ea96751e0cda0 /src | |
| parent | 808d1499f5708ad4eda3612416e62efe6fdff021 (diff) | |
| download | minishell-b15ab562d74b5111ac7c9bd6e0ec185435902472.tar.gz minishell-b15ab562d74b5111ac7c9bd6e0ec185435902472.tar.bz2 minishell-b15ab562d74b5111ac7c9bd6e0ec185435902472.zip | |
Removing ms_ prefix, Removing junk
Diffstat (limited to 'src')
| -rw-r--r-- | src/builtin/cd.c | 2 | ||||
| -rw-r--r-- | src/builtin/echo.c | 2 | ||||
| -rw-r--r-- | src/builtin/env.c | 2 | ||||
| -rw-r--r-- | src/builtin/export.c | 2 | ||||
| -rw-r--r-- | src/builtin/pwd.c | 3 | ||||
| -rw-r--r-- | src/builtin/unset.c | 4 | ||||
| -rw-r--r-- | src/env.c | 6 | ||||
| -rw-r--r-- | src/eval/eval.c | 12 | ||||
| -rw-r--r-- | src/main.c | 18 | ||||
| -rw-r--r-- | src/parse/ast.c | 63 | ||||
| -rw-r--r-- | src/parse/lexer.c | 2 | ||||
| -rw-r--r-- | src/parse/parse.c | 6 | ||||
| -rw-r--r-- | src/path.c | 4 | ||||
| -rw-r--r-- | src/utils.c | 2 |
14 files changed, 33 insertions, 95 deletions
diff --git a/src/builtin/cd.c b/src/builtin/cd.c index fe806ec..14c38d2 100644 --- a/src/builtin/cd.c +++ b/src/builtin/cd.c @@ -5,7 +5,7 @@ #include "minishell.h" -int ms_cd(t_env env, char **argv) +int builtin_cd(t_env env, char **argv) { char *path; diff --git a/src/builtin/echo.c b/src/builtin/echo.c index 817da28..b9f2e28 100644 --- a/src/builtin/echo.c +++ b/src/builtin/echo.c @@ -5,7 +5,7 @@ #include "minishell.h" -int ms_echo(char **argv) +int builtin_echo(char **argv) { bool newline; diff --git a/src/builtin/env.c b/src/builtin/env.c index 4855917..3869ead 100644 --- a/src/builtin/env.c +++ b/src/builtin/env.c @@ -13,7 +13,7 @@ void st_print_env_variable(t_ftht_entry *entry) ft_putchar('\n'); } -int ms_env(t_env env) +int builtin_env(t_env env) { ft_htiter(env, st_print_env_variable); return (0); diff --git a/src/builtin/export.c b/src/builtin/export.c index 77d46c1..c0839b9 100644 --- a/src/builtin/export.c +++ b/src/builtin/export.c @@ -5,7 +5,7 @@ #include "minishell.h" -/* int ms_export(t_env env, char **argv) */ +/* int export(t_env env, char **argv) */ /* { */ /* return (0); */ /* } */ diff --git a/src/builtin/pwd.c b/src/builtin/pwd.c index 326f834..813c4c6 100644 --- a/src/builtin/pwd.c +++ b/src/builtin/pwd.c @@ -2,9 +2,10 @@ ** \file pwd.c ** \brief `pwd` builtin */ + #include "minishell.h" -int ms_pwd(void) +int builtin_pwd(void) { char buf[PATH_MAX]; diff --git a/src/builtin/unset.c b/src/builtin/unset.c index 4d7c628..64f25f4 100644 --- a/src/builtin/unset.c +++ b/src/builtin/unset.c @@ -5,10 +5,10 @@ #include "minishell.h" -int ms_unset(t_env env, char **argv) +int builtin_unset(t_env env, char **argv) { if (argv[1] == NULL) return (1); - ft_htdelone(env, argv[1], ms_ht_del_str_entry); + ft_htdelone(env, argv[1], ht_del_str_entry); return (0); } @@ -29,7 +29,7 @@ ** \return Environment hash table or NULL on error */ -t_env ms_env_from_array(char **envp) +t_env env_from_array(char **envp) { t_env env; int i; @@ -50,7 +50,7 @@ t_env ms_env_from_array(char **envp) return (NULL); if ((value = ft_strdup(value + 1)) == NULL) return (NULL); - if (ft_htset(env, key, value, ms_ht_del_str_entry) == NULL) + if (ft_htset(env, key, value, ht_del_str_entry) == NULL) return (NULL); free(key); } @@ -63,7 +63,7 @@ t_env ms_env_from_array(char **envp) ** \return Array of string on NULL on error */ -char **ms_env_to_array(t_env env) +char **env_to_array(t_env env) { (void)env; // need ft_htlen diff --git a/src/eval/eval.c b/src/eval/eval.c index a5e2c71..d40c7f3 100644 --- a/src/eval/eval.c +++ b/src/eval/eval.c @@ -3,19 +3,19 @@ ** \brief Evaluation of an AST */ -#include "ms_eval.h" +#include "eval.h" static int eval_line(t_eval_state *state, t_line *line) { int status; if (line->right == NULL) - return (ms_eval(state, line->left)); - status = ms_eval(state, line->left); + return (eval(state, line->left)); + status = eval(state, line->left); if ((line->sep == SEP_AND && status != 0) || (line->sep == SEP_OR && status == 0)) return (status); - return (ms_eval(state, line->right)); + return (eval(state, line->right)); } static char *search_exec_path(t_path path, char *path_var, char *exec_name) @@ -25,7 +25,7 @@ static char *search_exec_path(t_path path, char *path_var, char *exec_name) // try current first if ((exec_path = ft_htget(path, exec_name)) == NULL) { - if (ms_path_update(path, path_var) == NULL) + if (path_update(path, path_var) == NULL) return (NULL); if ((exec_path = ft_htget(path, exec_name)) == NULL) return (NULL); @@ -67,7 +67,7 @@ static int eval_cmd(t_eval_state *state, t_cmd *cmd) return (WEXITSTATUS(child_pid)); } -int ms_eval(t_eval_state *state, t_ast *ast) +int eval(t_eval_state *state, t_ast *ast) { if (ast->tag == TAG_LINE) return eval_line(state, &ast->data.line); @@ -34,23 +34,23 @@ int main(int argc, char **argv, const char **envp) (void)argc; (void)argv; - env = ms_env_from_array((char**)envp); - path = ms_path_update(NULL, ft_htget(env, "PATH")); + env = env_from_array((char**)envp); + path = path_update(NULL, ft_htget(env, "PATH")); printf("%s\n", (char*)ft_htget(path, "nmap")); - /* ms_env(env); */ - /* ms_pwd(&state); */ - /* ms_cd(&state, NULL); */ - /* ms_pwd(&state); */ + /* env(env); */ + /* pwd(&state); */ + /* cd(&state, NULL); */ + /* pwd(&state); */ /* while ((ret = ft_next_line(STDIN_FILENO, &line)) == 1) */ /* { */ - /* if (ms_eval(ms_parse(line)) == -1) */ + /* if (eval(parse(line)) == -1) */ /* continue ; // and display error */ /* free(line); */ /* } */ /* free(line); */ - ft_htdestroy(path, ms_ht_del_str_entry); - ft_htdestroy(env, ms_ht_del_str_entry); + ft_htdestroy(path, ht_del_str_entry); + ft_htdestroy(env, ht_del_str_entry); return (0); } diff --git a/src/parse/ast.c b/src/parse/ast.c deleted file mode 100644 index 44a36cd..0000000 --- a/src/parse/ast.c +++ /dev/null @@ -1,63 +0,0 @@ -/** -** \file ast.c -** \brief AST manipulation -*/ - -#include "ms_parse.h" - -/** -** \brief Create a new AST node with default values -** \param tag Tag of the node -** \return The allocated node -*/ - -/* t_ast *ms_ast_new(t_ast_tag tag) */ -/* { */ -/* t_ast *ast; */ -/* */ -/* if ((ast = (t_ast*)malloc(sizeof(t_ast))) == NULL) */ -/* return (NULL); */ -/* ast->tag = tag; */ -/* ast->content = NULL; */ -/* ast->children_num = 0; */ -/* ast->children = NULL; */ -/* return (ast); */ -/* } */ - -/** -** \brief Destroy an allocated AST -** \warning Assumes that `content`, `children` and the node itself have been malloc'd -** \param ast AST to destroy -*/ - -/* void ms_ast_destroy(t_ast *ast) */ -/* { */ -/* int i; */ -/* */ -/* if (ast == NULL) */ -/* return ; */ -/* i = -1; */ -/* while (++i < ast->children_num) */ -/* ms_ast_destroy(ast->children[i]); */ -/* free(ast->children); */ -/* free(ast->content); */ -/* free(ast); */ -/* } */ - -/** -** \brief Iterate over an AST node's childs -** \param f Function applied to each child, take `arg` has his first argument. -** \param arg Pointer that will be passed to `f`, to keep information between iterations -*/ - -/* void ms_ast_iter( */ -/* t_ast *ast, */ -/* void (*f)(void *f_arg, t_ast *children), */ -/* void *arg) */ -/* { */ -/* int i; */ -/* */ -/* i = -1; */ -/* while (++i < ast->children_num) */ -/* f(arg, ast->children[i]); */ -/* } */ diff --git a/src/parse/lexer.c b/src/parse/lexer.c index d8f1254..57ecdf7 100644 --- a/src/parse/lexer.c +++ b/src/parse/lexer.c @@ -5,7 +5,7 @@ #include "minishell.h" -char **ms_lexer(char *input) +char **lexer(char *input) { char **out_lex; diff --git a/src/parse/parse.c b/src/parse/parse.c index 41b82c2..c99f0fe 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -3,12 +3,12 @@ ** \brief Parser */ -#include "minishell.h" +#include "parse.h" -t_ast *ms_parse(char *input) +t_ast *parse(char *input) { /* char **out_lex; */ -/* if (!(out_lex = ms_lexer(input))) */ +/* if (!(out_lex = lexer(input))) */ /* return (NULL); */ (void)input; @@ -42,7 +42,7 @@ static t_path st_path_dir_update(t_path path, char *dirname) { if ((tmp = ft_strjoin3(dirname, "/", entry->d_name)) == NULL) return (NULL); - if (ft_htset(path, entry->d_name, tmp, ms_ht_del_str_entry) == NULL) + if (ft_htset(path, entry->d_name, tmp, ht_del_str_entry) == NULL) return (NULL); } if (closedir(dir) == -1) @@ -57,7 +57,7 @@ static t_path st_path_dir_update(t_path path, char *dirname) ** \return The updated/created path hash table or NULL on error */ -t_path ms_path_update(t_path path, char *path_var) +t_path path_update(t_path path, char *path_var) { int i; char **dirs; diff --git a/src/utils.c b/src/utils.c index 815e8e3..5989d71 100644 --- a/src/utils.c +++ b/src/utils.c @@ -23,7 +23,7 @@ ** */ -void ms_ht_del_str_entry(t_ftht_entry *entry) +void ht_del_str_entry(t_ftht_entry *entry) { if (entry == NULL) return ; |
