Skip to content

Commit 03869a6

Browse files
done most of work
1 parent 3a54856 commit 03869a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1232
-829
lines changed

Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: alyildiz <[email protected]> +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2023/05/06 08:32:50 by alyildiz #+# #+# #
9+
# Updated: 2023/05/06 08:32:54 by alyildiz ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
13+
SRCS = ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c \
14+
ft_isprint.c ft_strlen.c ft_memset.c ft_bzero.c \
15+
ft_memcpy.c ft_memmove.c ft_strlcpy.c ft_strlcat.c \
16+
ft_toupper.c ft_tolower.c ft_strchr.c ft_strrchr.c ft_strncmp.c \
17+
ft_memchr.c ft_memcmp.c ft_strnstr.c ft_atoi.c \
18+
ft_calloc.c ft_strdup.c ft_substr.c ft_strjoin.c \
19+
ft_strtrim.c ft_split.c ft_itoa.c ft_strmapi.c \
20+
ft_putchar_fd.c ft_putstr_fd.c \
21+
ft_putendl_fd.c ft_putnbr_fd.c ft_striteri.c \
22+
23+
OBJS = $(SRCS:.c=.o)
24+
25+
BONUS = ft_lstnew.c ft_lstadd_front.c ft_lstsize.c ft_lstlast.c \
26+
ft_lstadd_back.c ft_lstdelone.c ft_lstclear.c ft_lstiter.c \
27+
ft_lstmap.c
28+
29+
BONUS_OBJS = $(BONUS:.c=.o)
30+
31+
CC = gcc
32+
RM = rm -f
33+
CFLAGS = -Wall -Wextra -Werror -I.
34+
35+
NAME = libft.a
36+
37+
all: $(NAME)
38+
39+
$(NAME): $(OBJS)
40+
ar rcs $(NAME) $(OBJS)
41+
42+
clean:
43+
$(RM) $(OBJS) $(BONUS_OBJS)
44+
45+
fclean: clean
46+
$(RM) $(NAME)
47+
48+
re: fclean $(NAME)
49+
50+
bonus: $(BONUS_OBJS)
51+
ar rcs $(NAME) $(BONUS_OBJS)
52+
53+
.PHONY: all clean fclean re bonus

ft_atoi.c

+36-25
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_atoi.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 06:59:36 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:02:01 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_atoi(char *str)
15+
int ft_atoi(const char *str)
416
{
5-
int i;
6-
int sign;
7-
int base;
17+
int i;
18+
int sign;
19+
long long base;
820

9-
i = 0;
10-
sign = 1;
11-
base = 0;
12-
while ((str[i] >= '\t' && str[i] <= '\r') || (str[i] == ' '))
13-
{
14-
i += 1;
15-
}
16-
while (str[i] == '+' || str[i] == '-')
17-
{
18-
if (str[i] == '-')
19-
{
20-
sign *= -1;
21-
}
22-
i++;
23-
}
24-
while (str[i] >= '0' && str[i] <= '9')
25-
{
26-
base = base * 10 + (str[i] - '0');
27-
i++;
28-
}
29-
return (base * sign);
21+
i = 0;
22+
sign = 1;
23+
base = 0;
24+
while ((str[i] >= '\t' && str[i] <= '\r') || (str[i] == ' '))
25+
{
26+
i += 1;
27+
}
28+
if (str[i] == '+' || str[i] == '-')
29+
{
30+
if (str[i] == '-')
31+
sign *= -1;
32+
i++;
33+
}
34+
while (str[i] >= '0' && str[i] <= '9'
35+
&& base < 2147483647 && base > -2147483648)
36+
{
37+
base = base * 10 + (str[i] - '0');
38+
i++;
39+
}
40+
return (base * sign);
3041
}

ft_bzero.c

+23-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_bzero.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 07:06:55 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:07:27 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
void ft_bzero(void *str, size_t n)
15+
void ft_bzero(void *str, size_t n)
416
{
5-
size_t i;
6-
char *str_ptr;
17+
size_t i;
18+
char *str_ptr;
719

8-
i = 0;
9-
// convert void pointers into char pointers
10-
str_ptr = (char *)str;
11-
while (i < n)
12-
{
13-
str_ptr[i] = '\0';
14-
i++;
15-
}
16-
}
20+
i = 0;
21+
str_ptr = (char *)str;
22+
while (i < n)
23+
{
24+
str_ptr[i] = '\0';
25+
i++;
26+
}
27+
}

ft_calloc.c

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_calloc.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 07:21:22 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:21:51 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
void *ft_calloc(size_t elementCount, size_t elementSize)
15+
void *ft_calloc(size_t count, size_t size)
416
{
5-
char *tab;
6-
size_t total;
7-
8-
total = elementCount * elementSize;
9-
tab = malloc(total);
10-
if (tab == NULL)
11-
return (0x0);
12-
ft_memset(tab, 0, elementCount);
13-
return total;
14-
}
17+
void *tab;
18+
size_t total;
1519

20+
tab = NULL;
21+
total = (count * size);
22+
if (count != 0 && ((count * size) / count != size))
23+
return (NULL);
24+
tab = malloc(total);
25+
if (tab == NULL)
26+
return (NULL);
27+
ft_memset(tab, 0, total);
28+
return (tab);
29+
}

ft_isalnum.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isalnum.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 07:14:23 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:15:13 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_isalnum(int chr)
15+
int ft_isalnum(int chr)
416
{
5-
if ((chr >= 0b1100001 && chr <= 0b1111010) || (chr >= 0b1000001 && chr <= 0b1011010) || (chr >= 0b0110000 && chr <= 0b0111001))
6-
return (1);
7-
return (0);
17+
if ((chr >= 0b1100001 && chr <= 0b1111010)
18+
|| (chr >= 0b1000001 && chr <= 0b1011010)
19+
|| (chr >= 0b0110000 && chr <= 0b0111001))
20+
return (1);
21+
return (0);
822
}

ft_isalpha.c

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isalpha.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 06:53:23 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 06:55:16 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_isalpha(int chr)
15+
int ft_isalpha(int chr)
416
{
5-
if ((chr >= 0b1100001 && chr <= 0b1111010) || (chr >= 0b1000001 && chr <= 0b1011010))
6-
return (1);
7-
return (0);
8-
}
17+
if ((chr >= 0b1100001 && chr <= 0b1111010)
18+
|| (chr >= 0b1000001 && chr <= 0b1011010))
19+
return (1);
20+
return (0);
21+
}

ft_isascii.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isascii.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 06:57:33 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 06:57:46 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_isascii(int chr)
15+
int ft_isascii(int chr)
416
{
5-
if (chr >= 0b0000000 && chr <= 0b1111111)
6-
return (1);
7-
return (0);
8-
}
17+
if (chr >= 0b0000000 && chr <= 0b1111111)
18+
return (1);
19+
return (0);
20+
}

ft_isdigit.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isdigit.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 07:12:56 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:13:10 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_isdigit(int chr)
15+
int ft_isdigit(int chr)
416
{
5-
if (chr >= 0b0110000 && chr <= 0b0111001)
6-
return (1);
7-
return (0);
8-
}
17+
if (chr >= 0b0110000 && chr <= 0b0111001)
18+
return (1);
19+
return (0);
20+
}

ft_isprint.c

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* ft_isprint.c :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: alyildiz <[email protected]> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2023/05/06 07:10:43 by alyildiz #+# #+# */
9+
/* Updated: 2023/05/06 07:10:44 by alyildiz ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
113
#include "libft.h"
214

3-
int ft_isprint(int chr)
15+
int ft_isprint(int chr)
416
{
5-
if (chr >= 0b0100000 && chr <= 0b1111110)
6-
return (1);
7-
return (0);
8-
}
17+
if (chr >= 0b0100000 && chr <= 0b1111110)
18+
return (1);
19+
return (0);
20+
}

0 commit comments

Comments
 (0)