aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--README.md163
-rw-r--r--include/libft.h14
-rw-r--r--include/libft_algo.h34
-rw-r--r--include/libft_def.h (renamed from include/libft_types.h)35
-rw-r--r--include/libft_dlst.h30
-rw-r--r--include/libft_dstr.h44
-rw-r--r--include/libft_ht.h51
-rw-r--r--include/libft_lst.h2
-rw-r--r--include/libft_mem.h5
-rw-r--r--include/libft_str.h20
-rw-r--r--include/libft_vec.h9
-rwxr-xr-xscript/create_test.sh22
-rw-r--r--script/test.template.c26
-rwxr-xr-xscript/test_prettier.sh6
-rw-r--r--src/algo/ft_compar_int.c9
-rw-r--r--src/algo/ft_compar_str.c25
-rw-r--r--src/algo/ft_is_set.c13
-rw-r--r--src/algo/ft_mergesort.c24
-rw-r--r--src/algo/ft_qsort.c35
-rw-r--r--src/algo/ft_reverse.c9
-rw-r--r--src/dlst/ft_dlstdelone.c26
-rw-r--r--src/dlst/ft_dlstdestroy.c32
-rw-r--r--src/dlst/ft_dlstnew.c25
-rw-r--r--src/dstr/ft_dstrdestroy.c26
-rw-r--r--src/dstr/ft_dstrerase.c35
-rw-r--r--src/dstr/ft_dstrgrow.c41
-rw-r--r--src/dstr/ft_dstrinsert.c38
-rw-r--r--src/dstr/ft_dstrnew.c32
-rw-r--r--src/dstr/ft_dstrsubstitute.c32
-rw-r--r--src/dstr/ft_dstrunwrap.c28
-rw-r--r--src/ht/ft_htdelone.c11
-rw-r--r--src/ht/ft_htdestroy.c10
-rw-r--r--src/ht/ft_htget.c6
-rw-r--r--src/ht/ft_hthash.c4
-rw-r--r--src/ht/ft_htnew.c7
-rw-r--r--src/ht/ft_htset.c37
-rw-r--r--src/ht/ft_inter_htdel_first_order.c33
-rw-r--r--src/str/ft_atoi.c7
-rw-r--r--src/str/ft_fnmatch.c37
-rw-r--r--src/str/ft_strcasecmp.c2
-rw-r--r--src/str/ft_strcat3.c26
-rw-r--r--src/str/ft_strncasecmp.c2
-rw-r--r--src/str/ft_strncmp.c3
-rw-r--r--src/str/ft_strsep.c15
-rw-r--r--src/str/ft_strsjoin.c50
-rw-r--r--src/str/ft_strsjoinf.c29
-rw-r--r--src/str/ft_strsub.c (renamed from src/str/ft_substr.c)24
-rw-r--r--src/str/ft_strsubf.c30
-rw-r--r--src/str/ft_strtrim.c4
-rw-r--r--src/vec/ft_vecgrow.c4
-rw-r--r--src/vec/ft_vecinsert.c36
-rw-r--r--src/vec/ft_vecnew.c2
-rw-r--r--src/vec/ft_vecpush.c2
-rw-r--r--src/vec/ft_vecpush_safe.c27
-rw-r--r--src/vec/ft_vecremove.c31
-rw-r--r--src/vec/ft_vecsort.c24
-rw-r--r--test/Makefile6
-rw-r--r--test/include/libft_test.h1
-rw-r--r--test/src/algo/test_ft_qsort.c42
-rw-r--r--test/src/dstr/test_ft_dstrdestroy.c26
-rw-r--r--test/src/dstr/test_ft_dstrerase.c69
-rw-r--r--test/src/dstr/test_ft_dstrgrow.c52
-rw-r--r--test/src/dstr/test_ft_dstrinsert.c59
-rw-r--r--test/src/dstr/test_ft_dstrnew.c60
-rw-r--r--test/src/dstr/test_ft_dstrsubstitute.c64
-rw-r--r--test/src/dstr/test_ft_dstrunwrap.c42
-rw-r--r--test/src/ht/test_ft_htdelone.c28
-rw-r--r--test/src/ht/test_ft_htdestroy.c18
-rw-r--r--test/src/ht/test_ft_htget.c54
-rw-r--r--test/src/ht/test_ft_htset.c16
-rw-r--r--test/src/main.c18
-rw-r--r--test/src/runner/test_runner_algo.c3
-rw-r--r--test/src/runner/test_runner_dstr.c48
-rw-r--r--test/src/runner/test_runner_ht.c2
-rw-r--r--test/src/runner/test_runner_str.c25
-rw-r--r--test/src/runner/test_runner_vec.c21
-rw-r--r--test/src/str/test_ft_fnmatch.c117
-rw-r--r--test/src/str/test_ft_strsjoin.c57
-rw-r--r--test/src/str/test_ft_strsjoinf.c87
-rw-r--r--test/src/str/test_ft_strsub.c54
-rw-r--r--test/src/str/test_ft_strsubf.c61
-rw-r--r--test/src/vec/test_ft_vecgrow.c41
-rw-r--r--test/src/vec/test_ft_vecinsert.c66
-rw-r--r--test/src/vec/test_ft_vecpush_safe.c45
-rw-r--r--test/src/vec/test_ft_vecremove.c64
-rw-r--r--test/src/vec/test_ft_vecsort.c34
87 files changed, 2271 insertions, 368 deletions
diff --git a/Makefile b/Makefile
index 9b9cee4..14b556d 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/10/08 15:45:53 by cacharle #+# #+# #
-# Updated: 2020/04/01 21:58:00 by charles ### ########.fr #
+# Updated: 2020/05/09 12:28:11 by charles ### ########.fr #
# #
# **************************************************************************** #
@@ -30,6 +30,9 @@ INCLUDE_DIR = include
CC = gcc
OFLAG ?= -O0
CCFLAGS = $(OFLAG) -I$(INCLUDE_DIR) -Wall -Wextra -Werror
+ifeq ($(TRAVIS_COMPILER),gcc)
+CCFLAGS += -Wno-unused-result
+endif
ifeq ($(TRAVIS_COMPILER),gcc)
CCFLAGS += -Wno-unused-result
diff --git a/README.md b/README.md
index 6984a24..a278471 100644
--- a/README.md
+++ b/README.md
@@ -28,166 +28,9 @@ Much like the `.gitignore` file, you can put the files/directory to ignore when
## Documentation
-### mem
-
-| Name | Prototype | Description | Tested |
-|--------------------|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|--------|
-| ft_bzero | `void ft_bzero(void *s, size_t n)` | fill `n` bytes of `s` with 0 | [x] |
-| ft_calloc | `void *ft_calloc(size_t count, size_t size)` | allocate `count` element of `size` and initialize them to 0 | [x] |
-| ft_memccpy | `void *ft_memccpy(void *dest, const void *src, int c, size_t n)` | copy `n` byte from `src` to `dest` until `c` is reached | [x] |
-| ft_memchr | `void *ft_memchr(const void *s, int c, size_t n)` | return the address of the first occurance of `c` in `s` or NULL if `c` isn't found | [x] |
-| ft_memcmp | `int ft_memcmp(const void *s1, const void *s2, size_t n)` | compare `n` byte of `s1` and `s2` | [x] |
-| ft_memcpy | `void *ft_memcpy(void *dest, const void *src, size_t n)` | copy `n` byte from `src` to `dest` | [x] |
-| ft_memmem | `void *ft_memmem(const void *big, size_t big_len, const void *little, size_t little_len)` | search `little` in `big` | [x] |
-| ft_memmove | `void *ft_memmove(void *dst, const void *src, size_t len)` | copy `len` byte from `src` to `dst` and the copied memory can overlap | [x] |
-| ft_memset | `void *ft_memset(void *s, int c, size_t n)` | set `n` byte of `s` to `c` | [x] |
-| ft_memset_pattern4 | `void ft_memset_pattern4(void *b, const void *pattern4, size_t len)` | set `len` byte of `b` to a reapeated pattern of 4 bytes | [x] |
-| ft_memswap | `void ft_memswap(void *a, void *b, size_t size)` | swap `a` and `b` memory | [x] |
-
-### algo
-
-| Name | Prototype | Description | Tested |
-|---------------|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|--------|
-| ft_bsearch | `void *ft_bsearch(const void *base, size_t nel, size_t width, t_ftsearch_const *consts)` | search `consts.key` in `base` using binary search (NULL if not found) | [x] |
-| ft_compar_int | `int ft_compar_int(const void *a, const void *b)` | comparison function of `int` | [x] |
-| ft_heapsort | `int ft_heapsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *))` | sort `base` using heapsort | [?] |
-| ft_is_set | `t_ftbool ft_is_set(void *base, size_t nel, size_t width, t_ftcompar_func compar)` | check is `base` has unique elements | [x] |
-| ft_lfind | `void *ft_lfind(const void *base, size_t *nelp, size_t width, t_ftsearch_const *consts)` | search `consts.key` in `base` using linear search (NULL if not found) | [x] |
-| ft_lsearch | `void *ft_lsearch(const void *base, size_t *nelp, size_t width, t_ftsearch_const *consts)` | search `consts.key` in `base` using linear search (insert at the end if not found) | [x] |
-| ft_mergesort | `int ft_mergesort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *))` | sort `base` using mergesort | [x] |
-| ft_qsort | `void ft_qsort(void *base, size_t nel, size_t width, t_ftcompar_func compar)` | sort `base` using quicksort | [x] |
-| ft_reverse | `void ft_reverse(void *base, size_t nel, size_t width)` | reverse `base` | [x] |
-
-### bt
-
-| Name | Prototype | Description | Tested |
-|--------------|---------------------------------------------------------------|----------------------------------------------|--------|
-| ft_btdestroy | `void ft_btdestroy(t_ftbtree *tree, void (*del)(void *data))` | destroy `tree` and apply `del` on nodes data | [ ] |
-| ft_btnew | `t_ftbtree *ft_btnew(void *data)` | create a new node with `data` | [ ] |
-
-### ctype
-
-| Name | Prototype | Description | Tested |
-|------------|-------------------------|----------------------------------------------------|--------|
-| ft_isalnum | `int ft_isalnum(int c)` | c is alphanumeric | [x] |
-| ft_isalpha | `int ft_isalpha(int c)` | c is alphabetic | [x] |
-| ft_isascii | `int ft_isascii(int c)` | c is ascii | [x] |
-| ft_isblank | `int ft_isblank(int c)` | c is `\t` ` ` | [x] |
-| ft_isdigit | `int ft_isdigit(int c)` | c is a digit | [x] |
-| ft_isprint | `int ft_isprint(int c)` | c is a printable character | [x] |
-| ft_isspace | `int ft_isspace(int c)` | c is `\t` `\n` `\v` `\f` `\r` ` ` | [x] |
-| ft_todigit | `int ft_todigit(int c)` | convert lower case to upper case | [x] |
-| ft_tolower | `int ft_tolower(int c)` | convert upper case to lower case | [x] |
-| ft_toupper | `int ft_toupper(int c)` | convert digit character to int (-1 if not a digit) | [x] |
-
-### ht
-
-| Name | Prototype | Description | Tested |
-|------------------|-------------------------------------------------------------------------|-----------------------------------------------------------|--------|
-| ft_htcontent_new | `t_ftht_content *ft_htcontent_new(char *key, void *value)` | create a new key/value pair | [x] |
-| ft_htdelone | `void ft_htdelone(t_ftht *ht, char *key, void (*del)(t_ftht_content*))` | delete element at `key` | [x] |
-| ft_htdestroy | `void ft_htdestroy(t_ftht *ht, void (*del)(t_ftht_content*))` | destroy `ht` with the `del` functions applied on values | [x] |
-| ft_htget | `void *ft_htget(t_ftht *ht, char *key)` | return value at `key` | [x] |
-| ft_htnew | `t_ftht *ft_htnew(t_ftsize size)` | create a new hash table with a underlying array of `size` | [x] |
-| ft_htset | `t_ftht_content *ft_htset(t_ftht *ht, char *key, void *value)` | set `key` to value, if element doesn't exist, create it | [x] |
-
-### io
-
-| Name | Prototype | Description | Tested |
-|---------------|-----------------------------------------|------------------------------------------------|--------|
-| ft_getchar | `char ft_getchar(void)` | read one character from stdin and return it | [ ] |
-| ft_next_line | `int ft_next_line(int fd, char **line)` | read a line of `fd` and put it in `line` | [ ] |
-| ft_putchar | `void ft_putchar(char c)` | write a character on stdout | [ ] |
-| ft_putchar_fd | `void ft_putchar_fd(char c, int fd)` | write a character on `fd` | [ ] |
-| ft_putendl | `void ft_putendl(char *s)` | write a string followed by a newline on stdout | [ ] |
-| ft_putendl_fd | `void ft_putendl_fd(char *s, int fd)` | write a string followed by a newline on `fd` | [ ] |
-| ft_putnbr | `void ft_putnbr(int n)` | write a number on stdout | [ ] |
-| ft_putnbr_fd | `void ft_putnbr_fd(int n, int fd)` | write a number on `fd` | [ ] |
-| ft_putstr | `void ft_putstr(char const *s)` | write a string on stdout | [ ] |
-| ft_putstr_fd | `void ft_putstr_fd(char *s, int fd)` | write a string on `fd` | [ ] |
-
-### printf
-
-| Name | Prototype | Description | Tested |
-|---------------|----------------------------------------------------------------------------|---------------------------------------------------------------------|--------|
-| ft_asprintf | `int ft_asprintf(char **ret, const char *format, ...)` | allocate and return the formated string | [ ] |
-| ft_dprintf | `int ft_dprintf(int fd, const char *format, ...)` | write formated string to `fd` | [ ] |
-| ft_printf | `int ft_printf(const char *format, ...)` | write formated string to stdout | [ ] |
-| ft_snprintf | `int ft_snprintf(char *str, size_t size, const char *format, ...)` | write formated string in `str` with max `size` character | [ ] |
-| ft_sprintf | `int ft_sprintf(char *str, const char *format, ...)` | write formated string in `str` | [ ] |
-| ft_vasprintf | `int ft_vasprintf(char **ret, const char *format, va_list ap)` | allocate and return the formated string, with `ap` | [ ] |
-| ft_vdprintf | `int ft_vdprintf(int fd, const char *format, va_list ap)` | write formated string to `fd` , with `ap` | [ ] |
-| ft_vprintf | `int ft_vprintf(const char *format, va_list ap)` | write formated string to stdout, with `ap` | [ ] |
-| ft_vsnprintf | `int ft_vsnprintf(char *str, size_t size, const char *format, va_list ap)` | write formated string in `str` with max `size` character, with `ap` | [ ] |
-| ft_vsprintf | `int ft_vsprintf(char *str, const char *format, va_list ap)` | write formated string in `str`, with `ap` | [ ] |
-
-### lst
-
-| Name | Prototype | Description | Tested |
-|--------------------|---------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|--------|
-| ft_lstadd_back | `void ft_lstadd_back(t_ftlst **alst, t_ftlst *new)` | add `new` at the start of `alst` | [x] |
-| ft_lstadd_front | `void ft_lstadd_front(t_ftlst **alst, t_ftlst *new)` | add `new` at the end of `alst` | [x] |
-| ft_lstbsearch | `t_ftlst *ft_lstbsearch(t_ftlst *lst, t_ftbool (*equal)(void *ref, void *content), void *ref)` | search `ref` in `lst` using binary search | [x] |
-| ft_lstlsearch | `t_ftlst *ft_lstlsearch(t_ftlst *lst, t_ftbool (*equal)(void *ref, void *content), void *ref)` | search `ref` in `lst` using linear search (push back if not found)| [x] |
-| ft_lstlfind | `t_ftlst *ft_lstlsearch(t_ftlst *lst, t_ftbool (*equal)(void *ref, void *content), void *ref)` | search `ref` in `lst` using linear search | [x] |
-| ft_lstclear | `void ft_lstclear(t_ftlst **lst, void (*del)(void *))` | free all data with `del`, free all nodes and set `*lst` to NULL | [x] |
-| ft_lstdelone | `void ft_lstdelone(t_ftlst *lst, void (*del)(void *))` | free `lst` node | [x] |
-| ft_lstiter | `void ft_lstiter(t_ftlst *lst, void (*f)(void *))` | apply `f` on each node of `lst` | [x] |
-| ft_lstlast | `t_ftlst *ft_lstlast(t_ftlst *lst)` | return the last node of `lst` | [x] |
-| ft_lstmap | `t_ftlst *ft_lstmap(t_ftlst *lst, void *(*f)(void *), void (*del)(void *))` | create a new list which is `lst` with all node passed through `f` | [x] |
-| ft_lstnew | `t_ftlst *ft_lstnew(void const *content)` | create a new node with `content` | [x] |
-| ft_lstpop_front | `void ft_lstpop_front(t_ftlst **lst, void (*del)(void *))` | remove the front of `lst` | [x] |
-| ft_lstremove_if | `void ft_lstremove_if(t_ftlst **lst, int (*cmp)(const void *ref, const void *content), void *ref, void (*del)(void *content))` | remove all element which verify `equal` | [x] |
-| ft_lstreverse | `void ft_lstreverse(t_ftlst **lst)` | reverse `lst` | [x] |
-| ft_lstreverse_ret | `t_ftlst *ft_lstreverse_ret(t_ftlst *lst)` | reverse `lst` and return it | [x] |
-| ft_lstsize | `int ft_lstsize(t_ftlst *lst)` | return the number of node in `lst` | [x] |
-| ft_lstsort | `void ft_lstsort(t_ftlst **begin_list, int (*cmp)(void *, void*))` | sort `begin_list` using mergesort | [x] |
-| ft_lstsorted_merge | `t_ftlst *ft_lstsorted_merge(t_ftlst *l1, t_ftlst *l2, int (*cmp)(void *, void *))` | merge 2 sorted list and return the merged and still sorted one | [x] |
-
-### str
-
-| Name | Prototype | Description | Tested |
-|----------------|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|--------|
-| ft_atoi | `int ft_atoi(const char *nptr)` | convert `nptr` to an int | [ ] |
-| ft_atoi_strict | `int ft_atoi_strict(const char *s )` | convert `nptr` to an int without spaces or other characters | [ ] |
-| ft_itoa | `char *ft_itoa(int n)` | return a string which represent `n` | [ ] |
-| ft_split | `char **ft_split(char const *s, char c)` | return the strings in between `c` in `s` | [ ] |
-| ft_strcasecmp | `int ft_strcasecmp(const char *s1, const char *s2)` | compare `s1` and `s2` ignoring case | [ ] |
-| ft_strcat | `char *ft_strcat(char *dest, const char *src)` | concatenate `dest` and `src` in `dest` | [ ] |
-| ft_strchr | `char *ft_strchr(const char *s, int c)` | search `c` in `s`, return address if found, NULL otherwise | [ ] |
-| ft_strcmp | `int ft_strcmp(const char *s1, const char *s2)` | compare `s1` and `s2` | [ ] |
-| ft_strcount | `int ft_strcount(char *str, char c)` | count the number of occurence of `c` in `str` | [ ] |
-| ft_strcpy | `char *ft_strcpy(char *dest, const char *src)`