Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicknamemohaji committed Apr 9, 2024
1 parent e15d491 commit 2c0dd2e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
16 changes: 8 additions & 8 deletions codes/builtins/builtin_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: kyungjle <kyungjle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/27 06:04:49 by nicknamemoh #+# #+# */
/* Updated: 2024/04/09 15:07:35 by kyungjle ### ########.fr */
/* Updated: 2024/04/09 21:04:40 by kyungjle ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -49,19 +49,19 @@ t_bool builtin_isbuiltin(char *name)
*/
t_bool builtin_isbuiltin(char *name)
{
if (ft_strncmp(name, "cd", 2) == 0)
if (ft_strlen(name) == 2 && ft_strncmp(name, "cd", 2) == 0)
return (TRUE);
else if (ft_strncmp(name, "pwd", 3) == 0)
else if (ft_strlen(name) == 3 && ft_strncmp(name, "pwd", 3) == 0)
return (TRUE);
else if (ft_strncmp(name, "echo", 4) == 0)
else if (ft_strlen(name) == 4 && ft_strncmp(name, "echo", 4) == 0)
return (TRUE);
else if (ft_strncmp(name, "exit", 4) == 0)
else if (ft_strlen(name) == 5 && ft_strncmp(name, "exit", 4) == 0)
return (TRUE);
else if (ft_strncmp(name, "export", 6) == 0)
else if (ft_strlen(name) == 6 && ft_strncmp(name, "export", 6) == 0)
return (TRUE);
else if (ft_strncmp(name, "unset", 5) == 0)
else if (ft_strlen(name) == 5 && ft_strncmp(name, "unset", 5) == 0)
return (TRUE);
else if (ft_strncmp(name, "env", 3) == 0)
else if (ft_strlen(name) == 3 && ft_strncmp(name, "env", 3) == 0)
return (TRUE);
return (FALSE);
}
4 changes: 3 additions & 1 deletion codes/loader/ldexec_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: kyungjle <kyungjle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/14 01:11:55 by nicknamemoh #+# #+# */
/* Updated: 2024/04/09 17:46:44 by kyungjle ### ########.fr */
/* Updated: 2024/04/09 21:13:03 by kyungjle ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -37,6 +37,8 @@ pid_t ldexec_run_bin(t_ld_exec exec, pid_t pid)
signal(SIGQUIT, SIG_DFL);
if (errno != 0)
do_exit("ldexec_run_bin.signal");
if (exec.argv[0][0] == '\0')
exit(EXIT_SUCCESS);
if (execve(exec.path, exec.argv, exec.envp) < 0)
do_exit("ldexec_run_bin.execve");
}
Expand Down
4 changes: 2 additions & 2 deletions codes/loader/ldpre_ast_redir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* ldpre_ast_redir2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nicknamemohaji <nicknamemohaji@student. +#+ +:+ +#+ */
/* By: kyungjle <kyungjle@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/04 18:41:08 by kyungjle #+# #+# */
/* Updated: 2024/04/09 20:53:03 by nicknamemoh ### ########.fr */
/* Updated: 2024/04/09 21:01:10 by kyungjle ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
19 changes: 8 additions & 11 deletions codes/utils/ld_map_functions2.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,27 @@ char *ldpre_env_fetch(char *key, t_ld_map_env *map)
void ldpre_env_add(char *key, char *value, t_ld_map_env *map)
{
t_ld_map_node *node;
char *key_copy;
char *value_copy;

if (!ldpre_env_validate_key(key))
{
printf("syntax error: [%s]\n", key);
printf("export: syntax error: [%s]\n", key);
free(key);
free(value);
return ;
}
ldpre_env_remove(key, map);
node = malloc(sizeof(t_ld_map_node) * 1);
if (node == NULL)
do_exit("ldpre_env_add.malloc");
key_copy = ft_strdup(key);
value_copy = ft_strdup(value);
if (key_copy == NULL || value_copy == NULL)
do_exit("ldpre_env_add.ft_strdup");
node->key = ft_strdup(key);
node->value = ft_strdup(value);
free(key);
free(value);
node->key = key_copy;
node->value = value_copy;
node->next = NULL;
if (node->key == NULL || node->value == NULL)
do_exit("ldpre_env_add.ft_strdup");
ld_map_node_attach(map, node);
map->count++;
return ;
map->count += 1;
}

t_bool ldpre_env_remove(char *key, t_ld_map_env *map)
Expand Down

0 comments on commit 2c0dd2e

Please sign in to comment.