diff --git a/42sh/Makefile b/42sh/Makefile index b39cae83..ed8d6f20 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,7 +6,7 @@ # 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 # # # # **************************************************************************** # diff --git a/42sh/includes/completion.h b/42sh/includes/completion.h index dcd66200..c2ac1d27 100644 --- a/42sh/includes/completion.h +++ b/42sh/includes/completion.h @@ -6,7 +6,7 @@ /* 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_add_escape(char *str, char to_escape); void c_lst_id(t_comp *c); +char *c_strdupi(char *s, int (*f)(char)); #endif diff --git a/42sh/includes/ft_readline.h b/42sh/includes/ft_readline.h index e4412ffc..f08d88b2 100644 --- a/42sh/includes/ft_readline.h +++ b/42sh/includes/ft_readline.h @@ -6,7 +6,7 @@ /* 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); void sigwinch_resize(int sig); 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_left(char **str, size_t *pos, size_t pos_ref); diff --git a/42sh/libft/includes/cliopts.h b/42sh/libft/includes/cliopts.h index 9ea82890..3d7f752d 100644 --- a/42sh/libft/includes/cliopts.h +++ b/42sh/libft/includes/cliopts.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* cliopts.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* 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 */ /* */ /* ************************************************************************** */ @@ -20,7 +20,7 @@ typedef struct s_cliopts t_cliopts; typedef struct s_data_template t_data_template; typedef long long t_flag; -struct s_cliopts +struct s_cliopts { char c; char *str; @@ -30,15 +30,18 @@ struct s_cliopts int arg_required:1; }; -struct s_data_template +struct s_data_template { t_flag flag; char **av_data; }; -int cliopts_get(char **av, t_cliopts opt_map[], void *data); -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_get(char **av, t_cliopts opt_map[], + void *data); +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); #endif diff --git a/42sh/libft/src/lst/ft_lst_delif.c b/42sh/libft/src/lst/ft_lst_delif.c index 7580ea7d..768272b5 100644 --- a/42sh/libft/src/lst/ft_lst_delif.c +++ b/42sh/libft/src/lst/ft_lst_delif.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_lst_delif.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* 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 */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index af086139..d0bb0d11 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ @@ -31,7 +31,7 @@ static t_cliopts g_cdopts[] = {0, NULL, 0, 0, NULL, 0}, }; -int cd_file_autorisations(char *target, int flag) +int cd_file_autorisations(char *target, int flag) { (void)flag; if (access(target, F_OK)) diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index 77fe9600..36adb113 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* 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); } -static char *c_strdupi(char *s, int (*f)(char)) +char *c_strdupi(char *s, int (*f)(char)) { int i; char *str; diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 752ed3f5..4d6b464d 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ @@ -29,7 +29,7 @@ static void c_mv_tab(t_comp *c, int next) ptr->next->cursor = 1; else ptr->prev->cursor = 1; - } +} /* ** Once the completion has been processed, this is the return point. diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index a2d57f1c..4f7ffb1d 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ @@ -22,8 +22,7 @@ int redirect_dgreat(t_redir *redir) if ((try_access(redir->word, 0, W_OK))) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0) - exit (1); - + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index 0e24b2c7..793028f7 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* redirect_less.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* 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 */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ int redirect_less(t_redir *redir) if ((try_access(redir->word, 1, R_OK)) != 0) return (ft_perror(NULL)); if ((fdold = open(redir->word, O_RDONLY, 0644)) < 0) - exit (1); + exit(1); fd_replace(fdold, fdnew); return (0); } diff --git a/42sh/src/history/history_parsing.c b/42sh/src/history/history_parsing.c index 2c7040f3..2f1535b1 100644 --- a/42sh/src/history/history_parsing.c +++ b/42sh/src/history/history_parsing.c @@ -6,7 +6,7 @@ /* 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] == '"') return (0); return (1); - } 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)); else if (str[*i + 1] && str[*i + 1] != ' ') 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 return (0); return (1); diff --git a/42sh/src/history/history_parsing_toolz.c b/42sh/src/history/history_parsing_toolz.c index 4c2f00b7..3c384222 100644 --- a/42sh/src/history/history_parsing_toolz.c +++ b/42sh/src/history/history_parsing_toolz.c @@ -6,12 +6,19 @@ /* 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" +int hist_is_delim(char c) +{ + if (c == ' ' || c == '"') + return (1); + return (0); +} + static char *ft_nget_histo(size_t nb_his) { t_list_history *list; diff --git a/42sh/src/line_editing/init_line/init_termcaps.c b/42sh/src/line_editing/init_line/init_termcaps.c index b8b2dbdb..475bf580 100644 --- a/42sh/src/line_editing/init_line/init_termcaps.c +++ b/42sh/src/line_editing/init_line/init_termcaps.c @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line_editing/readline.c b/42sh/src/line_editing/readline.c index 82856a6f..32788265 100644 --- a/42sh/src/line_editing/readline.c +++ b/42sh/src/line_editing/readline.c @@ -6,7 +6,7 @@ /* 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) ret = ft_history_parsing(has_prompt, input); ft_strdel(&data_singleton()->line.copy_tmp); + DG("ret = \"%s\"", *input); if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) return (-1); return (ret); diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 5397a51c..b6e7181e 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* 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 */ /* */ /* ************************************************************************** */