some changes for ft_ls, mostly printf norm
This commit is contained in:
parent
3156450a32
commit
f54e802fa7
34 changed files with 479 additions and 104 deletions
|
|
@ -1,10 +1,27 @@
|
||||||
typedef struct s_dlist
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* dlst.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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;
|
void *content;
|
||||||
size_t content_size;
|
size_t content_size;
|
||||||
struct s_dlist *next;
|
struct s_dlist *next;
|
||||||
struct s_dlist *prev;
|
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_after(t_dlist **alst, t_dlist *new);
|
||||||
void ft_dlst_add_before(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_new(void const *content, size_t content_size);
|
||||||
t_dlist *ft_dlst_last(t_dlist *list);
|
t_dlist *ft_dlst_last(t_dlist *list);
|
||||||
char *ft_dlsttostr(t_dlist *list);
|
char *ft_dlsttostr(t_dlist *list);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,17 @@
|
||||||
#ifndef LIBFTPRINTF_H
|
/* ************************************************************************** */
|
||||||
# define LIBFTPRINTF_H
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ftprintf.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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 "libft.h"
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
# define ALL_FLAGS "#0- +"
|
# define ALL_FLAGS "#0- +"
|
||||||
21
libft/includes/ft_xattr.h
Normal file
21
libft/includes/ft_xattr.h
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ftxattr.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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 <sys/types.h>
|
||||||
|
# include <sys/xattr.h>
|
||||||
|
|
||||||
|
int ft_xattr_print(char *path);
|
||||||
|
int ft_xattr_count(char *path);
|
||||||
|
#endif
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef FTXATTR_H
|
|
||||||
# define FTXATTR_H
|
|
||||||
# define FT_XATTR_SIZE 10000
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/xattr.h>
|
|
||||||
|
|
||||||
int ft_xattr_print(char *path);
|
|
||||||
int ft_xattr_count(char *path);
|
|
||||||
#endif
|
|
||||||
20
libft/includes/get_next_line.h
Normal file
20
libft/includes/get_next_line.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* getnextline.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -1,7 +1,19 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* libft.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:55:26 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef LIBFT_H
|
#ifndef LIBFT_H
|
||||||
# define LIBFT_H
|
# define LIBFT_H
|
||||||
|
|
||||||
# include "ftxattr.h"
|
# include "ft_xattr.h"
|
||||||
# include "lst.h"
|
# include "lst.h"
|
||||||
# include "dlst.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_str3join(char const *s1, char const *s2, char const *s3);
|
||||||
char *ft_strcut(char *str, char *cut);
|
char *ft_strcut(char *str, char *cut);
|
||||||
char **ft_split_whitespaces(char *str);
|
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_itoa_base(int nbr, char *base, char *flags);
|
||||||
char *ft_lltoa_base(long long 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);
|
char *ft_uitoa_base(unsigned int nbr, char *base);
|
||||||
size_t ft_ilen(int n);
|
size_t ft_ilen(int n);
|
||||||
size_t ft_uilen(unsigned 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_sstrsort(char **list, int size, int (*cmp)());
|
||||||
void ft_sstrprint(char **list, char sep);
|
void ft_sstrprint(char **list, char sep);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,26 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lst.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:31:28 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef LST_H
|
#ifndef LST_H
|
||||||
# define LST_H
|
# define LST_H
|
||||||
|
|
||||||
typedef struct s_list
|
struct s_list
|
||||||
{
|
{
|
||||||
void *content;
|
void *content;
|
||||||
size_t content_size;
|
size_t content_size;
|
||||||
struct s_list *next;
|
struct s_list *next;
|
||||||
} t_list;
|
};
|
||||||
|
|
||||||
|
typedef struct s_list t_list;
|
||||||
|
|
||||||
t_list *ft_lstnew(void const *content, size_t content_size);
|
t_list *ft_lstnew(void const *content, size_t content_size);
|
||||||
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
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));
|
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_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_sort(t_list **begin_list, int (*cmp)());
|
||||||
void ft_lst_print(t_list *list, void (*printer)());
|
void ft_lst_print(t_list *list, void (*printer)());
|
||||||
int ft_lstsize(t_list *lst);
|
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);
|
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_merge(
|
||||||
void ft_lst_sorted_insert(t_list **begin_list, t_list *insert, int (*cmp)());
|
t_list **begin_list1,
|
||||||
t_list *ft_lstnew_range(int a, int b);
|
t_list *begin_list2,
|
||||||
void ft_lst_delif(t_list **alist, void *data_ref, int (*cmp)(), void (*del)(void *, size_t));
|
int (*cmp)());
|
||||||
void ft_lst_delsub(t_list **alst, t_list *sub, int (*cmp)(), void (*del)(void *, size_t));
|
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);
|
void ft_lst_cfree(void *ptr, size_t size);
|
||||||
|
t_list *ft_lst_filter(
|
||||||
t_list *ft_lst_filter(t_list *lst, void const *data_ref, t_list *(*f)(t_list *elem, void const *));
|
t_list *lst,
|
||||||
t_list *ft_lst_removeif(t_list **alst, void *data_ref, int (*cmp)());
|
void const *data_ref,
|
||||||
t_list *ft_lst_find(t_list *begin_list, void *data_ref, int (*cmp)());
|
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);
|
t_list *ft_lstpop(t_list **lst);
|
||||||
void ft_lst_merge(t_list **begin_list1, t_list *begin_list2);
|
void ft_lst_merge(t_list **begin_list1, t_list *begin_list2);
|
||||||
void ft_lst_reverse(t_list **begin_list);
|
void ft_lst_reverse(t_list **begin_list);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_add_after.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:04 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:36 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
void ft_dlst_add_after(t_dlist **alst, t_dlist *new)
|
void ft_dlst_add_after(t_dlist **alst, t_dlist *new)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_add_before.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:09 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:10 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
void ft_dlst_add_before(t_dlist **alst, t_dlist *new)
|
void ft_dlst_add_before(t_dlist **alst, t_dlist *new)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_delone.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:13 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:13 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
void ft_dlst_delone(t_dlist **alst, void (*del)(void *, size_t))
|
void ft_dlst_delone(t_dlist **alst, void (*del)(void *, size_t))
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_last.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:15 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:15 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_dlist *ft_dlst_last(t_dlist *list)
|
t_dlist *ft_dlst_last(t_dlist *list)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_new.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:20 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:20 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_dlist *ft_dlst_new(void const *content, size_t content_size)
|
t_dlist *ft_dlst_new(void const *content, size_t content_size)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlst_size.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:23 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:27:23 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
int ft_dlst_size(t_dlist *list)
|
int ft_dlst_size(t_dlist *list)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_dlstrtostr.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:27:29 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:31:08 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
char *ft_dlsttostr(t_dlist *list)
|
char *ft_dlsttostr(t_dlist *list)
|
||||||
|
|
@ -9,12 +21,10 @@ char *ft_dlsttostr(t_dlist *list)
|
||||||
while (list->prev)
|
while (list->prev)
|
||||||
list = list->prev;
|
list = list->prev;
|
||||||
str = (char *)ft_strnew(sizeof(char) * (ft_dlst_size(list) + 2));
|
str = (char *)ft_strnew(sizeof(char) * (ft_dlst_size(list) + 2));
|
||||||
/* list = ft_dlst_last(list); */
|
|
||||||
while (list)
|
while (list)
|
||||||
{
|
{
|
||||||
ft_strcat(str, (char *)list->content);
|
ft_strcat(str, (char *)list->content);
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
/* str = ft_strrev(str); */
|
|
||||||
return (str);
|
return (str);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,24 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_conversion.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:48:59 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
char *ft_signed_conversion(t_fmt *fmt, va_list ap)
|
char *ft_signed_conversion(t_fmt *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char base10[] = "0123456789";
|
char base10[10];
|
||||||
long long arg = va_arg(ap, int);
|
long long arg;
|
||||||
|
|
||||||
|
arg = va_arg(ap, int);
|
||||||
|
ft_strcpy(base10, "0123456789");
|
||||||
(void)fmt;
|
(void)fmt;
|
||||||
return (ft_lltoa_base(arg, base10, fmt->flags));
|
return (ft_lltoa_base(arg, base10, fmt->flags));
|
||||||
}
|
}
|
||||||
|
|
@ -36,8 +50,6 @@ char *ft_char_conversion(t_fmt *fmt, va_list ap)
|
||||||
|
|
||||||
(void)fmt;
|
(void)fmt;
|
||||||
ret = (char *)malloc(sizeof(char) + 1);
|
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[0] = (char)va_arg(ap, int);
|
||||||
ret[1] = '\0';
|
ret[1] = '\0';
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
@ -48,8 +60,6 @@ char *ft_str_conversion(t_fmt *fmt, va_list ap)
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
(void)fmt;
|
(void)fmt;
|
||||||
/* if (ft_strcmp(fmt->modifier, "l") == 0) */
|
|
||||||
/* va_arg(ap, wchar_t *); */
|
|
||||||
ret = ft_strdup(va_arg(ap, char *));
|
ret = ft_strdup(va_arg(ap, char *));
|
||||||
if (fmt->precision && fmt->precision < (int)ft_strlen(ret))
|
if (fmt->precision && fmt->precision < (int)ft_strlen(ret))
|
||||||
ret[fmt->precision] = '\0';
|
ret[fmt->precision] = '\0';
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_parse.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:24 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:52:02 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
t_fmt *ft_printf_parse(char **format, va_list ap)
|
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;
|
*format += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ft_printf_parse_modifiers(t_fmt *fmt, char **format)
|
void ft_printf_parse_modifiers(t_fmt *fmt, char **format)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_printf.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:33:59 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
t_conv g_convs[] =
|
t_conv g_convs[] =
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_transform.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:32 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:33:32 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
char *ft_transform(t_fmt *fmt, va_list ap)
|
char *ft_transform(t_fmt *fmt, va_list ap)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lib_fmt.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:35 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:33:35 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
t_fmt *ft_fmt_init(void)
|
t_fmt *ft_fmt_init(void)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lib_fmt_error.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:38 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:33:39 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
void ft_fmt_error_conv(char conv)
|
void ft_fmt_error_conv(char conv)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,16 @@
|
||||||
#include "ftprintf.h"
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lib_fmt_validate.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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)
|
void ft_fmt_simplify(t_fmt *fmt)
|
||||||
{
|
{
|
||||||
|
|
@ -17,6 +29,7 @@ void ft_fmt_simplify(t_fmt *fmt)
|
||||||
ft_strcpy(fmt->modifier, "l");
|
ft_strcpy(fmt->modifier, "l");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ft_fmt_validate_conversion(t_fmt *fmt)
|
int ft_fmt_validate_conversion(t_fmt *fmt)
|
||||||
{
|
{
|
||||||
if (!ft_strchr(ALL_CONVERSIONS, fmt->conversion))
|
if (!ft_strchr(ALL_CONVERSIONS, fmt->conversion))
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lib_pad.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:45 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:48:19 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
void ft_pad_right(char *str, t_fmt *fmt)
|
void ft_pad_right(char *str, t_fmt *fmt)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lib_pad_sharp.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:33:48 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:33:49 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "ftprintf.h"
|
#include "ftprintf.h"
|
||||||
|
|
||||||
void ft_pad_sharp_o(char *str, t_fmt *fmt)
|
void ft_pad_sharp_o(char *str, t_fmt *fmt)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_ilen.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:53:53 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:54:28 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
size_t ft_ilen(int n)
|
size_t ft_ilen(int n)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,26 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_itoa_base.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:52:51 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:57:06 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#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;
|
if (neg)
|
||||||
|
str[*i++] = '-';
|
||||||
i = 1;
|
else if (ft_strchr(flags, '+'))
|
||||||
while (n /= base)
|
str[*i++] = '+';
|
||||||
i++;
|
else if (ft_strchr(flags, ' '))
|
||||||
return (i);
|
str[*i++] = ' ';
|
||||||
|
return (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ft_itoa_base(int nbr, char *base, char *flags)
|
char *ft_itoa_base(int nbr, char *base, char *flags)
|
||||||
|
|
@ -19,10 +32,8 @@ char *ft_itoa_base(int nbr, char *base, char *flags)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
base_size = ft_strlen(base);
|
base_size = ft_strlen(base);
|
||||||
str = ft_strnew(ft_size(nbr, base_size) + 1);
|
str = ft_strnew(ft_ilen(nbr, base_size) + 1);
|
||||||
neg = 0;
|
neg = FT_NEG(nbr);
|
||||||
if (nbr < 0)
|
|
||||||
neg = 1;
|
|
||||||
if (nbr == 0)
|
if (nbr == 0)
|
||||||
{
|
{
|
||||||
str[i++] = '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)];
|
str[i++] = base[FT_ABS(nbr % base_size)];
|
||||||
nbr = nbr / base_size;
|
nbr = nbr / base_size;
|
||||||
}
|
}
|
||||||
if (neg)
|
str = ft_flags(str, &i, flags, neg);
|
||||||
str[i++] = '-';
|
|
||||||
else if (ft_strchr(flags, '+'))
|
|
||||||
str[i++] = '+';
|
|
||||||
else if (ft_strchr(flags, ' '))
|
|
||||||
str[i++] = ' ';
|
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
return (ft_strrev(str));
|
return (ft_strrev(str));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
libft/src/math/ft_lllen.c
Normal file
23
libft/src/math/ft_lllen.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lllen.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
@ -1,13 +1,26 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_lltoa_base.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:10:42 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:55:30 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#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;
|
if (neg)
|
||||||
|
str[*i++] = '-';
|
||||||
i = 1;
|
else if (ft_strchr(flags, '+'))
|
||||||
while (n /= base)
|
str[*i++] = '+';
|
||||||
i++;
|
else if (ft_strchr(flags, ' '))
|
||||||
return (i);
|
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)
|
||||||
|
|
@ -19,10 +32,8 @@ char *ft_lltoa_base(long long nbr, char *base, char *flags)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
base_size = ft_strlen(base);
|
base_size = ft_strlen(base);
|
||||||
str = ft_strnew(ft_size(nbr, base_size) + 1);
|
str = ft_strnew(ft_lllen(nbr, base_size) + 1);
|
||||||
neg = 0;
|
neg = FT_NEG(nbr);
|
||||||
if (nbr < 0)
|
|
||||||
neg = 1;
|
|
||||||
if (nbr == 0)
|
if (nbr == 0)
|
||||||
{
|
{
|
||||||
str[i++] = '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)];
|
str[i++] = base[FT_ABS(nbr % base_size)];
|
||||||
nbr = nbr / base_size;
|
nbr = nbr / base_size;
|
||||||
}
|
}
|
||||||
if (neg)
|
str = ft_flags(str, &i, flags, neg);
|
||||||
str[i++] = '-';
|
|
||||||
else if (ft_strchr(flags, '+'))
|
|
||||||
str[i++] = '+';
|
|
||||||
else if (ft_strchr(flags, ' '))
|
|
||||||
str[i++] = ' ';
|
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
return (ft_strrev(str));
|
return (ft_strrev(str));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_uilen.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:52:35 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:54:41 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
size_t ft_uilen(unsigned int n)
|
size_t ft_uilen(unsigned int n)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_uitoa_base.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:08:10 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:10:35 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
static size_t ft_size(unsigned int n, int base)
|
static size_t ft_size(unsigned int n, int base)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_ulltoa_base.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2016/11/07 13:07:50 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2016/11/07 13:12:41 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
static size_t ft_size(unsigned long long n, int base)
|
static size_t ft_size(unsigned long long n, int base)
|
||||||
|
|
@ -33,4 +45,3 @@ char *ft_ulltoa_base(unsigned long long nbr, char *base)
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
return (ft_strrev(str));
|
return (ft_strrev(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:31 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:34 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:58:40 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,6 +32,8 @@ char **ft_strsplit(char const *s, char c)
|
||||||
int j;
|
int j;
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
|
if (!s)
|
||||||
|
return (0);
|
||||||
w = countwords(s, c);
|
w = countwords(s, c);
|
||||||
if ((arr = (char **)malloc((w + 1) * sizeof(char *))))
|
if ((arr = (char **)malloc((w + 1) * sizeof(char *))))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue