"close #130"
This commit is contained in:
Antoine Riard 2017-03-21 19:38:56 +01:00
commit 00cba8ea4d
23 changed files with 44 additions and 41 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/21 16:32:26 by jhalford #+# #+# */
/* Updated: 2017/03/21 16:40:17 by jhalford ### ########.fr */
/* Updated: 2017/03/21 16:42:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:40:05 by wescande ### ########.fr */
/* Updated: 2017/03/21 17:40:31 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 13:37:49 by jhalford #+# #+# */
/* Updated: 2017/03/21 15:11:09 by gwojda ### ########.fr */
/* Updated: 2017/03/21 17:40:28 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/21 16:40:13 by jhalford ### ########.fr */
/* Updated: 2017/03/21 17:40:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
/* Updated: 2017/03/21 16:35:42 by jhalford ### ########.fr */
/* Updated: 2017/03/21 17:40:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/31 22:18:46 by wescande #+# #+# */
/* Updated: 2017/02/24 22:05:41 by ariard ### ########.fr */
/* Updated: 2017/03/21 18:13:25 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -66,7 +66,7 @@ unsigned char **ft_strsplit_esc(const char *str,
if ((pos = -1) && !str)
return (NULL);
if (!(s1 = (unsigned char **)malloc(sizeof(*s1) * (nb_c(str, esc, c) + 1))))
if (!(s1 = (unsigned char **)ft_malloc(sizeof(*s1) * (nb_c(str, esc, c) + 1))))
return (NULL);
i = 0;
fix = str;

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/31 20:49:30 by wescande #+# #+# */
/* Updated: 2017/02/24 22:03:22 by ariard ### ########.fr */
/* Updated: 2017/03/21 18:13:34 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -64,7 +64,7 @@ char **ft_strsplit_spe(const char *str,
int len;
if (!str || !(s1 =
(char**)malloc(sizeof(*s1) * (ft_nbstr_c(str, esc, c) + 1))))
(char**)ft_malloc(sizeof(*s1) * (ft_nbstr_c(str, esc, c) + 1))))
return (NULL);
i = 0;
fix = str;
@ -72,7 +72,7 @@ char **ft_strsplit_spe(const char *str,
++str;
while (*str && (len = ft_strlen_c(str, fix, esc, c)))
{
if (!(s1[i] = (char*)malloc(sizeof(**s1) * (len + 1))))
if (!(s1[i] = (char*)ft_malloc(sizeof(**s1) * (len + 1))))
return (NULL);
ft_strncpy(s1[i], str, len);
s1[i][len] = '\0';

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:04:40 by wescande #+# #+# */
/* Updated: 2017/03/07 21:14:55 by wescande ### ########.fr */
/* Updated: 2017/03/21 18:13:39 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ char **gen_tab(const char *pat,
char **my_tab;
int len;
if (!(my_tab = (char **)malloc(sizeof(char *) * (esc2 ? 4 : 3))))
if (!(my_tab = (char **)ft_malloc(sizeof(char *) * (esc2 ? 4 : 3))))
return (NULL);
if (dup)
{

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 18:17:34 by wescande #+# #+# */
/* Updated: 2017/03/07 21:17:20 by wescande ### ########.fr */
/* Updated: 2017/03/21 18:12:52 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,7 +16,7 @@ void ft_ld_new(t_ld **alst, void *content)
{
t_ld *new;
if ((new = (t_ld *)malloc(sizeof(t_ld))))
if ((new = (t_ld *)ft_malloc(sizeof(t_ld))))
{
new->content = content;
new->prev = NULL;

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 15:59:38 by wescande #+# #+# */
/* Updated: 2017/03/07 21:17:28 by wescande ### ########.fr */
/* Updated: 2017/03/21 18:12:58 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ void ft_ld_pushback(t_ld **alst, void *content)
if (!alst || !*alst)
return (ft_ld_new(alst, content));
if ((new = (t_ld *)malloc(sizeof(t_ld))))
if ((new = (t_ld *)ft_malloc(sizeof(t_ld))))
{
back = ft_ld_back(*alst);
new->prev = back;

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 18:32:40 by wescande #+# #+# */
/* Updated: 2017/03/07 21:15:42 by wescande ### ########.fr */
/* Updated: 2017/03/21 18:13:02 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ void ft_ld_pushfront(t_ld **alst, void *content)
if (!alst || !*alst)
return (ft_ld_new(alst, content));
if ((new = (t_ld *)malloc(sizeof(t_ld))))
if ((new = (t_ld *)ft_malloc(sizeof(t_ld))))
{
front = ft_ld_front(*alst);
new->next = front;

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:17:00 by wescande #+# #+# */
/* Updated: 2017/03/07 21:20:05 by wescande ### ########.fr */
/* Updated: 2017/03/21 18:13:08 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,7 @@ char **ft_ld_to_tab(t_ld *ld)
if (!ld)
return (NULL);
nb_item = ft_ld_size(ld);
if (!(my_tab = (char **)malloc(sizeof(char *) * (nb_item + 1))))
if (!(my_tab = (char **)ft_malloc(sizeof(char *) * (nb_item + 1))))
return (NULL);
index = 0;
while (ld)

View file

@ -6,19 +6,22 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 11:20:11 by gwojda #+# #+# */
/* Updated: 2017/03/19 16:40:25 by wescande ### ########.fr */
/* Updated: 2017/03/21 17:40:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#define BACKUP_PATH "/bin:/usr/bin"
char *ft_add_hash(char *cmd)
{
int id;
t_hash hash;
char *path;
if (!(hash.path = ft_findexec(ft_getenv(
data_singleton()->env, "PATH"), cmd)))
path = ft_getenv(data_singleton()->env, "PATH");
if (!(hash.path = ft_findexec(path ? path : BACKUP_PATH, cmd)))
return (NULL);
hash.key = ft_strdup(cmd);
id = ft_hash_str(cmd);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 11:06:19 by gwojda #+# #+# */
/* Updated: 2017/03/19 16:38:12 by wescande ### ########.fr */
/* Updated: 2017/03/21 17:40:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/18 11:08:40 by gwojda #+# #+# */
/* Updated: 2017/03/19 16:39:18 by wescande ### ########.fr */
/* Updated: 2017/03/21 17:40:20 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
/* Updated: 2017/03/21 13:37:25 by jhalford ### ########.fr */
/* Updated: 2017/03/21 18:12:27 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -33,7 +33,7 @@ t_list_history *ft_create_history_list(char *str)
{
t_list_history *list;
list = (t_list_history *)malloc(sizeof(t_list_history));
list = (t_list_history *)ft_malloc(sizeof(t_list_history));
if (!list)
return (NULL);
if (!str)

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* token_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 15:30:25 by jhalford #+# #+# */
/* Updated: 2017/03/16 19:07:52 by jhalford ### ########.fr */
/* Updated: 2017/03/21 18:11:43 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,7 +16,7 @@ t_token *token_init(void)
{
t_token *token;
if (!(token = (t_token *)malloc(sizeof(t_token))))
if (!(token = (t_token *)ft_malloc(sizeof(t_token))))
return (NULL);
token->type = 0;
token->size = 8;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
/* Updated: 2017/03/21 10:32:34 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:11:14 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ static char *ft_strdupi_space(char const *s)
++i;
if (s[i] == '\n')
++i;
if (!(str = (char *)malloc(sizeof(char) * (i + 1))))
if (!(str = (char *)ft_malloc(sizeof(char) * (i + 1))))
return (NULL);
if (str)
{

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:33:41 by gwojda #+# #+# */
/* Updated: 2017/03/07 17:36:38 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:11:13 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,7 +23,7 @@ struct termios *ft_save_termios(int save)
}
if (save > 0)
{
term_save = (struct termios *)malloc(sizeof(struct termios));
term_save = (struct termios *)ft_malloc(sizeof(struct termios));
tcgetattr(0, term_save);
}
return (term_save);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 17:06:30 by gwojda #+# #+# */
/* Updated: 2017/03/16 16:37:39 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:10:51 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,7 +30,7 @@ char *ft_strndup(char const *s, int n)
char *str;
i = 0;
if (!(str = (char *)malloc(sizeof(char) * (n + 1))))
if (!(str = (char *)ft_malloc(sizeof(char) * (n + 1))))
return (NULL);
if (str)
{

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/07 11:00:28 by gwojda #+# #+# */
/* Updated: 2017/03/07 17:32:44 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:10:50 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -62,7 +62,7 @@ char *ft_strdupi_w(char const *s)
i = 0;
while (s[i] && s[i] != ' ' && s[i] != '\t')
i++;
str = (char *)malloc(sizeof(char) * (i + 1));
str = (char *)ft_malloc(sizeof(char) * (i + 1));
if (str)
{
str[i--] = '\0';

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 10:56:08 by gwojda #+# #+# */
/* Updated: 2017/03/18 12:08:50 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:11:12 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:45:01 by gwojda ### ########.fr */
/* Updated: 2017/03/21 18:10:49 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,6 @@ t_data *data_singleton(void)
static t_data *data = NULL;
if (data == NULL)
data = malloc(sizeof(t_data));
data = ft_malloc(sizeof(t_data));
return (data);
}