Merge branch 'master' of https://git.cloud.arnaud-pc.fr/tvdu29/libft
This commit is contained in:
commit
2dfcdd29fd
52
.gitignore
vendored
Normal file
52
.gitignore
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
4
Makefile
4
Makefile
@ -6,7 +6,7 @@
|
||||
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
|
||||
# Updated: 2019/02/25 16:28:32 by tmaze ### ########.fr #
|
||||
# Updated: 2019/02/25 16:36:34 by tmaze ### ########.fr #
|
||||
# #
|
||||
#******************************************************************************#
|
||||
|
||||
@ -19,7 +19,7 @@ NAME = libft.a
|
||||
SRCS = ft_memset.c ft_bzero.c ft_memcpy.c ft_memccpy.c ft_memmove.c ft_memchr.c ft_memcmp.c ft_strlen.c ft_strdup.c ft_strcpy.c ft_strncpy.c ft_strcat.c ft_strncat.c ft_strlcat.c ft_strchr.c ft_strrchr.c ft_strstr.c ft_strnstr.c ft_strcmp.c ft_strncmp.c ft_atoi.c ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c ft_toupper.c ft_tolower.c \
|
||||
ft_memalloc.c ft_memdel.c ft_strnew.c ft_strdel.c ft_strclr.c ft_striter.c ft_striteri.c ft_strmap.c ft_strmapi.c ft_strequ.c ft_strnequ.c ft_strsub.c ft_strjoin.c ft_strtrim.c ft_strsplit.c ft_itoa.c ft_putchar.c ft_putstr.c ft_putendl.c ft_putnbr.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c ft_putnbr_fd.c\
|
||||
ft_lstnew.c ft_lstdelone.c ft_lstdel.c ft_lstadd.c ft_lstiter.c ft_lstmap.c \
|
||||
ft_isupper.c ft_islower.c ft_str_is_alpha.c ft_str_is_lowercase.c ft_str_is_numeric.c ft_str_is_printable.c ft_str_is_uppercase.c ft_strcapitalize.c ft_strlcpy.c ft_strlowcase.c ft_strupcase.c ft_lstsize.c ft_lstgetat.c ft_lstgetlast.c ft_sort_params.c ft_print_words_tables.c ft_lstaddend.c ft_strndup.c ft_abs.c ft_strnchr.c ft_strrnchr.c get_next_line.c ft_del_words_tables.c ft_putstrn.c ft_nbrlen.c ft_putstrpad.c ft_putnbrpad.c ft_lstsort.c ft_lstaddsort.c ft_round.c ft_iswhitespace.c ft_issign.c ft_hasdigit.c ft_strsplitwhitespace.c
|
||||
ft_isupper.c ft_islower.c ft_str_is_alpha.c ft_str_is_lowercase.c ft_str_is_numeric.c ft_str_is_printable.c ft_str_is_uppercase.c ft_strcapitalize.c ft_strlcpy.c ft_strlowcase.c ft_strupcase.c ft_lstsize.c ft_lstgetat.c ft_lstgetlast.c ft_sort_params.c ft_print_words_tables.c ft_lstaddend.c ft_strndup.c ft_abs.c ft_strnchr.c ft_strrnchr.c get_next_line.c ft_del_words_tables.c ft_putstrn.c ft_nbrlen.c ft_putstrpad.c ft_putnbrpad.c ft_lstsort.c ft_lstaddsort.c ft_round.c ft_realpath.c ft_iswhitespace.c ft_issign.c ft_hasdigit.c ft_strsplitwhitespace.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
INCLS = -I.
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/17 20:55:26 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/19 14:32:44 by tmaze ### ########.fr */
|
||||
/* Updated: 2018/11/26 12:30:30 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
t_list *ft_lstaddend(t_list **alst, t_list *new)
|
||||
{
|
||||
t_list **tmp;
|
||||
t_list *tmp;
|
||||
|
||||
if (new == NULL)
|
||||
return (NULL);
|
||||
@ -22,10 +22,8 @@ t_list *ft_lstaddend(t_list **alst, t_list *new)
|
||||
ft_lstadd(alst, new);
|
||||
else if (ft_lstsize(*alst) > 0)
|
||||
{
|
||||
if ((tmp = (t_list**)malloc(sizeof(t_list*))) == NULL)
|
||||
return (NULL);
|
||||
*tmp = ft_lstgetlast(*alst);
|
||||
ft_lstadd(&(*tmp)->next, new);
|
||||
tmp = ft_lstgetlast(*alst);
|
||||
ft_lstadd(&(tmp->next), new);
|
||||
}
|
||||
return (*alst);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/09 13:55:29 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/09 16:46:33 by tmaze ### ########.fr */
|
||||
/* Updated: 2018/11/28 14:46:12 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/07 22:37:44 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/10 14:24:26 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/01/13 17:44:21 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,8 +15,6 @@
|
||||
void ft_putendl(char const *s)
|
||||
{
|
||||
if (s != NULL)
|
||||
{
|
||||
ft_putstr(s);
|
||||
ft_putchar('\n');
|
||||
}
|
||||
}
|
||||
|
77
ft_realpath.c
Normal file
77
ft_realpath.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_realpath.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/01/27 14:42:35 by tmaze #+# #+# */
|
||||
/* Updated: 2019/01/29 18:16:22 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_tabtopath(char **tab_path)
|
||||
{
|
||||
size_t total_size;
|
||||
size_t i;
|
||||
char *ret;
|
||||
|
||||
i = 0;
|
||||
total_size = 0;
|
||||
while (tab_path[i])
|
||||
total_size += ft_strlen(tab_path[i++]);
|
||||
total_size = (total_size == 0) ? 1 : total_size;
|
||||
if ((ret = ft_strnew(total_size + i)) == NULL)
|
||||
return (NULL);
|
||||
i = 0;
|
||||
ft_strcat(ret, "/");
|
||||
while (tab_path[i])
|
||||
{
|
||||
if (i > 0)
|
||||
ft_strcat(ret, "/");
|
||||
ft_strcat(ret, tab_path[i++]);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void ft_reducepath(char ***tab)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
int strcmp;
|
||||
|
||||
i = 0;
|
||||
while ((*tab)[i])
|
||||
{
|
||||
if ((strcmp = ft_strcmp((*tab)[i], "..")) == 0
|
||||
|| ft_strcmp((*tab)[i], ".") == 0)
|
||||
{
|
||||
ft_strdel(&((*tab)[i]));
|
||||
if ((j = i) == i && strcmp == 0 && i != 0)
|
||||
ft_strdel(&((*tab)[i - 1]));
|
||||
while ((*tab)[++j])
|
||||
(*tab)[j - ((strcmp == 0 && i != 0) ? 2 : 1)] = (*tab)[j];
|
||||
if (strcmp == 0 && i != 0)
|
||||
(*tab)[j - 2] = NULL;
|
||||
(*tab)[j - 1] = NULL;
|
||||
if (strcmp == 0 && i != 0)
|
||||
i--;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
char *ft_realpath(char *r_path, char **a_path)
|
||||
{
|
||||
char **tab_path;
|
||||
|
||||
if ((tab_path = ft_strsplit(r_path, '/')) == NULL)
|
||||
return (NULL);
|
||||
ft_reducepath(&tab_path);
|
||||
*a_path = ft_tabtopath(tab_path);
|
||||
ft_del_words_tables(&tab_path);
|
||||
return (*a_path);
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/04 16:55:29 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/08 14:13:22 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/01/10 17:37:08 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
3
libft.h
3
libft.h
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/08 00:12:36 by tmaze #+# #+# */
|
||||
/* Updated: 2019/02/25 16:28:20 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/02/25 16:37:03 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -174,6 +174,7 @@ void ft_lstaddsort(t_list **lst, t_list *new,
|
||||
|
||||
int ft_round(float x, float ind);
|
||||
|
||||
char *ft_realpath(char *r_path, char **a_path);
|
||||
int ft_issign(char c);
|
||||
int ft_iswhitespace(char c);
|
||||
int ft_hasdigit(char *s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user