This commit is contained in:
gwojda 2017-03-27 18:01:25 +02:00
parent de1479f2a1
commit ef381ddaae
15 changed files with 43 additions and 32 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/27 16:09:37 by jhalford ### ########.fr # # Updated: 2017/03/27 17:02:38 by gwojda ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/18 11:13:04 by alao #+# #+# */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */
/* Updated: 2017/03/27 09:30:01 by alao ### ########.fr */ /* Updated: 2017/03/27 17:42:17 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -189,5 +189,6 @@ int ft_sstrlen(char **s);
char *ft_sstrtostr(char **s, char *sep); char *ft_sstrtostr(char **s, char *sep);
char *ft_add_escape(char *str, char to_escape); char *ft_add_escape(char *str, char to_escape);
void c_lst_id(t_comp *c); void c_lst_id(t_comp *c);
char *c_strdupi(char *s, int (*f)(char));
#endif #endif

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
/* Updated: 2017/03/23 16:16:57 by gwojda ### ########.fr */ /* Updated: 2017/03/27 18:00:07 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -134,6 +134,7 @@ int ft_nb_of_line(char *str, size_t pos);
int ft_get_size_prev(char *str, size_t pos); int ft_get_size_prev(char *str, size_t pos);
void sigwinch_resize(int sig); void sigwinch_resize(int sig);
size_t ft_hist_len(void); size_t ft_hist_len(void);
int hist_is_delim(char c);
int underline_right(char **str, size_t *pos, size_t pos_ref); int underline_right(char **str, size_t *pos, size_t pos_ref);
int underline_left(char **str, size_t *pos, size_t pos_ref); int underline_left(char **str, size_t *pos, size_t pos_ref);

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* cliopts.h :+: :+: :+: */ /* cliopts.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */ /* Created: 2017/03/14 20:22:56 by jhalford #+# #+# */
/* Updated: 2017/03/25 14:59:53 by jhalford ### ########.fr */ /* Updated: 2017/03/27 17:17:05 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -36,9 +36,12 @@ struct s_data_template
char **av_data; char **av_data;
}; };
int cliopts_get(char **av, t_cliopts opt_map[], void *data); int cliopts_get(char **av, t_cliopts opt_map[],
t_cliopts *cliopts_getmap_long(t_cliopts opt_map[], char *arg); void *data);
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[], char arg); t_cliopts *cliopts_getmap_long(t_cliopts opt_map[],
char *arg);
t_cliopts *cliopts_getmap_short(t_cliopts opt_map[],
char arg);
int cliopts_has(char **av, char c); int cliopts_has(char **av, char c);
#endif #endif

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* ft_lst_delif.c :+: :+: :+: */ /* ft_lst_delif.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */ /* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
/* Updated: 2017/03/13 15:36:19 by jhalford ### ########.fr */ /* Updated: 2017/03/27 17:45:01 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 18:20:42 by ariard #+# #+# */ /* Created: 2017/03/25 18:20:42 by ariard #+# #+# */
/* Updated: 2017/03/25 21:23:11 by ariard ### ########.fr */ /* Updated: 2017/03/27 17:11:36 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */
/* Updated: 2017/03/23 19:02:28 by gwojda ### ########.fr */ /* Updated: 2017/03/27 17:48:25 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,7 @@ static int c_is_delim(char c)
return (0); return (0);
} }
static char *c_strdupi(char *s, int (*f)(char)) char *c_strdupi(char *s, int (*f)(char))
{ {
int i; int i;
char *str; char *str;

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */ /* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */
/* Updated: 2017/03/27 09:30:40 by alao ### ########.fr */ /* Updated: 2017/03/27 17:11:59 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */ /* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
/* Updated: 2017/03/26 22:36:18 by jhalford ### ########.fr */ /* Updated: 2017/03/27 17:09:31 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,7 +23,6 @@ int redirect_dgreat(t_redir *redir)
return (ft_perror(NULL)); return (ft_perror(NULL));
if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
exit(1); exit(1);
fd_replace(fdold, fdnew); fd_replace(fdold, fdnew);
return (0); return (0);
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* redirect_less.c :+: :+: :+: */ /* redirect_less.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */ /* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
/* Updated: 2017/03/27 01:02:30 by jhalford ### ########.fr */ /* Updated: 2017/03/27 17:12:24 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */ /* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
/* Updated: 2017/03/22 12:09:59 by gwojda ### ########.fr */ /* Updated: 2017/03/27 18:00:27 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -41,7 +41,6 @@ static int check_validity(char *str, int i)
else if (!str[i + 1] || str[i + 1] == '"') else if (!str[i + 1] || str[i + 1] == '"')
return (0); return (0);
return (1); return (1);
} }
static int history_parsing_nb_and_name(char *str, int *i) static int history_parsing_nb_and_name(char *str, int *i)
@ -66,7 +65,7 @@ static int history_parsing_nb_and_name(char *str, int *i)
ft_strdupi_w(str + *i + 2)); ft_strdupi_w(str + *i + 2));
else if (str[*i + 1] && str[*i + 1] != ' ') else if (str[*i + 1] && str[*i + 1] != ' ')
ft_realloc_str_history_2(&(data_singleton()->line.input), *i, ft_realloc_str_history_2(&(data_singleton()->line.input), *i,
ft_strdupi_w(str + *i + 1)); c_strdupi(str + *i + 1, hist_is_delim));
else else
return (0); return (0);
return (1); return (1);

View file

@ -6,12 +6,19 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 14:09:39 by gwojda #+# #+# */ /* Created: 2017/01/25 14:09:39 by gwojda #+# #+# */
/* Updated: 2017/03/16 11:58:10 by gwojda ### ########.fr */ /* Updated: 2017/03/27 17:59:50 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
int hist_is_delim(char c)
{
if (c == ' ' || c == '"')
return (1);
return (0);
}
static char *ft_nget_histo(size_t nb_his) static char *ft_nget_histo(size_t nb_his)
{ {
t_list_history *list; t_list_history *list;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:33:41 by gwojda #+# #+# */ /* Created: 2017/03/07 17:33:41 by gwojda #+# #+# */
/* Updated: 2017/03/21 18:11:13 by gwojda ### ########.fr */ /* Updated: 2017/03/27 17:37:40 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/25 18:17:57 by ariard ### ########.fr */ /* Updated: 2017/03/27 17:38:51 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -35,6 +35,7 @@ int readline(int has_prompt, char **input)
if (has_prompt) if (has_prompt)
ret = ft_history_parsing(has_prompt, input); ret = ft_history_parsing(has_prompt, input);
ft_strdel(&data_singleton()->line.copy_tmp); ft_strdel(&data_singleton()->line.copy_tmp);
DG("ret = \"%s\"", *input);
if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1)
return (-1); return (-1);
return (ret); return (ret);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/27 16:04:45 by jhalford ### ########.fr */ /* Updated: 2017/03/27 17:13:41 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */