From 9d14f83efb750fa91558144139685f7e89d49195 Mon Sep 17 00:00:00 2001
From: Anonymus Raccoon
Date: Mon, 27 Apr 2020 11:22:51 +0200
Subject: [PATCH] Removing the lib my
---
Makefile | 8 +-
include/my.h | 70 -------------
include/utility.h | 19 ++++
lib/my/Makefile | 100 -------------------
lib/my/includes/my.h | 58 -----------
lib/my/sources/my_arrlen.c | 15 ---
lib/my/sources/my_atoi.c | 62 ------------
lib/my/sources/my_compute_power_rec.c | 19 ----
lib/my/sources/my_compute_square_root.c | 29 ------
lib/my/sources/my_find_prime_sup.c | 35 -------
lib/my/sources/my_get_digit.c | 15 ---
lib/my/sources/my_getnbr.c | 26 -----
lib/my/sources/my_getnbr_base.c | 41 --------
lib/my/sources/my_is_prime.c | 24 -----
lib/my/sources/my_isneg.c | 19 ----
lib/my/sources/my_put_nbr.c | 26 -----
lib/my/sources/my_putchar.c | 13 ---
lib/my/sources/my_putnbr_base.c | 44 ---------
lib/my/sources/my_putnbr_base_long.c | 26 -----
lib/my/sources/my_putstr.c | 16 ---
lib/my/sources/my_putstr_e.c | 28 ------
lib/my/sources/my_realloc.c | 25 -----
lib/my/sources/my_revstr.c | 32 ------
lib/my/sources/my_show_word_array.c | 18 ----
lib/my/sources/my_showmem.c | 13 ---
lib/my/sources/my_showstr.c | 12 ---
lib/my/sources/my_sort_int_array.c | 19 ----
lib/my/sources/my_str_is_alphanum.c | 22 -----
lib/my/sources/my_str_isalpha.c | 28 ------
lib/my/sources/my_str_islower.c | 27 -----
lib/my/sources/my_str_isnum.c | 20 ----
lib/my/sources/my_str_isprintable.c | 27 -----
lib/my/sources/my_str_isupper.c | 27 -----
lib/my/sources/my_str_to_word_array.c | 46 ---------
lib/my/sources/my_strcapitalize.c | 55 -----------
lib/my/sources/my_strcat.c | 19 ----
lib/my/sources/my_strchr.c | 16 ---
lib/my/sources/my_strcmp.c | 28 ------
lib/my/sources/my_strcpy.c | 21 ----
lib/my/sources/my_strdup.c | 22 -----
lib/my/sources/my_strlen.c | 15 ---
lib/my/sources/my_strlowcase.c | 16 ---
lib/my/sources/my_strncat.c | 24 -----
lib/my/sources/my_strncmp.c | 29 ------
lib/my/sources/my_strncpy.c | 23 -----
lib/my/sources/my_strstr.c | 26 -----
lib/my/sources/my_strupcase.c | 16 ---
lib/my/sources/my_swap.c | 17 ----
lib/my/sources/printf.c | 114 ----------------------
main.c | 9 +-
src/args.c | 2 +-
src/builtin/builtin_env.c | 10 +-
src/builtin/builtin_manager.c | 6 +-
src/env.c | 16 +--
src/execute.c | 8 +-
src/prompt.c | 7 +-
src/redirections/redirection_manager.c | 9 +-
src/redirections/redirection_validator.c | 15 +--
src/redirections/redirections.c | 2 +-
src/redirections/redirections_functions.c | 13 +--
src/shell.c | 5 +-
src/signal.c | 10 +-
src/utility/catpath.c | 13 +--
src/{ => utility}/same_var.c | 0
src/utility/split_str.c | 6 +-
src/utility/to_array.c | 6 +-
tests/tcd.c | 2 +-
tests/tenv.c | 2 +-
tests/tester/tests | 6 +-
69 files changed, 97 insertions(+), 1500 deletions(-)
delete mode 100644 include/my.h
create mode 100644 include/utility.h
delete mode 100644 lib/my/Makefile
delete mode 100644 lib/my/includes/my.h
delete mode 100644 lib/my/sources/my_arrlen.c
delete mode 100644 lib/my/sources/my_atoi.c
delete mode 100755 lib/my/sources/my_compute_power_rec.c
delete mode 100755 lib/my/sources/my_compute_square_root.c
delete mode 100755 lib/my/sources/my_find_prime_sup.c
delete mode 100644 lib/my/sources/my_get_digit.c
delete mode 100755 lib/my/sources/my_getnbr.c
delete mode 100644 lib/my/sources/my_getnbr_base.c
delete mode 100755 lib/my/sources/my_is_prime.c
delete mode 100755 lib/my/sources/my_isneg.c
delete mode 100755 lib/my/sources/my_put_nbr.c
delete mode 100755 lib/my/sources/my_putchar.c
delete mode 100644 lib/my/sources/my_putnbr_base.c
delete mode 100644 lib/my/sources/my_putnbr_base_long.c
delete mode 100755 lib/my/sources/my_putstr.c
delete mode 100644 lib/my/sources/my_putstr_e.c
delete mode 100755 lib/my/sources/my_realloc.c
delete mode 100755 lib/my/sources/my_revstr.c
delete mode 100644 lib/my/sources/my_show_word_array.c
delete mode 100755 lib/my/sources/my_showmem.c
delete mode 100644 lib/my/sources/my_showstr.c
delete mode 100755 lib/my/sources/my_sort_int_array.c
delete mode 100644 lib/my/sources/my_str_is_alphanum.c
delete mode 100755 lib/my/sources/my_str_isalpha.c
delete mode 100755 lib/my/sources/my_str_islower.c
delete mode 100755 lib/my/sources/my_str_isnum.c
delete mode 100755 lib/my/sources/my_str_isprintable.c
delete mode 100755 lib/my/sources/my_str_isupper.c
delete mode 100644 lib/my/sources/my_str_to_word_array.c
delete mode 100755 lib/my/sources/my_strcapitalize.c
delete mode 100755 lib/my/sources/my_strcat.c
delete mode 100644 lib/my/sources/my_strchr.c
delete mode 100755 lib/my/sources/my_strcmp.c
delete mode 100755 lib/my/sources/my_strcpy.c
delete mode 100644 lib/my/sources/my_strdup.c
delete mode 100755 lib/my/sources/my_strlen.c
delete mode 100755 lib/my/sources/my_strlowcase.c
delete mode 100755 lib/my/sources/my_strncat.c
delete mode 100755 lib/my/sources/my_strncmp.c
delete mode 100755 lib/my/sources/my_strncpy.c
delete mode 100755 lib/my/sources/my_strstr.c
delete mode 100755 lib/my/sources/my_strupcase.c
delete mode 100755 lib/my/sources/my_swap.c
delete mode 100644 lib/my/sources/printf.c
rename src/{ => utility}/same_var.c (100%)
diff --git a/Makefile b/Makefile
index 13d644e..5211efb 100644
--- a/Makefile
+++ b/Makefile
@@ -16,9 +16,9 @@ SRC = src/shell.c \
src/args.c \
src/builtin/builtin_manager.c \
src/builtin/builtin_env.c \
- src/same_var.c \
src/signal.c \
src/free_env.c \
+ src/utility/same_var.c \
src/utility/tostr.c \
src/utility/envvar_is_valid.c \
src/utility/to_array.c \
@@ -45,16 +45,14 @@ INCLUDE = -I ./include
CFLAGS = $(INCLUDE) -Wall -Wextra -Wshadow
-LDFLAGS = -L lib/my -lmy
+LDFLAGS =
all: $(NAME)
$(NAME): $(OBJ)
- $(MAKE) -C lib/my
$(CC) -o $(NAME) $(OBJ) $(LDFLAGS)
tests_run: clean
- $(MAKE) -C lib/my
$(CC) -o $(UT) $(TESTS) $(SRC) $(COVERAGE) $(CFLAGS) $(LDFLAGS)
$(UT)
@@ -63,12 +61,10 @@ func: all
rm tests/tester/mysh
clean:
- $(MAKE) -C lib/my clean
$(RM) $(OBJ)
$(RM) *.gc*
fclean: clean
- $(MAKE) -C lib/my fclean
$(RM) $(NAME)
$(RM) $(UT)
diff --git a/include/my.h b/include/my.h
deleted file mode 100644
index 5309c6e..0000000
--- a/include/my.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** task01
-** File description:
-** day10
-*/
-
-#ifndef _MY_H_
-#define _MY_H_
-
-#include
-#include
-
-char *same_var(char *str, const char *to_find);
-char **to_array(char *str);
-char *catpath(char *p1, char *p2);
-char **split_str(char *str, char delim);
-int count_str(char *str, char *delim);
-char *tostr(int n);
-void *my_realloc(void *oldptr, size_t oldsize, size_t newsize);
-
-void my_putchar(char c);
-int my_isneg(int nb);
-int my_put_nbr(int nb);
-void my_swap(int *a, int *b);
-int my_putstr(char const *str);
-int my_strlen(char const *str);
-int my_getnbr(char const *str);
-void my_sort_int_array(int *tab, int *size);
-int my_compute_power_rec(int nb, int power);
-int my_compute_square_root(int nb);
-int my_is_prime(int nb);
-int my_find_prime_sup(int nb);
-char *my_strcpy(char *dest, char const *src);
-char *my_strncpy(char *dest, char const *src, int n);
-char *my_revstr(char *str);
-char *my_strstr(char *str, char const *to_find);
-int my_strcmp(char const *s1, char const *s2);
-int my_strncmp(char const *s1, char const *s2, int n);
-char *my_strupcase(char *str);
-char *my_strlowcase(char *str);
-char *my_strcapitalize(char *str);
-int my_str_isalpha(char const *str);
-int my_str_isnum(char const *str);
-int my_str_islower(char const *str);
-int my_str_isupper(char const *str);
-int my_str_isprintable(char const *str);
-int my_showstr(char const *str);
-int my_showmem(char const *str);
-char *my_strcat(char *dest, char const *src);
-char *my_strncat(char *dest, char const *src, int nb);
-int my_show_word_array(char * const *tab);
-char *my_strdup(char const *str);
-char **my_str_to_word_array(char const *str);
-int sum_stdarg(int mode, int nb, ...);
-int disp_stdarg(char *s, ...);
-int my_getnbr_base(char const *str, char const *base);
-int my_putnbr_base(int nbr, char const *base);
-int my_putnbr_base_long(unsigned long long int nbr, char const *base);
-void my_putstr_e(char *str);
-int my_printf(char *format, ...);
-int my_arrlen(void **arr);
-int my_get_digit(int nb);
-int my_str_is_alphanum(const char *str);
-char *my_strchr(char *str, char c);
-int my_atoi(const char *str);
-bool is_alpha(char c);
-bool is_num(char c);
-
-#endif
\ No newline at end of file
diff --git a/include/utility.h b/include/utility.h
new file mode 100644
index 0000000..314f3a8
--- /dev/null
+++ b/include/utility.h
@@ -0,0 +1,19 @@
+/*
+** EPITECH PROJECT, 2020
+** ash
+** File description:
+** utility
+*/
+
+#pragma once
+
+#include
+
+char *catpath(char *p1, char *p2);
+char **to_array(char *str);
+char *tostr(int n);
+bool is_alpha(char c);
+bool envvar_is_valid(const char *str);
+int count_str(char *str, char *delim);
+char **split_str(char *str, char delim);
+char *same_var(char *str, const char *to_find);
diff --git a/lib/my/Makefile b/lib/my/Makefile
deleted file mode 100644
index 47ed986..0000000
--- a/lib/my/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-##
-## EPITECH PROJECT, 2019
-## libmy
-## File description:
-## makefile libmy
-##
-
-NAME = libmy.a
-
-SRC = sources/my_compute_power_rec.c \
- sources/my_compute_square_root.c \
- sources/my_find_prime_sup.c \
- sources/my_getnbr.c \
- sources/my_getnbr_base.c \
- sources/my_isneg.c \
- sources/my_is_prime.c \
- sources/my_putchar.c \
- sources/my_put_nbr.c \
- sources/my_putnbr_base.c \
- sources/my_putstr.c \
- sources/my_revstr.c \
- sources/my_showmem.c \
- sources/my_showstr.c \
- sources/my_show_word_array.c \
- sources/my_sort_int_array.c \
- sources/my_strcapitalize.c \
- sources/my_strcat.c \
- sources/my_strcmp.c \
- sources/my_strcpy.c \
- sources/my_str_isalpha.c \
- sources/my_str_islower.c \
- sources/my_str_isnum.c \
- sources/my_str_isprintable.c \
- sources/my_str_isupper.c \
- sources/my_strlen.c \
- sources/my_strlowcase.c \
- sources/my_strncat.c \
- sources/my_strncmp.c \
- sources/my_strncpy.c \
- sources/my_strstr.c \
- sources/my_str_to_word_array.c \
- sources/my_strupcase.c \
- sources/my_swap.c \
- sources/my_strdup.c \
- sources/my_putstr_e.c \
- sources/printf.c \
- sources/my_putnbr_base_long.c \
- sources/my_putstr_e.c \
- sources/my_arrlen.c \
- sources/my_get_digit.c \
- sources/my_realloc.c \
- sources/my_str_is_alphanum.c \
- sources/my_strchr.c \
- sources/my_atoi.c
-
-OBJ = $(SRC:%.c=%.o)
-
-TESTS = tests/test_my_printf.c \
-
-SRC_TEST = sources/my_putnbr_base_long.c \
- sources/my_putstr.c \
- sources/my_put_nbr.c \
- sources/my_putstr_e.c \
- sources/printf.c \
- sources/my_putchar.c \
- sources/my_putnbr_base.c \
- sources/my_strlen.c \
-
-INCLUDE = -I ./include
-
-COVERAGE = --coverage -lcriterion
-
-CFLAGS = -W -Wall -Wextra -Wshadow
-
-CC = gcc
-
-NAME_TEST = unit_tests
-
-all : $(NAME)
-
-$(NAME) : $(OBJ)
- $(AR) rc $(NAME) $(OBJ)
-
-clean :
- $(RM) $(OBJ)
-
-fclean : clean
- $(RM) $(NAME)
- $(RM) *.gc*
- $(RM) $(NAME_TEST)
-
-re : fclean all
-
-dbg: CFLAGS += -g
-dbg: re
-
-tests_run :
- $(RM) *.gc*
- $(CC) -o $(NAME_TEST) $(SRC_TEST) $(TESTS) $(INCLUDE) $(COVERAGE) $(CFLAGS)
- ./unit_tests
diff --git a/lib/my/includes/my.h b/lib/my/includes/my.h
deleted file mode 100644
index 231db14..0000000
--- a/lib/my/includes/my.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** task01
-** File description:
-** day10
-*/
-
-#ifndef _MY_H_
-#define _MY_H_
-
-void my_putchar(char c);
-int my_isneg(int nb);
-int my_put_nbr(int nb);
-void my_swap(int *a, int *b);
-int my_putstr(char const *str);
-int my_strlen(char const *str);
-int my_getnbr(char const *str);
-void my_sort_int_array(int *tab, int *size);
-int my_compute_power_rec(int nb, int power);
-int my_compute_square_root(int nb);
-int my_is_prime(int nb);
-int my_find_prime_sup(int nb);
-char *my_strcpy(char *dest, char const *src);
-char *my_strncpy(char *dest, char const *src, int n);
-char *my_revstr(char *str);
-char *my_strstr(char *str, char const *to_find);
-int my_strcmp(char const *s1, char const *s2);
-int my_strncmp(char const *s1, char const *s2, int n);
-char *my_strupcase(char *str);
-char *my_strlowcase(char *str);
-char *my_strcapitalize(char *str);
-int my_str_isalpha(char const *str);
-int my_str_isnum(char const *str);
-int my_str_islower(char const *str);
-int my_str_isupper(char const *str);
-int my_str_isprintable(char const *str);
-int my_showstr(char const *str);
-int my_showmem(char const *str);
-char *my_strcat(char *dest, char const *src);
-char *my_strncat(char *dest, char const *src, int nb);
-int my_show_word_array(char * const *tab);
-char *my_strdup(char const *str);
-char **my_str_to_word_array(char const *str);
-int sum_stdarg(int mode, int nb, ...);
-int disp_stdarg(char *s, ...);
-int my_getnbr_base(char const *str, char const *base);
-int my_putnbr_base(int nbr, char const *base);
-int my_putnbr_base_long(unsigned long long int nbr, char const *base);
-void my_putstr_e(char *str);
-int my_printf(char *format, ...);
-int my_arrlen(void **arr);
-int my_get_digit(int nb);
-void *my_realloc(char *ptr, int size, int newsize);
-int my_str_is_alphanum(const char *str);
-char *my_strchr(char *str, char c);
-int my_atoi(const char *str);
-
-#endif
\ No newline at end of file
diff --git a/lib/my/sources/my_arrlen.c b/lib/my/sources/my_arrlen.c
deleted file mode 100644
index 34c9189..0000000
--- a/lib/my/sources/my_arrlen.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** task1 day13
-** File description:
-** none
-*/
-
-int my_arrlen(void **arr)
-{
- int i = 0;
-
- while (arr[i])
- i++;
- return (i);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_atoi.c b/lib/my/sources/my_atoi.c
deleted file mode 100644
index b5dcb28..0000000
--- a/lib/my/sources/my_atoi.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** CPool_Day04_2019
-** File description:
-** Int parser
-*/
-
-static int parse(const char *str, int digit_count, int neg)
-{
- int n = 0;
- int add;
- for (int power = 0; power < digit_count; power++) {
- add = str[digit_count - power - 1] - '0';
- if (power == 10 && add > 2)
- return 0;
- add *= neg;
- for (int i = 0; i < power; i++) {
- add *= 10;
- if (add * neg < 0)
- return 0;
- }
- n += add;
- if ((neg == -1 && n > 0) || (neg == 1 && n < 0))
- return 0;
- }
- return n;
-}
-
-static int init_print(const char *str, int count, int s_index)
-{
- int neg = 1;
-
- for (char c = str[s_index]; c == '-' || c == '+'; c = str[s_index]) {
- if (c == '-')
- neg *= -1;
- s_index++;
- count--;
- }
- char buf[count];
- for (int i = 0; i < count; i++)
- buf[i] = str[s_index + i];
- return parse(buf, count, neg);
-}
-
-int my_atoi(const char *str)
-{
- int count = 0;
- int start_index = -1;
- char c;
-
- for (int i = 0; 1; i++) {
- c = str[i];
- if ((c >= '0' && c <= '9') || c == '-' || c == '+') {
- if (start_index == -1)
- start_index = i;
- count++;
- }
- else if (count > 0 || c == '\0')
- break;
- }
- return init_print(str, count, start_index);
-}
diff --git a/lib/my/sources/my_compute_power_rec.c b/lib/my/sources/my_compute_power_rec.c
deleted file mode 100755
index 5f764ad..0000000
--- a/lib/my/sources/my_compute_power_rec.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_compute_power_rec
-** File description:
-** task04 day05
-*/
-
-int my_compute_power_rec(int nb, int p)
-{
- if (p < 0)
- return (0);
-
- if (p == 0)
- return (1);
-
- int result = nb * my_compute_power_rec(nb, p-1);
-
- return (result);
-}
diff --git a/lib/my/sources/my_compute_square_root.c b/lib/my/sources/my_compute_square_root.c
deleted file mode 100755
index 070cb48..0000000
--- a/lib/my/sources/my_compute_square_root.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_compute_square_root
-** File description:
-** task05 day05
-*/
-
-int my_compute_square_root(int nb)
-{
- if (nb <= 0)
- return (0);
- if (nb == 1)
- return (1);
-
- int power = 1;
- int rpower = 1;
-
- while (rpower < nb) {
- rpower = power*power;
- power++;
- }
-
- if (rpower == nb) {
- return (power - 1);
- }
- else {
- return (0);
- }
-}
diff --git a/lib/my/sources/my_find_prime_sup.c b/lib/my/sources/my_find_prime_sup.c
deleted file mode 100755
index 0941704..0000000
--- a/lib/my/sources/my_find_prime_sup.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_find_prime_sup
-** File description:
-** task07 day05
-*/
-static int my_is_prime_spec(int nb);
-
-int my_find_prime_sup(int nb)
-{
- if (nb <= 1)
- return (2);
-
- while (my_is_prime_spec(nb) == 0) {
- nb++;
- }
- return (nb);
-}
-
-static int my_is_prime_spec(int nb)
-{
- int s;
- if (nb < 2)
- return (0);
- if (nb == 2)
- return (1);
- for (int i = 0; i * i <= nb; i++) {
- s = i;
- }
- for (int j = 2; j < s + 1; j++) {
- if (nb % j == 0)
- return (0);
- }
- return (1);
-}
diff --git a/lib/my/sources/my_get_digit.c b/lib/my/sources/my_get_digit.c
deleted file mode 100644
index 09ad870..0000000
--- a/lib/my/sources/my_get_digit.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** get_my_digit
-** File description:
-** dedefee
-*/
-
-int my_get_digit(int nb)
-{
- int count = 1;
-
- for (int i = 10; nb / i != 0; i *= 10)
- count++;
- return (count);
-}
diff --git a/lib/my/sources/my_getnbr.c b/lib/my/sources/my_getnbr.c
deleted file mode 100755
index 714f4be..0000000
--- a/lib/my/sources/my_getnbr.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_getnbr
-** File description:
-** Task05 Day04
-*/
-
-int my_getnbr(char const *str)
-{
- int ret = 0;
- int flag = 1;
-
- for (int i = 0; str[i] && str[i] != '\n'; i++) {
- ret *= 10;
- if (!(str[i] >= '0' && str[i] <= '9') && str[i] != '-')
- return (0);
- if (str[i] == '-' && i == 0) {
- flag = -1;
- continue;
- }
- else if (str[i] == '-')
- return (0);
- ret += str[i] - 48;
- }
- return (ret * flag);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_getnbr_base.c b/lib/my/sources/my_getnbr_base.c
deleted file mode 100644
index b714ba3..0000000
--- a/lib/my/sources/my_getnbr_base.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_getnbr_base
-** File description:
-** task19 day06 int nb = my_strlen(str) - 1;
-*/
-
-int my_strlen(char const *str);
-int my_compute_power_rec(int nb, int power);
-void my_put_nbr(int s);
-void my_putchar(char c);
-
-static int find_index(char str, char const *base)
-{
- for (int i = 0; base[i] != '\0'; i++) {
- if (str == base[i]) {
- return (i);
- }
- }
- return (-1);
-}
-
-int my_getnbr_base(char const *str, char const *base)
-{
- int sum = 0;
- int i = 0;
- int index;
- int powerneed = my_strlen(str) - 1;
- int basebase = my_strlen(base);
- while (str[i] != '\0') {
- if (str[i] == '-' && str[0] == '-') {
- my_putchar('-');
- }
- else {
- index = find_index(str[i], base);
- sum += (index * my_compute_power_rec(basebase, powerneed - i));
- }
- i++;
- }
- return (sum);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_is_prime.c b/lib/my/sources/my_is_prime.c
deleted file mode 100755
index 8917a86..0000000
--- a/lib/my/sources/my_is_prime.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_is_prime
-** File description:
-** task06 day05
-*/
-
-int my_is_prime(int nb)
-{
- int s = 0;
-
- if (nb < 2)
- return (0);
- if (nb == 2)
- return (1);
- for (int i = 0; i * i <= nb; i++) {
- s = i;
- }
- for (int j = 2; j < s + 1; j++) {
- if (nb % j == 0)
- return (0);
- }
- return (1);
-}
diff --git a/lib/my/sources/my_isneg.c b/lib/my/sources/my_isneg.c
deleted file mode 100755
index db6f12b..0000000
--- a/lib/my/sources/my_isneg.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_isneg
-** File description:
-** task04 day03
-*/
-
-void my_putchar(char c);
-
-int my_isneg(int n)
-{
- if (n > -1) {
- my_putchar('P');
- }
- else {
- my_putchar('N');
- }
- return (0);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_put_nbr.c b/lib/my/sources/my_put_nbr.c
deleted file mode 100755
index 8393c83..0000000
--- a/lib/my/sources/my_put_nbr.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_put_nbr
-** File description:
-** task07 day03
-*/
-
-void my_putchar(char c);
-
-int my_put_nbr(int nb)
-{
- long lnb = nb;
-
- if (lnb < 0) {
- my_putchar('-');
- lnb = lnb * -1;
- }
- if (lnb >= 10) {
- my_put_nbr(lnb / 10);
- my_put_nbr(lnb % 10);
- }
- else {
- my_putchar(lnb + '0');
- }
- return (0);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_putchar.c b/lib/my/sources/my_putchar.c
deleted file mode 100755
index 892a66c..0000000
--- a/lib/my/sources/my_putchar.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_putchar
-** File description:
-** fct base
-*/
-
-#include
-
-void my_putchar(char c)
-{
- write(1, &c, 1);
-}
diff --git a/lib/my/sources/my_putnbr_base.c b/lib/my/sources/my_putnbr_base.c
deleted file mode 100644
index f8c6c18..0000000
--- a/lib/my/sources/my_putnbr_base.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_putnbr_base
-** File description:
-** task18 day6
-*/
-
-void my_putchar(char c);
-int my_strlen(char const *str);
-
-#include
-
-int max_index_of_base(char const *base)
-{
- int inc = 0;
-
- for (int i = 0; base[i] != '\0'; i++) {
- inc++;
- }
- return (inc);
-}
-
-void print(int result, char const *base)
-{
- my_putchar(base[result]);
-}
-
-int my_putnbr_base(int nbr, char const *base)
-{
- if (nbr < 0) {
- my_putchar('-');
- nbr = nbr * -1;
- }
-
- if (nbr == 0) {
- return (0);
- }
-
- int divider = my_strlen(base);
-
- my_putnbr_base(nbr / divider, base);
- print(nbr % divider, base);
- return (0);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_putnbr_base_long.c b/lib/my/sources/my_putnbr_base_long.c
deleted file mode 100644
index 2144d67..0000000
--- a/lib/my/sources/my_putnbr_base_long.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** long long int
-** File description:
-** r
-*/
-
-void my_putchar(char c);
-int my_strlen(char const *str);
-int max_index_of_base(char const *base);
-void print(int result, char const *base);
-
-#include
-
-int my_putnbr_base_long(unsigned long int nbr, char const *base)
-{
- if (nbr == 0) {
- return (0);
- }
-
- int divider = my_strlen(base);
-
- my_putnbr_base_long(nbr / divider, base);
- print(nbr % divider, base);
- return (0);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_putstr.c b/lib/my/sources/my_putstr.c
deleted file mode 100755
index d1ae5d1..0000000
--- a/lib/my/sources/my_putstr.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_putstr
-** File description:
-** task02 day04
-*/
-
-#include
-
-int my_strlen(char const *str);
-
-int my_putstr(char const *str)
-{
- write(1, str, my_strlen(str));
- return (0);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_putstr_e.c b/lib/my/sources/my_putstr_e.c
deleted file mode 100644
index d194d2e..0000000
--- a/lib/my/sources/my_putstr_e.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my put str e
-** File description:
-** fe
-*/
-
-#include "../includes/my.h"
-
-void put_zero(char c)
-{
- my_putchar('0');
- if (c < 8)
- my_putchar('0');
-}
-
-void my_putstr_e(char *str)
-{
- for (int i = 0; str[i] != '\0'; i++) {
- if (str[i] >= 32 && str[i] < 127)
- my_putchar(str[i]);
- else {
- my_putchar('\\');
- put_zero(str[i]);
- my_putnbr_base(str[i], "01234567");
- }
- }
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_realloc.c b/lib/my/sources/my_realloc.c
deleted file mode 100755
index 117b38f..0000000
--- a/lib/my/sources/my_realloc.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strstr
-** File description:
-** task05 day06
-*/
-
-#include
-
-void *my_realloc(char *ptr, int size, int newsize)
-{
- char *new_ptr;
-
- if (newsize <= size || newsize < 1 || size <= 0)
- return (ptr);
- new_ptr = malloc(newsize);
- if (!new_ptr)
- return (NULL);
- if (ptr) {
- for (int i = 0; i < size; i++)
- new_ptr[i] = ptr[i];
- free(ptr);
- }
- return ((void *)new_ptr);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_revstr.c b/lib/my/sources/my_revstr.c
deleted file mode 100755
index d706280..0000000
--- a/lib/my/sources/my_revstr.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_revstr
-** File description:
-** task04 day06
-*/
-void my_putchar(char c);
-int my_putstr(char const *str);
-
-static int my_strlen_revstr(char const *str)
-{
- int i = 0;
- while (str[i] != '\0') {
- i++;
- }
- return i;
-}
-
-char *my_revstr(char *str)
-{
- int max = my_strlen_revstr(str);
- int maxcache = (max + 1) / 2;
- char c;
- int i;
- for (i = 0; i < maxcache; i++) {
- c = str[i];
- str[i] = str[max - 1];
- str[max - 1] = c;
- max--;
- }
- return (str);
-}
diff --git a/lib/my/sources/my_show_word_array.c b/lib/my/sources/my_show_word_array.c
deleted file mode 100644
index 9f74a3e..0000000
--- a/lib/my/sources/my_show_word_array.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_show_word_array
-** File description:
-** task03 day08
-*/
-
-int my_putstr(char const *str);
-void my_putchar(char c);
-
-int my_show_word_array(char * const *tab)
-{
- for (int i = 0; tab[i] != 0; i++) {
- my_putstr(tab[i]);
- my_putchar('\n');
- }
- return (0);
-}
diff --git a/lib/my/sources/my_showmem.c b/lib/my/sources/my_showmem.c
deleted file mode 100755
index 8979027..0000000
--- a/lib/my/sources/my_showmem.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_showmem
-** File description:
-** non fonctionnel
-*/
-
-char *my_showmem(char *dest, char const *src)
-{
- (void)dest;
- (void)src;
- return (0);
-}
diff --git a/lib/my/sources/my_showstr.c b/lib/my/sources/my_showstr.c
deleted file mode 100644
index 0fc0ab4..0000000
--- a/lib/my/sources/my_showstr.c
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_showstr
-** File description:
-** non fonctionnel
-*/
-
-int my_showstr(char const *str)
-{
- (void)str;
- return (0);
-}
diff --git a/lib/my/sources/my_sort_int_array.c b/lib/my/sources/my_sort_int_array.c
deleted file mode 100755
index 39ddde2..0000000
--- a/lib/my/sources/my_sort_int_array.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_sort_int_array
-** File description:
-** task06 day04
-*/
-
-void my_sort_int_array(int *array, int size)
-{
- int s;
- for (int i = 0; i <= size; i++) {
- if (array[i] > array[i + 1]) {
- s = array[i];
- array[i] = array[i + 1];
- array[i + 1] = s;
- }
- }
- return;
-}
diff --git a/lib/my/sources/my_str_is_alphanum.c b/lib/my/sources/my_str_is_alphanum.c
deleted file mode 100644
index 547b78c..0000000
--- a/lib/my/sources/my_str_is_alphanum.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** task1 day13
-** File description:
-** none
-*/
-
-int my_str_is_alphanum(const char *str)
-{
- for (int i = 0; str[i]; i++) {
- if (str[i] >= '0' && str[i] <= '9')
- continue;
- if (str[i] >= 'a' && str[i] <= 'z')
- continue;
- if (str[i] >= 'A' && str[i] <= 'Z')
- continue;
- if (str[i] == '_')
- continue;
- return (0);
- }
- return (1);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_str_isalpha.c b/lib/my/sources/my_str_isalpha.c
deleted file mode 100755
index 8c75ef8..0000000
--- a/lib/my/sources/my_str_isalpha.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_isalpha
-** File description:
-** task12 day06
-*/
-
-static int is_allowed_char_alpha(char const *str, int i)
-{
- if ((str[i] >= 'a' && str[i] <= 'z') \
-|| (str[i] >= 'A' && str[i] <= 'Z')) {
- return (1);
- }
- else
- return (0);
-}
-
-int my_str_isalpha(char const *str)
-{
- if (str[0] == '\0')
- return (1);
- for (int i = 0; str[i] != '\0'; i++) {
- if (is_allowed_char_alpha(str, i) == 0) {
- return (0);
- }
- }
- return (1);
-}
diff --git a/lib/my/sources/my_str_islower.c b/lib/my/sources/my_str_islower.c
deleted file mode 100755
index 7283eb5..0000000
--- a/lib/my/sources/my_str_islower.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_islower
-** File description:
-** task14 day06
-*/
-
-static int is_allowed_char_lower(char const *str, int i)
-{
- if ((str[i] >= 'a' && str[i] <= 'z')) {
- return (1);
- }
- else
- return (0);
-}
-
-int my_str_islower(char const *str)
-{
- if (str[0] == '\0')
- return (1);
- for (int i = 0; str[i] != '\0'; i++) {
- if (is_allowed_char_lower(str, i) == 0) {
- return (0);
- }
- }
- return (1);
-}
diff --git a/lib/my/sources/my_str_isnum.c b/lib/my/sources/my_str_isnum.c
deleted file mode 100755
index 4c3f5a6..0000000
--- a/lib/my/sources/my_str_isnum.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_isnum
-** File description:
-** task13 day06
-*/
-
-int my_str_isnum(char const *str)
-{
- if (str[0] == '\0')
- return (1);
- for (int i = 0; str[i] != '\0' && str[i] != '\n'; i++) {
- if (str[0] == '-' && i == 0)
- continue;
- if ((str[i] >= '0' && str[i] <= '9'))
- continue;
- return (0);
- }
- return (1);
-}
diff --git a/lib/my/sources/my_str_isprintable.c b/lib/my/sources/my_str_isprintable.c
deleted file mode 100755
index 9d0e505..0000000
--- a/lib/my/sources/my_str_isprintable.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_isprintable
-** File description:
-** task16 day06
-*/
-
-static int is_allowed_char_printable(char const *str, int i)
-{
- if (str[i] >= ' ' && str[i] != 127) {
- return (1);
- }
- else
- return (0);
-}
-
-int my_str_isprintable(char const *str)
-{
- if (str[0] == '\0')
- return (1);
- for (int i = 0; str[i] != '\0'; i++) {
- if (is_allowed_char_printable(str, i) == 0) {
- return (0);
- }
- }
- return (1);
-}
diff --git a/lib/my/sources/my_str_isupper.c b/lib/my/sources/my_str_isupper.c
deleted file mode 100755
index ca4f2d7..0000000
--- a/lib/my/sources/my_str_isupper.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_isupper
-** File description:
-** task15 day06
-*/
-
-static int is_allowed_char_upper(char const *str, int i)
-{
- if ((str[i] >= 'A' && str[i] <= 'Z')) {
- return (1);
- }
- else
- return (0);
-}
-
-int my_str_isupper(char const *str)
-{
- if (str[0] == '\0')
- return (1);
- for (int i = 0; str[i] != '\0'; i++) {
- if (is_allowed_char_upper(str, i) == 0) {
- return (0);
- }
- }
- return (1);
-}
diff --git a/lib/my/sources/my_str_to_word_array.c b/lib/my/sources/my_str_to_word_array.c
deleted file mode 100644
index d32bc94..0000000
--- a/lib/my/sources/my_str_to_word_array.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_str_to_word_array
-** File description:
-** task4 day8
-*/
-
-#include
-#include "../includes/my.h"
-
-static char *my_specndup(char const *str, int nb)
-{
- char *ret = malloc(sizeof(char) * (nb + 1));
-
- if (!ret)
- return (NULL);
- for (int i = 0; i < nb && str[i] != '\0'; i++)
- ret[i] = str[i];
- ret[nb] = '\0';
- return (ret);
-}
-
-char **my_str_to_word_array(char const *str)
-{
- int size = my_strlen(str);
- char **ret = malloc(sizeof(char *) * size);
- char const *ptr = str;
- int ret_inc = 0;
- char *new;
-
- for (int i = 0, inc = 1; i <= size; i++, inc++) {
- if (str[i] >= 33 && str[i] <= 126)
- continue;
- if (inc == 1) {
- ptr = str + i + 1;
- inc = 0;
- continue;
- }
- new = my_specndup(ptr, inc - 1);
- ret[ret_inc++] = new;
- ptr = str + i + 1;
- inc = 0;
- }
- ret[ret_inc] = NULL;
- return (ret);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_strcapitalize.c b/lib/my/sources/my_strcapitalize.c
deleted file mode 100755
index 1b8ab80..0000000
--- a/lib/my/sources/my_strcapitalize.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strcapitalize
-** File description:
-** task10 day06
-*/
-
-static int is_previous(char *str, int i, char min, char max)
-{
- if (str[0] >= min && str[0] <= max && i == 0)
- return (0);
- else if (str[i - 1] >= min && str[i - 1] <= max)
- return (1);
- else
- return (0);
-}
-
-static int to_uppercase(char *str, int i)
-{
- int flag = 0;
- int isaz = is_previous(str, i + 1 , 'a', 'z');
- int previousaz = is_previous(str, i, 'a', 'z');
- int previousAZ = is_previous(str, i, 'A', 'Z');
- int previous09 = is_previous(str, i, '0', '9');
-
- if (previousaz == 0 && previousAZ == 0 && previous09 == 0 && isaz == 1) {
- flag = 1;
- }
- return (flag);
-}
-
-static int to_lowercase(char *str, int i)
-{
- int flag = 0;
- int isAZ = is_previous(str, i + 1, 'A', 'Z');
- int previousaz = is_previous(str, i, 'a', 'z');
- int previousAZ = is_previous(str, i, 'A', 'Z');
- int previous09 = is_previous(str, i, '0', '9');
-
- if ((previousaz == 1 || previousAZ == 1 \
- || previous09 == 1) && isAZ == 1)
- flag = 1;
- return (flag);
-}
-
-char *my_strcapitalize(char *str)
-{
- for (int i = 0; str[i] != '\0'; i++) {
- if (to_uppercase(str, i) == 1)
- str[i] = str[i] - 32;
- if (to_lowercase(str, i) == 1)
- str[i] = str[i] + 32;
- }
- return (str);
-}
diff --git a/lib/my/sources/my_strcat.c b/lib/my/sources/my_strcat.c
deleted file mode 100755
index 1bc8e8e..0000000
--- a/lib/my/sources/my_strcat.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** String cat
-** File description:
-** The end of the string.h lib
-*/
-
-int my_strlen(const char *dest);
-
-char *my_strcat(char *dest, const char *src)
-{
- int i;
- int dest_length = my_strlen(dest);
-
- for (i = 0; src[i]; i++)
- dest[dest_length + i] = src[i];
- dest[dest_length + i] = '\0';
- return (dest);
-}
diff --git a/lib/my/sources/my_strchr.c b/lib/my/sources/my_strchr.c
deleted file mode 100644
index 2fe6461..0000000
--- a/lib/my/sources/my_strchr.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** task1 day13
-** File description:
-** none
-*/
-
-#include
-
-char *my_strchr(char *str, char c)
-{
- for (int i = 0; str[i]; i++)
- if (str[i] == c)
- return (str + i);
- return (NULL);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_strcmp.c b/lib/my/sources/my_strcmp.c
deleted file mode 100755
index c912ec8..0000000
--- a/lib/my/sources/my_strcmp.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strcmp
-** File description:
-** task06 day06
-*/
-
-static int find_relation(char const *s1, char const *s2, int i)
-{
- if (s1[i] > s2[i])
- return (1);
- else if (s1[i] < s2[i])
- return (-1);
- else
- return (0);
-}
-
-int my_strcmp(char const *s1, char const *s2)
-{
- int i = 0;
- while ((s1[i] != '\0') || (s2[i] != '\0')) {
- if (s1[i] != s2[i]) {
- return (find_relation(s1, s2, i));
- }
- i++;
- }
- return (0);
-}
diff --git a/lib/my/sources/my_strcpy.c b/lib/my/sources/my_strcpy.c
deleted file mode 100755
index e617ee4..0000000
--- a/lib/my/sources/my_strcpy.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strcpy
-** File description:
-** task01 day06
-*/
-
-char *my_strcpy(char *dest, char const *src)
-{
- int i;
- for (i = 0; src[i] != '\0'; i++) {
- dest[i] = src[i];
- }
- if (i == 0) {
- dest[i] = '\0';
- }
- else {
- dest[i] = '\0';
- }
- return (dest);
-}
diff --git a/lib/my/sources/my_strdup.c b/lib/my/sources/my_strdup.c
deleted file mode 100644
index 524c396..0000000
--- a/lib/my/sources/my_strdup.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strdup
-** File description:
-** task01 day08
-*/
-
-#include
-
-int my_strlen(char const *str);
-
-char *my_strdup(char const *str)
-{
- int i = 0;
- int size = my_strlen(str);
- char *newstr = malloc(sizeof(char) * (size + 1));
- for (i = 0; str[i] != '\0'; i++) {
- newstr[i] = str[i];
- }
- newstr[i] = '\0';
- return (newstr);
-}
diff --git a/lib/my/sources/my_strlen.c b/lib/my/sources/my_strlen.c
deleted file mode 100755
index 4e94223..0000000
--- a/lib/my/sources/my_strlen.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strlen
-** File description:
-** task03 day04
-*/
-
-int my_strlen(char const *str)
-{
- int i = 0;
- while (str[i] != '\0') {
- i++;
- }
- return (i);
-}
\ No newline at end of file
diff --git a/lib/my/sources/my_strlowcase.c b/lib/my/sources/my_strlowcase.c
deleted file mode 100755
index 41466b1..0000000
--- a/lib/my/sources/my_strlowcase.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strlowcase
-** File description:
-** task09 day06
-*/
-
-char *my_strlowcase(char *str)
-{
- for (int i = 0; str[i] != '\0'; i++) {
- if (str[i] >= 'A' && str[i] <= 'Z'){
- str[i] = str[i] + 'a' - 'A';
- }
- }
- return (str);
-}
diff --git a/lib/my/sources/my_strncat.c b/lib/my/sources/my_strncat.c
deleted file mode 100755
index c1d4470..0000000
--- a/lib/my/sources/my_strncat.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strncat
-** File description:
-** task03 day07
-*/
-
-char *my_strncat(char *dest, char const *src, int nb)
-{
- int memo = 0;
-
- for (int i = 0; dest[i] != '\0'; i++) {
- memo = i;
- }
- if (memo != 0)
- memo++;
- for (int b = 0; src[b] != '\0' && b < nb; b++) {
- dest[memo] = src[b];
- memo++;
- }
-
- dest[memo] = '\0';
- return (dest);
-}
diff --git a/lib/my/sources/my_strncmp.c b/lib/my/sources/my_strncmp.c
deleted file mode 100755
index 8ab035e..0000000
--- a/lib/my/sources/my_strncmp.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strncmp
-** File description:
-** task07 day06
-*/
-
-static int find_relation_cmp(char const *s1, char const *s2, int i)
-{
- if (s1[i] > s2[i])
- return (1);
- else if (s1[i] < s2[i])
- return (-1);
- else
- return (0);
-}
-
-int my_strncmp(char const *s1, char const *s2, int n)
-{
- int i = 0;
-
- while (((s1[i] != '\0') || (s2[i] != '\0')) && i < n) {
- if (s1[i] != s2[i]) {
- return (find_relation_cmp(s1, s2, i));
- }
- i++;
- }
- return (0);
-}
diff --git a/lib/my/sources/my_strncpy.c b/lib/my/sources/my_strncpy.c
deleted file mode 100755
index 4c1ee12..0000000
--- a/lib/my/sources/my_strncpy.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strncpy
-** File description:
-** task02 day06
-*/
-
-char *my_strncpy(char *dest, char const *src, int n)
-{
- int mem;
- int i;
-
- for (int k = 0; src[k] != '\0'; k++)
- mem = k;
- if (n > mem)
- n = mem;
- for (i = 0; i <= n; i++) {
- dest[i] = src[i];
- if (src[n] == '\0' && i == n)
- dest[n] = '\0';
- }
- return (dest);
-}
diff --git a/lib/my/sources/my_strstr.c b/lib/my/sources/my_strstr.c
deleted file mode 100755
index b93e9a8..0000000
--- a/lib/my/sources/my_strstr.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** StrStr duplicate
-** File description:
-** A search in string function
-*/
-
-char *my_strstr(char *str, const char *to_find)
-{
- int i;
- int search_index = 0;
-
- for (i = 0; str[i] != '\0'; i++) {
- if (to_find[search_index] == '\0')
- return (str + i - search_index);
- if (str[i] == to_find[search_index])
- search_index++;
- else if (str[i] == to_find[0])
- search_index = 1;
- else
- search_index = 0;
- }
- if (to_find[search_index] == '\0')
- return (str + i - search_index);
- return 0;
-}
diff --git a/lib/my/sources/my_strupcase.c b/lib/my/sources/my_strupcase.c
deleted file mode 100755
index 4efe7e3..0000000
--- a/lib/my/sources/my_strupcase.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_strupcase
-** File description:
-** task08 day06
-*/
-
-char *my_strupcase(char *str)
-{
- for (int i = 0; str[i] != '\0'; i++) {
- if (str[i] >= 'a' && str[i] <= 'z') {
- str[i] = str[i] - 'a' + 'A';
- }
- }
- return (str);
-}
diff --git a/lib/my/sources/my_swap.c b/lib/my/sources/my_swap.c
deleted file mode 100755
index 3e96719..0000000
--- a/lib/my/sources/my_swap.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** my_swap
-** File description:
-** task01 day04
-*/
-
-void my_putchar(char c);
-
-void my_swap(int *a, int *b)
-{
- int cache;
-
- cache = *a;
- *a = *b;
- *b = cache;
-}
\ No newline at end of file
diff --git a/lib/my/sources/printf.c b/lib/my/sources/printf.c
deleted file mode 100644
index 79e09a8..0000000
--- a/lib/my/sources/printf.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-** EPITECH PROJECT, 2019
-** printf
-** File description:
-** dezfgergr
-*/
-
-#include "../includes/my.h"
-#include
-#include
-
-int process_mod_extended(char *format, int i, va_list vl)
-{
- switch (format[i]) {
- case 'x':
- my_putnbr_base_long(va_arg(vl, unsigned long int), "0123456789abcdef");
- break;
- case 'X':
- my_putnbr_base_long(va_arg(vl, unsigned int), "0123456789ABCDEF");
- break;
- case 'S':
- my_putstr_e(va_arg(vl, char *));
- break;
- case 'h':
- if (format[i - 1] == '%')
- my_put_nbr(va_arg(vl, int));
- i++;
- break;
- default:
- my_putstr("%");
- i--;
- }
- return (i);
-}
-
-int process_mod_dlc(char *format, int i, va_list vl)
-{
- switch (format[i]) {
- case 'o':
- my_putnbr_base_long(va_arg(vl, unsigned int), "01234567");
- break;
- case 'u':
- my_putnbr_base_long(va_arg(vl, unsigned int), "0123456789");
- break;
- case 'b':
- my_putnbr_base_long(va_arg(vl, unsigned int), "01");
- break;
- case 'p':
- my_putstr("0x");
- my_putnbr_base_long(va_arg(vl, unsigned long int), "0123456789abcdef");
- break;
- default:
- i = process_mod_extended(format, i, vl);
- }
- return (i);
-}
-
-int process_mod(char *format, int i, va_list vl)
-{
- switch (format[i]) {
- case 'c':
- my_putchar(va_arg(vl, int));
- break;
- case 's':
- my_putstr(va_arg(vl, char *));
- break;
- case 'i':
- case 'd':
- if (format[i - 1] != '%')
- my_putnbr_base_long(va_arg(vl, long int), "0123456789");
- else
- my_put_nbr(va_arg(vl, int));
- break;
- default:
- i = process_mod_dlc(format, i , vl);
- }
- return (i);
-}
-
-int process_all(char *format, int i, va_list vl)
-{
- switch (format[i]) {
- case 'l':
- case 'j':
- case 't':
- case 'z':
- i = process_mod(format, i + 1, vl);
- break;
- default:
- i = process_mod(format, i, vl);
- }
- i++;
- return (i);
-}
-
-int my_printf(char *format, ...)
-{
- va_list vl;
- va_start(vl, format);
-
- for (int i = 0; format[i] != '\0'; i++) {
- if (format[i] == '%')
- i = process_all(format, i + 1, vl);
- if (format[i] == '\0')
- break;
- if (format[i] == '%') {
- i--;
- continue;
- }
- my_putchar(format[i]);
- }
- va_end(vl);
- return (my_strlen(format));
-}
\ No newline at end of file
diff --git a/main.c b/main.c
index 7679a04..b06fabb 100644
--- a/main.c
+++ b/main.c
@@ -6,17 +6,16 @@
*/
#include "shell.h"
-#include "my.h"
+#include
#include
#include
+#include
int get_return(char *ret)
{
if (!ret)
return (0);
- if (!my_str_isnum(ret))
- return (0);
- return (my_getnbr(ret));
+ return (atoi(ret));
}
int main(int argc, char **argv, char **env)
@@ -28,7 +27,7 @@ int main(int argc, char **argv, char **env)
if (!env || !envcp)
return (84);
for (int i = 0; env[i]; i++)
- envcp[i] = my_strdup(env[i]);
+ envcp[i] = strdup(env[i]);
envcp[env_get_length(env)] = NULL;
envt->env = envcp;
envt->vars = NULL;
diff --git a/src/args.c b/src/args.c
index 749b5fa..737eb93 100644
--- a/src/args.c
+++ b/src/args.c
@@ -5,7 +5,7 @@
** args
*/
-#include "my.h"
+
#include
#include
diff --git a/src/builtin/builtin_env.c b/src/builtin/builtin_env.c
index d5ce4ae..0afa7bb 100644
--- a/src/builtin/builtin_env.c
+++ b/src/builtin/builtin_env.c
@@ -7,7 +7,7 @@
#include
#include "shell.h"
-#include "my.h"
+
#include
#include
#include
@@ -16,7 +16,7 @@
int builtin_env(char **argv, env_t *env)
{
for (int i = 0; env->env[i]; i++) {
- write(1, env->env[i], my_strlen(env->env[i]));
+ write(1, env->env[i], strlen(env->env[i]));
write(1, "\n", 1);
}
free(argv);
@@ -27,12 +27,12 @@ int builtin_setenv(char **argv, env_t *env)
{
if (!argv[1])
return (builtin_env(argv, env));
- if (!is_alpha(argv[1][0])) {
+ if ('a' <= argv[1][0] && argv[1][0] <= 'z') {
write(2, "setenv: Variable name must begin with a letter.\n", 49);
return (0);
}
if (!envvar_is_valid(argv[1])) {
- write(2, INVALID_ENV_VAR, my_strlen(INVALID_ENV_VAR));
+ write(2, INVALID_ENV_VAR, strlen(INVALID_ENV_VAR));
return (0);
}
env->env = my_setenv(env->env, argv[1], argv[2]);
@@ -48,7 +48,7 @@ int builtin_unsetenv(char **argv, env_t *env)
return (0);
}
for (int i = 1; argv[i]; i++)
- if (!my_strchr(argv[i], '='))
+ if (!strchr(argv[i], '='))
env->env = my_unsetenv(env->env, argv[i]);
free(argv);
return (0);
diff --git a/src/builtin/builtin_manager.c b/src/builtin/builtin_manager.c
index 647f09b..31bb22d 100644
--- a/src/builtin/builtin_manager.c
+++ b/src/builtin/builtin_manager.c
@@ -8,7 +8,7 @@
#include "shell.h"
#include "builtin.h"
#include "redirections.h"
-#include "my.h"
+
#include
#include
#include
@@ -48,12 +48,12 @@ int builtin_cd(char **argv, env_t *env)
}
if (!argv[1])
path = my_getenv(env->env, "HOME");
- else if (argv[1] && !my_strcmp(argv[1], "-"))
+ else if (argv[1] && !strcmp(argv[1], "-"))
path = my_getenv(env->env, "OLDPWD");
else
path = argv[1];
if (chdir(path) < 0)
- my_printf("%s: %s.\n", path, strerror(errno));
+ printf("%s: %s.\n", path, strerror(errno));
else
env->env = my_setenv(env->env, "OLDPWD", old);
free(old);
diff --git a/src/env.c b/src/env.c
index e011e0b..fb92ea4 100644
--- a/src/env.c
+++ b/src/env.c
@@ -7,7 +7,9 @@
#include
#include
-#include "my.h"
+#include
+#include "utility.h"
+
char *my_getenv(char **env, char *name)
{
@@ -15,22 +17,22 @@ char *my_getenv(char **env, char *name)
return (NULL);
for (int i = 0; env[i]; i++) {
if (same_var(env[i], name) == env[i])
- return (env[i] + my_strlen(name) + 1);
+ return (env[i] + strlen(name) + 1);
}
return (NULL);
}
char *create_envvar(char *name, char *value)
{
- int len = my_strlen(name) + (value ? my_strlen(value) : 0);
+ int len = strlen(name) + (value ? strlen(value) : 0);
char *var = malloc(sizeof(char) * (len + 2));
if (!var)
return (NULL);
- my_strcpy(var, name);
- my_strcat(var, "=");
+ strcpy(var, name);
+ strcat(var, "=");
if (value)
- my_strcat(var, value);
+ strcat(var, value);
return (var);
}
@@ -48,7 +50,7 @@ char **my_setenv(char **env, char *name, char *value)
}
for (i = 0; env && env[i]; i++)
old += sizeof(char *);
- env = my_realloc(env, old, old + sizeof(char *));
+ env = realloc(env, old + sizeof(char *));
if (!env)
return (NULL);
env[i] = create_envvar(name, value);
diff --git a/src/execute.c b/src/execute.c
index bf4a9f6..1f8f0f3 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -15,7 +15,7 @@
#include
#include
#include
-#include "my.h"
+#include "utility.h"
#include "shell.h"
#include "redirections.h"
@@ -37,11 +37,11 @@ char *eval(char *cmd, char **argv, env_t* env)
char **envpath = NULL;
if (pathstr) {
- pathstr = my_strdup(pathstr);
+ pathstr = strdup(pathstr);
if (pathstr)
envpath = to_array(pathstr);
}
- if (my_strchr(cmd, '/') == NULL) {
+ if (strchr(cmd, '/') == NULL) {
if (!envpath)
return (NULL);
for (int i = 0; envpath[i] && !path; i++)
@@ -98,7 +98,7 @@ void run_cmd(char **argv, redirection *inout[2], env_t *env)
int status;
char *path;
- if (my_strlen(argv[0]) == 0)
+ if (strlen(argv[0]) == 0)
return;
pid = fork();
if (pid == 0) {
diff --git a/src/prompt.c b/src/prompt.c
index 68881bd..eb8500c 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -6,12 +6,13 @@
*/
-#include "my.h"
+
#include "shell.h"
#include "builtin.h"
#include "redirections.h"
#include
#include
+#include
const builtin builtins[] = {
{"env", &builtin_env},
@@ -33,7 +34,7 @@ int prompt_run(char *cmd, redirection *inout[2], env_t *env)
if (!argv[0])
return (0);
for (int i = 0; builtins[i].name; i++)
- if (!my_strcmp(argv[0], builtins[i].name))
+ if (!strcmp(argv[0], builtins[i].name))
return (run_builtin(&builtins[i], argv, inout, env));
run_cmd(argv, inout, env);
free(argv);
@@ -47,6 +48,6 @@ void prompt_prepare(env_t *env)
if (isatty(0)) {
if (!prompt)
prompt = "$ ";
- write(1, prompt, my_strlen(prompt));
+ write(1, prompt, strlen(prompt));
}
}
\ No newline at end of file
diff --git a/src/redirections/redirection_manager.c b/src/redirections/redirection_manager.c
index 85edf25..8ea3277 100644
--- a/src/redirections/redirection_manager.c
+++ b/src/redirections/redirection_manager.c
@@ -5,14 +5,15 @@
** redirections
*/
-#include "my.h"
+
#include "shell.h"
#include "redirections.h"
#include
#include
#include
#include
-
+#include
+#include "utility.h"
const redirection_map redirections[] = {
{"|", &get_pipe_fd, &handle_pipe, OUTPUT | PIPE | EX_PIPE},
@@ -26,7 +27,7 @@ const redirection_map redirections[] = {
const redirection_map *get_redirection(char *c)
{
for (int i = 0; redirections[i].key; i++)
- if (!my_strncmp(redirections[i].key, c, my_strlen(redirections[i].key)))
+ if (!strncmp(redirections[i].key, c, strlen(redirections[i].key)))
return (&redirections[i]);
return (NULL);
}
@@ -47,7 +48,7 @@ redirection *split_redirections(char *cmd)
if (!shell_cmd)
continue;
*cmd = '\0';
- cmd += my_strlen(shell_cmd->key);
+ cmd += strlen(shell_cmd->key);
redirection_ctr(&cmds[j++], cmd, shell_cmd);
if (shell_cmd->type & PIPE)
break;
diff --git a/src/redirections/redirection_validator.c b/src/redirections/redirection_validator.c
index 48b97a1..fd8cabb 100644
--- a/src/redirections/redirection_validator.c
+++ b/src/redirections/redirection_validator.c
@@ -5,14 +5,15 @@
** redirection_validator
*/
-#include "my.h"
+
#include "shell.h"
#include "redirections.h"
#include
#include
#include
#include
-
+#include
+#include
bool validate_redirection_args(const redirection_map *cmd, char *arg, char *end)
{
@@ -24,9 +25,9 @@ bool validate_redirection_args(const redirection_map *cmd, char *arg, char *end)
if (count != 0 && end - arg - 1 != 0)
return (true);
if (cmd->type & PIPE)
- my_printf("Invalid null command.\n");
+ printf("Invalid null command.\n");
else
- my_printf("Missing name for redirect.\n");
+ printf("Missing name for redirect.\n");
return (false);
}
@@ -36,11 +37,11 @@ int *input_count, int *output_count)
*input_count += (shell_cmd->type & INPUT) != 0;
*output_count += (shell_cmd->type & OUTPUT) != 0;
if (*input_count > 1) {
- my_printf("Ambiguous input redirect.\n");
+ printf("Ambiguous input redirect.\n");
return (true);
}
if (*output_count > 1) {
- my_printf("Ambiguous output redirect.\n");
+ printf("Ambiguous output redirect.\n");
return (true);
}
if (shell_cmd->type & PIPE) {
@@ -63,7 +64,7 @@ bool redirections_are_invalid(char *cmd)
shell_cmd = get_redirection(cmd);
if (!validate_redirection_args(shell_cmd, fcmd, cmd))
return (true);
- cmd += my_strlen(shell_cmd->key);
+ cmd += strlen(shell_cmd->key);
if (redirections_are_ambiguous(shell_cmd, &input_count, &output_count))
return (true);
fcmd = cmd;
diff --git a/src/redirections/redirections.c b/src/redirections/redirections.c
index 1f23ae1..c988af8 100644
--- a/src/redirections/redirections.c
+++ b/src/redirections/redirections.c
@@ -5,7 +5,7 @@
** redirections
*/
-#include "my.h"
+
#include "shell.h"
#include "redirections.h"
#include
diff --git a/src/redirections/redirections_functions.c b/src/redirections/redirections_functions.c
index f47cd38..2680f1b 100644
--- a/src/redirections/redirections_functions.c
+++ b/src/redirections/redirections_functions.c
@@ -5,7 +5,7 @@
** redirections_input
*/
-#include "my.h"
+
#include "shell.h"
#include "redirections.h"
#include
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
void redirection_ctr(redirection *red, char *cmd, const redirection_map *type)
{
@@ -62,14 +63,14 @@ void handle_eof_input(redirection *in, env_t *env)
in->extra_data = tmp;
if (!args)
return;
- eof = malloc(sizeof(char) * (my_strlen(args[0]) + 2));
- my_strcpy(eof, args[0]);
- my_strcpy(eof + my_strlen(args[0]), "\n");
+ eof = malloc(sizeof(char) * (strlen(args[0]) + 2));
+ strcpy(eof, args[0]);
+ strcpy(eof + strlen(args[0]), "\n");
write(1, "? ", 2);
while (getline(&input, &t, stdin) >= 0) {
- if (!my_strcmp(input, eof))
+ if (!strcmp(input, eof))
return;
- write(in->extra_data, input, my_strlen(input));
+ write(in->extra_data, input, strlen(input));
write(1, "? ", 2);
}
(void)env;
diff --git a/src/shell.c b/src/shell.c
index 9a43732..a94d0b7 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -9,8 +9,7 @@
#include
#include
#include "shell.h"
-#include "my.h"
-
+#include
#include
void start_shell(env_t *env)
@@ -22,7 +21,7 @@ void start_shell(env_t *env)
while (!should_close) {
if (cmd) {
- p = my_strchr(cmd, '\n');
+ p = strchr(cmd, '\n');
if (p)
*p = '\0';
if (eval_raw_cmd(cmd, env) < 0)
diff --git a/src/signal.c b/src/signal.c
index be31035..a94a369 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -13,7 +13,7 @@
#include
#include
#include
-#include "my.h"
+#include "utility.h"
#include "shell.h"
const char *my_strsignal(int status)
@@ -54,7 +54,7 @@ void handle_signal(int status, env_t *env)
free(stat);
if (!WIFSIGNALED(status))
return;
- write(2, err, my_strlen(err));
+ write(2, err, strlen(err));
if (WCOREDUMP(status))
write(2, " (core dumped)", 15);
write(2, "\n", 1);
@@ -63,12 +63,12 @@ void handle_signal(int status, env_t *env)
void exec_error(char *path, char *cmd)
{
if (errno == ENOEXEC) {
- my_printf("%s: Exec format error. Wrong Architecture.\n", cmd);
+ printf("%s: Exec format error. Wrong Architecture.\n", cmd);
} else if (access(path, F_OK) == 0) {
- write(2, cmd, my_strlen(cmd));
+ write(2, cmd, strlen(cmd));
write(2, ": Permission denied.\n", 22);
} else {
- write(2, cmd, my_strlen(cmd));
+ write(2, cmd, strlen(cmd));
write(2, ": Command not found.\n", 21);
}
exit(1);
diff --git a/src/utility/catpath.c b/src/utility/catpath.c
index fe37894..90ccadc 100644
--- a/src/utility/catpath.c
+++ b/src/utility/catpath.c
@@ -1,19 +1,20 @@
/*
** EPITECH PROJECT, 2019
-** PSU_my_ls_2019
+** PSU_ls_2019
** File description:
** catpath
*/
-#include "my.h"
+
#include
+#include
char *catpath(char *p1, char *p2)
{
- char *ret = malloc((my_strlen(p1) + my_strlen(p2) + 2) * sizeof(char));
+ char *ret = malloc((strlen(p1) + strlen(p2) + 2) * sizeof(char));
- my_strcpy(ret, p1);
- my_strcat(ret, "/");
- my_strcat(ret, p2);
+ strcpy(ret, p1);
+ strcat(ret, "/");
+ strcat(ret, p2);
return (ret);
}
\ No newline at end of file
diff --git a/src/same_var.c b/src/utility/same_var.c
similarity index 100%
rename from src/same_var.c
rename to src/utility/same_var.c
diff --git a/src/utility/split_str.c b/src/utility/split_str.c
index d6bc8f2..48832fa 100644
--- a/src/utility/split_str.c
+++ b/src/utility/split_str.c
@@ -7,7 +7,7 @@
#include
#include
-#include "my.h"
+#include
int count_char(char *str, char c)
{
@@ -23,8 +23,8 @@ int count_str(char *str, char *delim)
{
int count = 0;
- while ((str = my_strstr(str, delim))) {
- str += my_strlen(delim);
+ while ((str = strstr(str, delim))) {
+ str += strlen(delim);
count++;
}
return (count);
diff --git a/src/utility/to_array.c b/src/utility/to_array.c
index 99a1bbb..fcf583f 100644
--- a/src/utility/to_array.c
+++ b/src/utility/to_array.c
@@ -2,12 +2,12 @@
** EPITECH PROJECT, 2020
** PSU_minishell1_2019
** File description:
-** my_to_array
+** to_array
*/
#include
#include
-#include "my.h"
+#include
static int get_word_count(char *str)
{
@@ -35,7 +35,7 @@ char **to_array(char *str)
if (!arr)
return (NULL);
arr[0] = str;
- for (i = 1; (p = my_strchr(p, ':')); i++) {
+ for (i = 1; (p = strchr(p, ':')); i++) {
*p = '\0';
p++;
arr[i] = p;
diff --git a/tests/tcd.c b/tests/tcd.c
index 217162c..04e13b4 100644
--- a/tests/tcd.c
+++ b/tests/tcd.c
@@ -26,7 +26,7 @@ Test(cd, home)
env->env[i] = strdup(environ[i]);
builtin_cd(args, env);
- cr_assert_str_eq(getcwd(NULL, 0), getenv("HOME"));
+ cr_assert_str_eq(getcwd(NULL, 0), my_getenv("HOME"));
}
Test(cd, absolute)
diff --git a/tests/tenv.c b/tests/tenv.c
index 4cd3e06..c9b7323 100644
--- a/tests/tenv.c
+++ b/tests/tenv.c
@@ -28,7 +28,7 @@ Test(setenv, null)
cr_assert_eq(env[1], NULL);
}
-Test(env, unsetenv)
+Test(env, my_unsetenv)
{
char **env = malloc(sizeof(char **) * 1);
env[0] = NULL;
diff --git a/tests/tester/tests b/tests/tester/tests
index 6eef875..b78c6d1 100644
--- a/tests/tester/tests
+++ b/tests/tester/tests
@@ -44,7 +44,7 @@ TESTS=
[905-END]
[906]
-NAME="setenv and unsetenv"
+NAME="setenv and my_unsetenv"
SETUP="/usr/bin/env > .lstenv ; while read varenv ; do unset $varenv ; done < <(/bin/cat .lstenv | /usr/bin/cut -f1 -d=) ; export PATH=/bin:/usr/bin ; export _=ls ; export LS_COLORS=RID ; export MYBG=4 ; export LVL=4 ; export NOTE=2"
CLEAN="while read varenv ; do export "$varenv" 2>/dev/null ; done < <(/bin/cat .lstenv) ; /bin/rm -f .lstenv"
TESTS=
@@ -94,7 +94,7 @@ NAME="Launch DivZero program with core dump"
SETUP="export TERM=xterm ; PATH='/bin:/usr/bin'"
CLEAN=""
TESTS=
- echo "./my_divzero"
+ echo "./divzero"
[909-END]
[910]
@@ -102,7 +102,7 @@ NAME="Launch SegFault program without core dump"
SETUP="ulimit -c 0 ; export TERM=xterm ; PATH='/bin:/usr/bin'"
CLEAN=""
TESTS=
- echo "./my_segfault"
+ echo "./segfault"
[910-END]
[911]