🔨」 fix: fixed some things.

This commit is contained in:
2024-07-18 17:10:53 +02:00
parent 93eae87ea8
commit e5e127f71d
6 changed files with 79 additions and 27 deletions

53
readline.supp Normal file
View File

@ -0,0 +1,53 @@
{
readline
Memcheck:Leak
match-leak-kinds: reachable
...
fun:readline
...
}
{
readline-history
Memcheck:Leak
...
fun:xmalloc
fun:add_history
...
}
{
</bin/toe>
Memcheck:Leak
match-leak-kinds: reachable
...
obj:/usr/bin/toe
fun:(below main)
}
{
</bin/locale>
Memcheck:Leak
...
obj:/usr/bin/locale
fun:(below main)
}
{
</bin/clear>
Memcheck:Leak
match-leak-kinds: reachable
...
obj:/usr/bin/clear
fun:(below main)
}
{
</bin/cat>
Memcheck:Leak
...
obj:/usr/bin/cat
fun:(below main)
}
{
</bin/ls>
Memcheck:Leak
...
obj:/usr/bin/ls
fun:(below main)
}

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/24 11:18:04 by adjoly #+# #+# */
/* Updated: 2024/07/18 13:30:40 by adjoly ### ########.fr */
/* Updated: 2024/07/18 16:58:27 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -87,7 +87,7 @@ int main(int ac, char **av, char **env)
if (!env_l)
return (EXIT_FAILURE);
get_env(&env_l);
get_exit_code(727);
get_exit_code(0);
while (1)
{
rl = __rl(env_l);

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/30 12:52:22 by adjoly #+# #+# */
/* Updated: 2024/07/16 14:24:14 by adjoly ### ########.fr */
/* Updated: 2024/07/18 17:04:06 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,13 +42,3 @@ bool check_pipe(char *readline)
}
return (false);
}
bool check_space(char *rl)
{
while (*rl && *rl == ' ')
rl++;
if (!*rl)
return (send_error_parsing(ERROR_NO_FILE));
else
return (false);
}

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/18 13:30:27 by adjoly #+# #+# */
/* Updated: 2024/07/18 14:01:24 by mmoussou ### ########.fr */
/* Updated: 2024/07/18 17:03:08 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,8 +19,8 @@ bool run_checks(char *rl)
{
if (!*rl)
return (true);
if (check_space(rl))
return (true);
// if (check_space(rl))
//return (true);
add_history(rl);
if (check_syntax(rl))
return (true);

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/20 21:05:04 by adjoly #+# #+# */
/* Updated: 2024/07/18 14:08:29 by adjoly ### ########.fr */
/* Updated: 2024/07/18 17:00:51 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/02 14:42:00 by adjoly #+# #+# */
/* Updated: 2024/07/09 14:36:05 by adjoly ### ########.fr */
/* Updated: 2024/07/18 16:57:47 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,18 +14,10 @@
#include "libft.h"
#include "env.h"
char *get_pwd(t_env *env)
char *_format_pwd(char *pwd, char *home)
{
char *pwd;
char *home;
char *tmp;
pwd = env_get_value("PWD", env);
if (!pwd)
return (NULL);
home = env_get_value("HOME", env);
if (!home)
return (NULL);
if (!ft_strncmp(pwd, home, ft_strlen(home) - 1))
{
tmp = pwd;
@ -40,3 +32,20 @@ char *get_pwd(t_env *env)
free(home);
return (pwd);
}
char *get_pwd(t_env *env)
{
char *pwd;
char *home;
pwd = env_get_value("PWD", env);
if (!pwd)
return (NULL);
home = env_get_value("HOME", env);
if (!home)
{
free(pwd);
return (NULL);
}
return (_format_pwd(pwd, home));
}