From ba772aeb91f6023017b38dc47ef451db7a891469 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 27 Mar 2017 03:24:00 +0200 Subject: [PATCH] stuff --- libftasm/Makefile | 5 ++-- libftasm/includes/error.h | 3 +-- libftasm/includes/libft.h | 4 ++- libftasm/includes/lst.h | 7 ++++- libftasm/src/cliopts/cliopts_get.c | 4 +-- libftasm/src/error/error.c | 3 +-- libftasm/src/lst/ft_lst_delsub.c | 2 +- libftasm/src/lst/ft_lst_filter.c | 2 +- libftasm/src/lst/ft_lst_filterout.c | 36 ++++++++++++++++++++++++++ libftasm/src/lst/ft_lst_order_delsub.c | 2 +- libftasm/src/lst/ft_lst_removeif.c | 2 +- 11 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 libftasm/src/lst/ft_lst_filterout.c diff --git a/libftasm/Makefile b/libftasm/Makefile index fb38f8d4..1d70e37d 100644 --- a/libftasm/Makefile +++ b/libftasm/Makefile @@ -6,7 +6,7 @@ # By: jhalford +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# # -# Updated: 2017/03/08 01:11:01 by ariard ### ########.fr # +# Updated: 2017/03/26 15:35:32 by jhalford ### ########.fr # # # # **************************************************************************** # @@ -84,6 +84,7 @@ lst/ft_lst_cfree.c\ lst/ft_lst_delif.c\ lst/ft_lst_delsub.c\ lst/ft_lst_filter.c\ +lst/ft_lst_filterout.c\ lst/ft_lst_find.c\ lst/ft_lst_merge.c\ lst/ft_lst_order_delsub.c\ @@ -207,7 +208,7 @@ all: $(NAME): $(OBJ_DIR) $(OBJS) @$(AR) $(NAME) $(OBJS) @ranlib $(NAME) - @strip -x $(NAME) + @#strip -x $(NAME) @printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n" $(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR) diff --git a/libftasm/includes/error.h b/libftasm/includes/error.h index c564654b..5138dade 100644 --- a/libftasm/includes/error.h +++ b/libftasm/includes/error.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 15:34:21 by jhalford #+# #+# */ -/* Updated: 2017/03/16 14:19:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 15:35:02 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,7 +29,6 @@ enum e_errors E_NOERR, E_CO_INV, E_CO_INVL, - E_CO_MULT, E_CO_MISS, E_CO_MISSL, E_MAX, diff --git a/libftasm/includes/libft.h b/libftasm/includes/libft.h index 56cdf59b..aa81b9a9 100644 --- a/libftasm/includes/libft.h +++ b/libftasm/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/03/15 20:51:55 by ariard ### ########.fr */ +/* Updated: 2017/03/26 17:07:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,6 +39,8 @@ typedef struct s_stos t_stos; typedef struct s_stof t_stof; typedef struct s_itof t_itof; +typedef long long t_type; +typedef long long t_flag; struct s_stos { diff --git a/libftasm/includes/lst.h b/libftasm/includes/lst.h index 166cf985..b62bf152 100644 --- a/libftasm/includes/lst.h +++ b/libftasm/includes/lst.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */ -/* Updated: 2017/03/11 16:18:00 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 17:08:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,6 +75,11 @@ t_list *ft_lst_find( t_list *ft_lstpop(t_list **lst); void ft_lst_merge(t_list **begin_list1, t_list *begin_list2); void ft_lst_reverse(t_list **begin_list); +void ft_lst_filterout( + t_list **alst, + void *data_ref, + int (*cmp)(), + void (*del)(void *, size_t)); int ft_diff(void *a, void *b); t_list *ft_id(t_list *a); diff --git a/libftasm/src/cliopts/cliopts_get.c b/libftasm/src/cliopts/cliopts_get.c index 37094636..59e5c224 100644 --- a/libftasm/src/cliopts/cliopts_get.c +++ b/libftasm/src/cliopts/cliopts_get.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 20:04:04 by jhalford #+# #+# */ -/* Updated: 2017/03/26 15:27:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 16:37:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,7 +75,7 @@ static int cliopts_parse_long( if (map->get) { if (map->arg_required && !(tmp = check_required(av, NULL))) - return (ERR_SET(E_CO_MISS, *arg)); + return (ERR_SET(E_CO_MISSL, arg)); if ((map->get)(tmp, data)) return (ERR_SET(E_CO_MISSL, arg)); } diff --git a/libftasm/src/error/error.c b/libftasm/src/error/error.c index 2c82901b..7f80f91c 100644 --- a/libftasm/src/error/error.c +++ b/libftasm/src/error/error.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 16:47:00 by jhalford #+# #+# */ -/* Updated: 2017/03/15 20:45:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 16:36:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,6 @@ char g_error_msglist[E_MAX][ERRMSG_MAX_SIZE] = "no error", "invalid option -%c", "invalid option --%s", - "option '%c' awaits argument(s): please don't combine", "option '%c': missing argument", "option '%s': missing argument", }; diff --git a/libftasm/src/lst/ft_lst_delsub.c b/libftasm/src/lst/ft_lst_delsub.c index b3912fc2..441c70d3 100644 --- a/libftasm/src/lst/ft_lst_delsub.c +++ b/libftasm/src/lst/ft_lst_delsub.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:15 by jhalford #+# #+# */ -/* Updated: 2017/01/12 14:33:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 16:55:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lst_filter.c b/libftasm/src/lst/ft_lst_filter.c index f0004126..349cb2e4 100644 --- a/libftasm/src/lst/ft_lst_filter.c +++ b/libftasm/src/lst/ft_lst_filter.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:17 by jhalford #+# #+# */ -/* Updated: 2017/03/02 17:47:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 17:11:27 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lst_filterout.c b/libftasm/src/lst/ft_lst_filterout.c new file mode 100644 index 00000000..9a97c09d --- /dev/null +++ b/libftasm/src/lst/ft_lst_filterout.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lst_filterout.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/26 16:56:02 by jhalford #+# #+# */ +/* Updated: 2017/03/26 19:10:03 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +void ft_lst_filterout( + t_list **alst, + void *data_ref, + int (*cmp)(), + void (*del)(void *, size_t)) +{ + t_list *tmp; + t_list **indirect; + + indirect = alst; + while (*indirect) + { + if ((*cmp)((*indirect)->content, data_ref) == 0) + { + tmp = *indirect; + (*indirect) = (*indirect)->next; + ft_lstdelone(&tmp, del); + } + else + indirect = &(*indirect)->next; + } +} diff --git a/libftasm/src/lst/ft_lst_order_delsub.c b/libftasm/src/lst/ft_lst_order_delsub.c index 5bf2067c..de6b61ff 100644 --- a/libftasm/src/lst/ft_lst_order_delsub.c +++ b/libftasm/src/lst/ft_lst_order_delsub.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:25 by jhalford #+# #+# */ -/* Updated: 2016/11/04 12:01:47 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 16:55:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lst_removeif.c b/libftasm/src/lst/ft_lst_removeif.c index b82f57c2..78734f1c 100644 --- a/libftasm/src/lst/ft_lst_removeif.c +++ b/libftasm/src/lst/ft_lst_removeif.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:30 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:31:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 17:13:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */