From 18a111051fbd9ba1864c3adfeed9a186a05a838f Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 10 Feb 2017 00:37:52 +0100 Subject: [PATCH] push and pop --- libftasm/Makefile | 5 +++-- libftasm/includes/libft.h | 20 ++++++++++---------- libftasm/includes/lst.h | 5 ++++- libftasm/src/lst/ft_lstadd.c | 2 +- libftasm/src/lst/ft_lstlast.c | 2 +- libftasm/src/lst/ft_lstnew.c | 2 +- libftasm/src/lst/{ft_lstpop.c => pop.c} | 6 +++--- libftasm/src/lst/push.c | 19 +++++++++++++++++++ libftasm/src/str/ft_strappend.c | 2 +- 9 files changed, 43 insertions(+), 20 deletions(-) rename libftasm/src/lst/{ft_lstpop.c => pop.c} (84%) create mode 100644 libftasm/src/lst/push.c diff --git a/libftasm/Makefile b/libftasm/Makefile index 9bd2ac72..809f204c 100644 --- a/libftasm/Makefile +++ b/libftasm/Makefile @@ -6,7 +6,7 @@ # By: jhalford +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# # -# Updated: 2017/02/07 20:11:46 by jhalford ### ########.fr # +# Updated: 2017/02/10 00:26:46 by jhalford ### ########.fr # # # # **************************************************************************** # @@ -98,8 +98,9 @@ lst/ft_lstmap.c\ lst/ft_lstnadd.c\ lst/ft_lstnew.c\ lst/ft_lstnew_range.c\ -lst/ft_lstpop.c\ lst/ft_lstsort.c\ +lst/pop.c\ +lst/push.c\ math/ft_addrcmp.c\ math/ft_ilen.c\ math/ft_ilen_base.c\ diff --git a/libftasm/includes/libft.h b/libftasm/includes/libft.h index 7688a510..bd8a14a7 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/02/07 16:12:40 by jhalford ### ########.fr */ +/* Updated: 2017/02/10 00:27:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,14 +22,6 @@ # define DG_MSG1 ft_path_notdir(__FILE__), __LINE__ # define DG(f, ...) ft_dprintf(STDBUG, DG_MSG0 f "{eoc}\n", DG_MSG1, ##__VA_ARGS__) -# include "get_next_line.h" -# include "ft_xattr.h" -# include "mytime.h" -# include "lst.h" -# include "dlst.h" -# include "btree.h" -# include "color.h" - # include # include # include @@ -38,13 +30,21 @@ # include # include +# include "lst.h" +# include "get_next_line.h" +# include "ft_xattr.h" +# include "mytime.h" +# include "dlst.h" +# include "btree.h" +# include "color.h" + # define FT_WS(x) (x == ' ' || x == '\t' || x == '\n') # define FT_ABS(x) (((x) < 0) ? -(x) : (x)) # define FT_NEG(x) ((x) < 0) # define FT_POS(x) ((x) > 0) # define FT_MIN(a, b) ((a) < (b) ? (a) : (b)) # define FT_MAX(a, b) ((a) > (b) ? (a) : (b)) -# define FT_DIST(a, b) (FT_ABS((a) - (b))) +# define FT_DIST(a, b) FT_ABS((a) - (b)) typedef struct s_stof t_stof; typedef struct s_stos t_stos; diff --git a/libftasm/includes/lst.h b/libftasm/includes/lst.h index ee4926df..f8ceb753 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: 2016/12/12 14:59:12 by jhalford ### ########.fr */ +/* Updated: 2017/02/10 00:32:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,9 @@ struct s_list typedef struct s_list t_list; +t_list *pop(t_list **lst); +t_list *push(t_list **stack, int elem); + t_list *ft_lstnew(void const *content, size_t content_size); void ft_lstdel(t_list **alst, void (*del)(void *, size_t)); void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); diff --git a/libftasm/src/lst/ft_lstadd.c b/libftasm/src/lst/ft_lstadd.c index f2064d9f..aec063b0 100644 --- a/libftasm/src/lst/ft_lstadd.c +++ b/libftasm/src/lst/ft_lstadd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:44 by jhalford ### ########.fr */ +/* Updated: 2017/02/09 21:50:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lstlast.c b/libftasm/src/lst/ft_lstlast.c index b8019f8f..addae8fc 100644 --- a/libftasm/src/lst/ft_lstlast.c +++ b/libftasm/src/lst/ft_lstlast.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:48 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:49 by jhalford ### ########.fr */ +/* Updated: 2017/02/09 20:46:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lstnew.c b/libftasm/src/lst/ft_lstnew.c index db921685..178ade1d 100644 --- a/libftasm/src/lst/ft_lstnew.c +++ b/libftasm/src/lst/ft_lstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2016/11/29 15:57:40 by jhalford ### ########.fr */ +/* Updated: 2017/02/09 21:37:14 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libftasm/src/lst/ft_lstpop.c b/libftasm/src/lst/pop.c similarity index 84% rename from libftasm/src/lst/ft_lstpop.c rename to libftasm/src/lst/pop.c index fd9df6c6..a78bb6fc 100644 --- a/libftasm/src/lst/ft_lstpop.c +++ b/libftasm/src/lst/pop.c @@ -1,18 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* ft_lstpop.c :+: :+: :+: */ +/* pop.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */ -/* Updated: 2016/11/29 13:46:21 by jhalford ### ########.fr */ +/* Updated: 2017/02/10 00:33:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -t_list *ft_lstpop(t_list **lst) +t_list *pop(t_list **lst) { t_list *top; diff --git a/libftasm/src/lst/push.c b/libftasm/src/lst/push.c new file mode 100644 index 00000000..e13ac8f1 --- /dev/null +++ b/libftasm/src/lst/push.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* push.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/02/09 15:59:39 by jhalford #+# #+# */ +/* Updated: 2017/02/10 00:28:45 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_list *push(t_list **stack, int elem) +{ + ft_lstadd(stack, ft_lstnew(&elem, sizeof(elem))); + return (*stack); +} diff --git a/libftasm/src/str/ft_strappend.c b/libftasm/src/str/ft_strappend.c index 222c95c9..3aab80d4 100644 --- a/libftasm/src/str/ft_strappend.c +++ b/libftasm/src/str/ft_strappend.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */ -/* Updated: 2017/01/22 17:46:19 by jhalford ### ########.fr */ +/* Updated: 2017/02/09 17:34:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */