diff --git a/libft/includes/dlst.h b/libft/includes/dlst.h index 58c1e569..ffcf518f 100644 --- a/libft/includes/dlst.h +++ b/libft/includes/dlst.h @@ -1,10 +1,27 @@ -typedef struct s_dlist +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* dlst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:21:04 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:21:52 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef DLST_H +# define DLST_H + +struct s_dlist { void *content; size_t content_size; struct s_dlist *next; struct s_dlist *prev; -} t_dlist; +}; + +typedef struct s_dlist t_dlist; void ft_dlst_add_after(t_dlist **alst, t_dlist *new); void ft_dlst_add_before(t_dlist **alst, t_dlist *new); @@ -13,3 +30,5 @@ int ft_dlst_size(t_dlist *list); t_dlist *ft_dlst_new(void const *content, size_t content_size); t_dlist *ft_dlst_last(t_dlist *list); char *ft_dlsttostr(t_dlist *list); + +#endif diff --git a/libft/includes/ftprintf.h b/libft/includes/ft_printf.h similarity index 64% rename from libft/includes/ftprintf.h rename to libft/includes/ft_printf.h index c89282c1..396ef088 100644 --- a/libft/includes/ftprintf.h +++ b/libft/includes/ft_printf.h @@ -1,5 +1,17 @@ -#ifndef LIBFTPRINTF_H -# define LIBFTPRINTF_H +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ftprintf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:22:54 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:26:50 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_PRINTF_H +# define FT_PRINTF_H # include "libft.h" # include # define ALL_FLAGS "#0- +" diff --git a/libft/includes/ft_xattr.h b/libft/includes/ft_xattr.h new file mode 100644 index 00000000..9afadc18 --- /dev/null +++ b/libft/includes/ft_xattr.h @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ftxattr.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:24:05 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:24:05 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_XATTR_H +# define FT_XATTR_H +# define FT_XATTR_SIZE 10000 +# include +# include + +int ft_xattr_print(char *path); +int ft_xattr_count(char *path); +#endif diff --git a/libft/includes/ftxattr.h b/libft/includes/ftxattr.h deleted file mode 100644 index ff945002..00000000 --- a/libft/includes/ftxattr.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef FTXATTR_H -# define FTXATTR_H -# define FT_XATTR_SIZE 10000 -# include -# include - -int ft_xattr_print(char *path); -int ft_xattr_count(char *path); -#endif diff --git a/libft/includes/get_next_line.h b/libft/includes/get_next_line.h new file mode 100644 index 00000000..9163a6e5 --- /dev/null +++ b/libft/includes/get_next_line.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* getnextline.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:21:59 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:22:13 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef GET_NEXT_LINE_H +# define GET_NEXT_LINE_H +# define BUFF_SIZE 10 +# include "libft.h" + +int get_next_line(int const fd, char **line); + +#endif diff --git a/libft/includes/getnextline.h b/libft/includes/getnextline.h deleted file mode 100644 index 254ff862..00000000 --- a/libft/includes/getnextline.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef GET_NEXT_LINE_H -# define GET_NEXT_LINE_H - -# include "libft.h" -# define BUFF_SIZE 10 - -int get_next_line(int const fd, char **line); - -#endif diff --git a/libft/includes/libft.h b/libft/includes/libft.h index ccbb5412..b4d845e1 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -1,7 +1,19 @@ -#ifndef LIBFT_H -#define LIBFT_H +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:55:26 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ -# include "ftxattr.h" +#ifndef LIBFT_H +# define LIBFT_H + +# include "ft_xattr.h" # include "lst.h" # include "dlst.h" @@ -80,7 +92,8 @@ char **ft_strsplit(char const *s, char c); char *ft_str3join(char const *s1, char const *s2, char const *s3); char *ft_strcut(char *str, char *cut); char **ft_split_whitespaces(char *str); -char *ft_convert_base(char *str, char *base_from, char *base_to, char *flags); +char *ft_convert_base( + char *str, char *base_from, char *base_to, char *flags); char *ft_itoa_base(int nbr, char *base, char *flags); char *ft_lltoa_base(long long nbr, char *base, char *flags); @@ -88,6 +101,7 @@ char *ft_ulltoa_base(unsigned long long nbr, char *base); char *ft_uitoa_base(unsigned int nbr, char *base); size_t ft_ilen(int n); size_t ft_uilen(unsigned int n); +size_t ft_lllen(long long n); void ft_sstrsort(char **list, int size, int (*cmp)()); void ft_sstrprint(char **list, char sep); diff --git a/libft/includes/lst.h b/libft/includes/lst.h index fdec98d4..241962dd 100644 --- a/libft/includes/lst.h +++ b/libft/includes/lst.h @@ -1,12 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lst.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:31:28 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef LST_H # define LST_H -typedef struct s_list +struct s_list { void *content; size_t content_size; struct s_list *next; -} t_list; +}; + +typedef struct s_list t_list; t_list *ft_lstnew(void const *content, size_t content_size); void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); @@ -14,22 +28,43 @@ void ft_lstadd(t_list **alst, t_list *new); void ft_lstiter(t_list *lst, void (*f)(t_list *elem)); t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem)); +t_list *ft_lstnew_range(int a, int b); +void ft_lsteadd(t_list **alst, t_list *new); +void ft_lstnadd(t_list **alst, t_list *new, int n); void ft_lst_sort(t_list **begin_list, int (*cmp)()); void ft_lst_print(t_list *list, void (*printer)()); int ft_lstsize(t_list *lst); -void ft_lsteadd(t_list **alst, t_list *new); -void ft_lstnadd(t_list **alst, t_list *new, int n); t_list *ft_lstlast(t_list *lst); -void ft_lst_sorted_merge(t_list **begin_list1, t_list *begin_list2, int (*cmp)()); -void ft_lst_sorted_insert(t_list **begin_list, t_list *insert, int (*cmp)()); -t_list *ft_lstnew_range(int a, int b); -void ft_lst_delif(t_list **alist, void *data_ref, int (*cmp)(), void (*del)(void *, size_t)); -void ft_lst_delsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t)); +void ft_lst_sorted_merge( + t_list **begin_list1, + t_list *begin_list2, + int (*cmp)()); +void ft_lst_sorted_insert( + t_list **begin_list, + t_list *insert, + int (*cmp)()); +void ft_lst_delif( + t_list **alist, + void *data_ref, + int (*cmp)(), + void (*del)(void *, size_t)); +void ft_lst_delsub( + t_list **alst, + t_list *sub, int (*cmp)(), + void (*del)(void *, size_t)); void ft_lst_cfree(void *ptr, size_t size); - -t_list *ft_lst_filter(t_list *lst, void const *data_ref, t_list *(*f)(t_list *elem, void const *)); -t_list *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)()); -t_list *ft_lst_find(t_list *begin_list, void *data_ref, int (*cmp)()); +t_list *ft_lst_filter( + t_list *lst, + void const *data_ref, + t_list *(*f)(t_list *elem, void const *)); +t_list *ft_lst_removeif( + t_list **alst, + void *data_ref, + int (*cmp)()); +t_list *ft_lst_find( + t_list *begin_list, + void *data_ref, + int (*cmp)()); 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); diff --git a/libft/src/dlst/ft_dlst_add_after.c b/libft/src/dlst/ft_dlst_add_after.c index 90b96499..c1fa36eb 100644 --- a/libft/src/dlst/ft_dlst_add_after.c +++ b/libft/src/dlst/ft_dlst_add_after.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_add_after.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:04 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:36 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" void ft_dlst_add_after(t_dlist **alst, t_dlist *new) diff --git a/libft/src/dlst/ft_dlst_add_before.c b/libft/src/dlst/ft_dlst_add_before.c index e0c145a4..5025986c 100644 --- a/libft/src/dlst/ft_dlst_add_before.c +++ b/libft/src/dlst/ft_dlst_add_before.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_add_before.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:09 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:10 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" void ft_dlst_add_before(t_dlist **alst, t_dlist *new) diff --git a/libft/src/dlst/ft_dlst_delone.c b/libft/src/dlst/ft_dlst_delone.c index eb4cd604..ff83b296 100644 --- a/libft/src/dlst/ft_dlst_delone.c +++ b/libft/src/dlst/ft_dlst_delone.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_delone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:13 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:13 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" void ft_dlst_delone(t_dlist **alst, void (*del)(void *, size_t)) diff --git a/libft/src/dlst/ft_dlst_last.c b/libft/src/dlst/ft_dlst_last.c index b536596e..9772cc0c 100644 --- a/libft/src/dlst/ft_dlst_last.c +++ b/libft/src/dlst/ft_dlst_last.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_last.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:15 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:15 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" t_dlist *ft_dlst_last(t_dlist *list) diff --git a/libft/src/dlst/ft_dlst_new.c b/libft/src/dlst/ft_dlst_new.c index a7c5143b..8725382f 100644 --- a/libft/src/dlst/ft_dlst_new.c +++ b/libft/src/dlst/ft_dlst_new.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_new.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:20 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:20 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" t_dlist *ft_dlst_new(void const *content, size_t content_size) diff --git a/libft/src/dlst/ft_dlst_size.c b/libft/src/dlst/ft_dlst_size.c index 1ed16481..9777bb11 100644 --- a/libft/src/dlst/ft_dlst_size.c +++ b/libft/src/dlst/ft_dlst_size.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlst_size.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:23 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:27:23 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" int ft_dlst_size(t_dlist *list) diff --git a/libft/src/dlst/ft_dlstrtostr.c b/libft/src/dlst/ft_dlstrtostr.c index a2b7ba74..be96ba71 100644 --- a/libft/src/dlst/ft_dlstrtostr.c +++ b/libft/src/dlst/ft_dlstrtostr.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_dlstrtostr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:27:29 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:31:08 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" char *ft_dlsttostr(t_dlist *list) @@ -9,12 +21,10 @@ char *ft_dlsttostr(t_dlist *list) while (list->prev) list = list->prev; str = (char *)ft_strnew(sizeof(char) * (ft_dlst_size(list) + 2)); - /* list = ft_dlst_last(list); */ while (list) { ft_strcat(str, (char *)list->content); list = list->next; } - /* str = ft_strrev(str); */ return (str); } diff --git a/libft/src/ft_printf/ft_conversion.c b/libft/src/ft_printf/ft_conversion.c index cc841b0d..5b65518b 100644 --- a/libft/src/ft_printf/ft_conversion.c +++ b/libft/src/ft_printf/ft_conversion.c @@ -1,10 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_conversion.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:48:59 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" char *ft_signed_conversion(t_fmt *fmt, va_list ap) { - char base10[] = "0123456789"; - long long arg = va_arg(ap, int); + char base10[10]; + long long arg; + arg = va_arg(ap, int); + ft_strcpy(base10, "0123456789"); (void)fmt; return (ft_lltoa_base(arg, base10, fmt->flags)); } @@ -36,8 +50,6 @@ char *ft_char_conversion(t_fmt *fmt, va_list ap) (void)fmt; ret = (char *)malloc(sizeof(char) + 1); - /* if (ft_strcmp(fmt->modifier, "l") == 0) */ - /* va_arg(ap, wint_t); */ ret[0] = (char)va_arg(ap, int); ret[1] = '\0'; return (ret); @@ -48,8 +60,6 @@ char *ft_str_conversion(t_fmt *fmt, va_list ap) char *ret; (void)fmt; - /* if (ft_strcmp(fmt->modifier, "l") == 0) */ - /* va_arg(ap, wchar_t *); */ ret = ft_strdup(va_arg(ap, char *)); if (fmt->precision && fmt->precision < (int)ft_strlen(ret)) ret[fmt->precision] = '\0'; diff --git a/libft/src/ft_printf/ft_parse.c b/libft/src/ft_printf/ft_parse.c index f91c1f6d..fa03a90e 100644 --- a/libft/src/ft_printf/ft_parse.c +++ b/libft/src/ft_printf/ft_parse.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_parse.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:24 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:52:02 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" t_fmt *ft_printf_parse(char **format, va_list ap) @@ -88,7 +100,6 @@ void ft_printf_parse_precision(t_fmt *fmt, char **format, va_list ap) *format += i; } - void ft_printf_parse_modifiers(t_fmt *fmt, char **format) { char *str; diff --git a/libft/src/ft_printf/ft_printf.c b/libft/src/ft_printf/ft_printf.c index 927b37a9..e8dc16b7 100644 --- a/libft/src/ft_printf/ft_printf.c +++ b/libft/src/ft_printf/ft_printf.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:33:59 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" t_conv g_convs[] = diff --git a/libft/src/ft_printf/ft_transform.c b/libft/src/ft_printf/ft_transform.c index e92172b2..9716c3ce 100644 --- a/libft/src/ft_printf/ft_transform.c +++ b/libft/src/ft_printf/ft_transform.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_transform.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:33:32 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" char *ft_transform(t_fmt *fmt, va_list ap) diff --git a/libft/src/ft_printf/lib_fmt.c b/libft/src/ft_printf/lib_fmt.c index 7ab5e073..f0d25bbb 100644 --- a/libft/src/ft_printf/lib_fmt.c +++ b/libft/src/ft_printf/lib_fmt.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib_fmt.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:33:35 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" t_fmt *ft_fmt_init(void) diff --git a/libft/src/ft_printf/lib_fmt_error.c b/libft/src/ft_printf/lib_fmt_error.c index 1d5415f8..5f1f2bfc 100644 --- a/libft/src/ft_printf/lib_fmt_error.c +++ b/libft/src/ft_printf/lib_fmt_error.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib_fmt_error.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:38 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:33:39 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" void ft_fmt_error_conv(char conv) diff --git a/libft/src/ft_printf/lib_fmt_validate.c b/libft/src/ft_printf/lib_fmt_validate.c index 71438734..89bc9090 100644 --- a/libft/src/ft_printf/lib_fmt_validate.c +++ b/libft/src/ft_printf/lib_fmt_validate.c @@ -1,4 +1,16 @@ -#include "ftprintf.h" +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib_fmt_validate.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:43 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:51:29 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" void ft_fmt_simplify(t_fmt *fmt) { @@ -17,6 +29,7 @@ void ft_fmt_simplify(t_fmt *fmt) ft_strcpy(fmt->modifier, "l"); } } + int ft_fmt_validate_conversion(t_fmt *fmt) { if (!ft_strchr(ALL_CONVERSIONS, fmt->conversion)) diff --git a/libft/src/ft_printf/lib_pad.c b/libft/src/ft_printf/lib_pad.c index 057ad42c..6d7501dc 100644 --- a/libft/src/ft_printf/lib_pad.c +++ b/libft/src/ft_printf/lib_pad.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib_pad.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:48:19 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" void ft_pad_right(char *str, t_fmt *fmt) diff --git a/libft/src/ft_printf/lib_pad_sharp.c b/libft/src/ft_printf/lib_pad_sharp.c index 32268b5c..a887aeba 100644 --- a/libft/src/ft_printf/lib_pad_sharp.c +++ b/libft/src/ft_printf/lib_pad_sharp.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lib_pad_sharp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:33:49 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ftprintf.h" void ft_pad_sharp_o(char *str, t_fmt *fmt) diff --git a/libft/src/math/ft_ilen.c b/libft/src/math/ft_ilen.c index cd80062b..c1bc8050 100644 --- a/libft/src/math/ft_ilen.c +++ b/libft/src/math/ft_ilen.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ilen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:53:53 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:54:28 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" size_t ft_ilen(int n) diff --git a/libft/src/math/ft_itoa_base.c b/libft/src/math/ft_itoa_base.c index e99f887f..9a0eb9ab 100644 --- a/libft/src/math/ft_itoa_base.c +++ b/libft/src/math/ft_itoa_base.c @@ -1,16 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:52:51 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:57:06 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -static size_t ft_size(int n, int base) +static char *ft_flags(char *str, int *i, char *flags, int neg) { - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); + if (neg) + str[*i++] = '-'; + else if (ft_strchr(flags, '+')) + str[*i++] = '+'; + else if (ft_strchr(flags, ' ')) + str[*i++] = ' '; + return (str); } -char *ft_itoa_base(int nbr, char *base, char *flags) +char *ft_itoa_base(int nbr, char *base, char *flags) { int i; int neg; @@ -19,10 +32,8 @@ char *ft_itoa_base(int nbr, char *base, char *flags) i = 0; base_size = ft_strlen(base); - str = ft_strnew(ft_size(nbr, base_size) + 1); - neg = 0; - if (nbr < 0) - neg = 1; + str = ft_strnew(ft_ilen(nbr, base_size) + 1); + neg = FT_NEG(nbr); if (nbr == 0) { str[i++] = '0'; @@ -34,12 +45,7 @@ char *ft_itoa_base(int nbr, char *base, char *flags) str[i++] = base[FT_ABS(nbr % base_size)]; nbr = nbr / base_size; } - if (neg) - str[i++] = '-'; - else if (ft_strchr(flags, '+')) - str[i++] = '+'; - else if (ft_strchr(flags, ' ')) - str[i++] = ' '; + str = ft_flags(str, &i, flags, neg); str[i] = '\0'; return (ft_strrev(str)); } diff --git a/libft/src/math/ft_lllen.c b/libft/src/math/ft_lllen.c new file mode 100644 index 00000000..1d0abb37 --- /dev/null +++ b/libft/src/math/ft_lllen.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lllen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:55:15 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +size_t ft_lllen(long long n) +{ + size_t i; + + i = 1; + while (n /= 10) + i++; + return (i); +} diff --git a/libft/src/math/ft_lltoa_base.c b/libft/src/math/ft_lltoa_base.c index 62d9f8e5..a3efe82b 100644 --- a/libft/src/math/ft_lltoa_base.c +++ b/libft/src/math/ft_lltoa_base.c @@ -1,16 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lltoa_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:10:42 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:55:30 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -static size_t ft_size(long long n, int base) +static char *ft_flags(char *str, int *i, char *flags, int neg) { - size_t i; - - i = 1; - while (n /= base) - i++; - return (i); + if (neg) + str[*i++] = '-'; + else if (ft_strchr(flags, '+')) + str[*i++] = '+'; + else if (ft_strchr(flags, ' ')) + str[*i++] = ' '; + return (str); } -char *ft_lltoa_base(long long nbr, char *base, char *flags) +char *ft_lltoa_base(long long nbr, char *base, char *flags) { int i; int neg; @@ -19,10 +32,8 @@ char *ft_lltoa_base(long long nbr, char *base, char *flags) i = 0; base_size = ft_strlen(base); - str = ft_strnew(ft_size(nbr, base_size) + 1); - neg = 0; - if (nbr < 0) - neg = 1; + str = ft_strnew(ft_lllen(nbr, base_size) + 1); + neg = FT_NEG(nbr); if (nbr == 0) { str[i++] = '0'; @@ -34,12 +45,7 @@ char *ft_lltoa_base(long long nbr, char *base, char *flags) str[i++] = base[FT_ABS(nbr % base_size)]; nbr = nbr / base_size; } - if (neg) - str[i++] = '-'; - else if (ft_strchr(flags, '+')) - str[i++] = '+'; - else if (ft_strchr(flags, ' ')) - str[i++] = ' '; + str = ft_flags(str, &i, flags, neg); str[i] = '\0'; return (ft_strrev(str)); } diff --git a/libft/src/math/ft_uilen.c b/libft/src/math/ft_uilen.c index 0e7aa85f..9e87ca1f 100644 --- a/libft/src/math/ft_uilen.c +++ b/libft/src/math/ft_uilen.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_uilen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:54:41 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" size_t ft_uilen(unsigned int n) diff --git a/libft/src/math/ft_uitoa_base.c b/libft/src/math/ft_uitoa_base.c index 1888db90..a09cb11e 100644 --- a/libft/src/math/ft_uitoa_base.c +++ b/libft/src/math/ft_uitoa_base.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_uitoa_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:08:10 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:10:35 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" static size_t ft_size(unsigned int n, int base) @@ -10,7 +22,7 @@ static size_t ft_size(unsigned int n, int base) return (i); } -char *ft_uitoa_base(unsigned int nbr, char *base) +char *ft_uitoa_base(unsigned int nbr, char *base) { int i; int base_size; diff --git a/libft/src/math/ft_ulltoa_base.c b/libft/src/math/ft_ulltoa_base.c index 4e92334d..5c33f30d 100644 --- a/libft/src/math/ft_ulltoa_base.c +++ b/libft/src/math/ft_ulltoa_base.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_ulltoa_base.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/11/07 13:07:50 by jhalford #+# #+# */ +/* Updated: 2016/11/07 13:12:41 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" static size_t ft_size(unsigned long long n, int base) @@ -10,7 +22,7 @@ static size_t ft_size(unsigned long long n, int base) return (i); } -char *ft_ulltoa_base(unsigned long long nbr, char *base) +char *ft_ulltoa_base(unsigned long long nbr, char *base) { int i; int base_size; @@ -33,4 +45,3 @@ char *ft_ulltoa_base(unsigned long long nbr, char *base) str[i] = '\0'; return (ft_strrev(str)); } - diff --git a/libft/src/mem/ft_memcpy.c b/libft/src/mem/ft_memcpy.c index a0711c68..38a72390 100644 --- a/libft/src/mem/ft_memcpy.c +++ b/libft/src/mem/ft_memcpy.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:31 by jhalford #+# #+# */ -/* Updated: 2016/11/03 14:57:32 by jhalford ### ########.fr */ +/* Updated: 2016/11/07 13:10:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/mem/ft_memmove.c b/libft/src/mem/ft_memmove.c index 952faa3d..996c5cb3 100644 --- a/libft/src/mem/ft_memmove.c +++ b/libft/src/mem/ft_memmove.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:34 by jhalford #+# #+# */ -/* Updated: 2016/11/03 15:53:48 by jhalford ### ########.fr */ +/* Updated: 2016/11/07 13:46:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/str/ft_strsplit.c b/libft/src/str/ft_strsplit.c index b1aa03a2..9264c2ee 100644 --- a/libft/src/str/ft_strsplit.c +++ b/libft/src/str/ft_strsplit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:58:40 by jhalford #+# #+# */ -/* Updated: 2016/11/05 17:58:23 by jhalford ### ########.fr */ +/* Updated: 2016/11/07 13:07:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,22 +32,24 @@ char **ft_strsplit(char const *s, char c) int j; int w; + if (!s) + return (0); w = countwords(s, c); if ((arr = (char **)malloc((w + 1) * sizeof(char *)))) { - i = 0; - while (i < w) - { - while (*s == c) - ++s; - j = 0; - while (*(s + j) != c) - ++j; - if ((arr[i] = ft_strnew(j))) - ft_strncpy(arr[i++], s, j); - s += j; - } - arr[i] = 0; + i = 0; + while (i < w) + { + while (*s == c) + ++s; + j = 0; + while (*(s + j) != c) + ++j; + if ((arr[i] = ft_strnew(j))) + ft_strncpy(arr[i++], s, j); + s += j; } + arr[i] = 0; + } return (arr); }