diff --git a/lib/Makefile b/lib/Makefile index b2265ef..a94b27d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -23,8 +23,8 @@ PART2 = ft_itoa.c ft_strjoin.c ft_split.c ft_striteri.c ft_strmapi.c \ ft_substr.c ft_strtrim.c ft_putchar_fd.c ft_putstr_fd.c ft_putendl_fd.c \ ft_putnbr_fd.c -BONUS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c ft_lstadd_back.c \ - ft_lstdelone.c ft_lstclear.c ft_lstiter.c ft_lstmap.c +BONUS = ft_lstnew_bonus.c ft_lstadd_front_bonus.c ft_lstsize_bonus.c ft_lstlast_bonus.c ft_lstadd_back_bonus.c \ + ft_lstdelone_bonus.c ft_lstclear_bonus.c ft_lstiter_bonus.c ft_lstmap_bonus.c SRC = ${PART1} ${PART2} diff --git a/lib/ft_atoi.c b/lib/ft_atoi.c index e90d0f6..c2f0c55 100644 --- a/lib/ft_atoi.c +++ b/lib/ft_atoi.c @@ -14,7 +14,7 @@ //ft_isdigit(str[i]) returns boolean if is digit or not. #include "libft.h" -int ft_atoi(const char *str) +int ft_atoi(const char *nptr) { int i; int sign; @@ -23,19 +23,19 @@ int ft_atoi(const char *str) i = 0; sign = 1; result = 0; - while (str[i] == 32 || (str[i] >= 9 && str[i] <= 13)) + while (nptr[i] == 32 || (nptr[i] >= 9 && nptr[i] <= 13)) i++; - if (str[i] == '-') + if (nptr[i] == '-') { sign = -1; i++; } - else if (str[i] == '+') + else if (nptr[i] == '+') i++; - while (ft_isdigit(str[i])) + while (ft_isdigit(nptr[i])) { result *= 10; - result += str[i] - '0'; + result += nptr[i] - '0'; i++; } return (result * sign); diff --git a/lib/ft_lstadd_back.c b/lib/ft_lstadd_back_bonus.c similarity index 100% rename from lib/ft_lstadd_back.c rename to lib/ft_lstadd_back_bonus.c diff --git a/lib/ft_lstadd_front.c b/lib/ft_lstadd_front_bonus.c similarity index 100% rename from lib/ft_lstadd_front.c rename to lib/ft_lstadd_front_bonus.c diff --git a/lib/ft_lstclear.c b/lib/ft_lstclear_bonus.c similarity index 100% rename from lib/ft_lstclear.c rename to lib/ft_lstclear_bonus.c diff --git a/lib/ft_lstdelone.c b/lib/ft_lstdelone_bonus.c similarity index 100% rename from lib/ft_lstdelone.c rename to lib/ft_lstdelone_bonus.c diff --git a/lib/ft_lstiter.c b/lib/ft_lstiter_bonus.c similarity index 100% rename from lib/ft_lstiter.c rename to lib/ft_lstiter_bonus.c diff --git a/lib/ft_lstlast.c b/lib/ft_lstlast_bonus.c similarity index 100% rename from lib/ft_lstlast.c rename to lib/ft_lstlast_bonus.c diff --git a/lib/ft_lstmap.c b/lib/ft_lstmap_bonus.c similarity index 100% rename from lib/ft_lstmap.c rename to lib/ft_lstmap_bonus.c diff --git a/lib/ft_lstnew.c b/lib/ft_lstnew_bonus.c similarity index 100% rename from lib/ft_lstnew.c rename to lib/ft_lstnew_bonus.c diff --git a/lib/ft_lstsize.c b/lib/ft_lstsize_bonus.c similarity index 100% rename from lib/ft_lstsize.c rename to lib/ft_lstsize_bonus.c diff --git a/lib/ft_strlcat.c b/lib/ft_strlcat.c index 0d15ccb..bc8f676 100644 --- a/lib/ft_strlcat.c +++ b/lib/ft_strlcat.c @@ -22,7 +22,7 @@ // :space had been available. #include "libft.h" -size_t ft_strlcat(char *dest, const char *src, size_t size) +size_t ft_strlcat(char *dst, const char *src, size_t size) { size_t i; size_t len_src; @@ -32,18 +32,18 @@ size_t ft_strlcat(char *dest, const char *src, size_t size) i = 0; str_result = 0; len_src = ft_strlen(src); - len_dest = ft_strlen(dest); + len_dest = ft_strlen(dst); if (size > len_dest) str_result = len_src + len_dest; else return (len_src + size); while (src[i] && (len_dest + 1) < size) { - dest[len_dest] = src[i]; + dst[len_dest] = src[i]; len_dest++; i++; } - dest[len_dest] = '\0'; + dst[len_dest] = '\0'; return (str_result); } // int main(void) diff --git a/lib/ft_strlcpy.c b/lib/ft_strlcpy.c index 8c9f52a..3d16950 100644 --- a/lib/ft_strlcpy.c +++ b/lib/ft_strlcpy.c @@ -12,21 +12,21 @@ /* The ft_strlcpy function copies up to dst size - 1 (we remove 1 because * of the null-terminator)characters from the string src to dst, - * NUL-terminating the result if dstsize is not 0. + * NUL-terminating the result if size is not 0. * It ensures that the resulting string will always be NUL-terminated. * The size of the source string is returned. * Return the size of the source string */ #include "libft.h" -size_t ft_strlcpy(char *dst, const char *src, size_t dstsize) +size_t ft_strlcpy(char *dst, const char *src, size_t size) { size_t i; i = 0; - if (dstsize > 0) + if (size > 0) { - while (src[i] && i < dstsize - 1) + while (src[i] && i < size - 1) { dst[i] = src[i]; i++;