mirror of
https://github.com/Savapitech/42sh.git
synced 2026-03-18 21:50:35 +01:00
Remove unused lib functions
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** CPoolDay07
|
||||
** File description:
|
||||
** ./u_swap.c
|
||||
*/
|
||||
|
||||
void u_swap(int *a, int *b)
|
||||
{
|
||||
int swap;
|
||||
|
||||
swap = *a;
|
||||
*a = *b;
|
||||
*b = swap;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2025
|
||||
** __
|
||||
** File description:
|
||||
** _
|
||||
*/
|
||||
|
||||
int swap_uint32(int src)
|
||||
{
|
||||
return ((src & 0xFF000000) >> 24) |
|
||||
((src & 0x00FF0000) >> 8) |
|
||||
((src & 0x0000FF00) << 8) |
|
||||
((src & 0x000000FF) << 24);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** B-CPE-100-REN-1-1-cpoolday03-savinien.petitjean
|
||||
** File description:
|
||||
** u_getnbr.c
|
||||
*/
|
||||
|
||||
long u_pow(int pow)
|
||||
{
|
||||
long r = 1;
|
||||
|
||||
for (long i = 0; i < pow; i++)
|
||||
r *= 10;
|
||||
return r;
|
||||
}
|
||||
|
||||
int u_atoi(char *str, int size, int negativ, int rsize)
|
||||
{
|
||||
long result = 0;
|
||||
|
||||
if (size > 10 || size == 0 || rsize == 0)
|
||||
return 0;
|
||||
for (int i = 0; i < size; i++)
|
||||
result += u_pow(size - i - 1) * (str[i] - '0');
|
||||
if (negativ % 2 != 0)
|
||||
result *= (-1);
|
||||
if (result > 2147483647 || result < -2147483648)
|
||||
return 0;
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
int u_getnbr(char const *str)
|
||||
{
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
int sig = 0;
|
||||
char nstr[1000000];
|
||||
int size = 0;
|
||||
int rsize = 1;
|
||||
|
||||
for (; str[start] < 48 || str[start] > 57; start++);
|
||||
end = start + 1;
|
||||
for (; str[end] >= 48 && str[end] <= 57; end++);
|
||||
for (int i = 0; i < end; i++)
|
||||
if (str[i] == '-')
|
||||
sig++;
|
||||
for (int i = start; i < end; i++) {
|
||||
nstr[size] = str[i];
|
||||
size++;
|
||||
}
|
||||
return u_atoi(nstr, size, sig, rsize);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** B-CPE-100-REN-1-1-cpoolday06-savinien.petitjean
|
||||
** File description:
|
||||
** Task 3
|
||||
*/
|
||||
|
||||
#include "u_str.h"
|
||||
|
||||
char *u_revstr(char *str)
|
||||
{
|
||||
int len = u_strlen(str);
|
||||
char copy;
|
||||
|
||||
for (int i = 0; i < len / 2; i++) {
|
||||
copy = str[i];
|
||||
str[i] = str[len - 1 - i];
|
||||
str[len - 1 - i] = copy;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2023
|
||||
** CPoolDay07
|
||||
** File description:
|
||||
** ./u_strcat.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "u_str.h"
|
||||
|
||||
char *u_strcat(char *dest, char const *src)
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
char *res;
|
||||
|
||||
i = 0;
|
||||
count = 0;
|
||||
res = malloc(sizeof(*res) * (u_strlen(dest) + u_strlen(src) + 1));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
while (dest[i]) {
|
||||
res[i] = dest[i];
|
||||
i++;
|
||||
}
|
||||
while (src[count]) {
|
||||
res[i + count] = src[count];
|
||||
count++;
|
||||
}
|
||||
res[i + count] = '\0';
|
||||
return (res);
|
||||
}
|
||||
@@ -17,11 +17,3 @@ int u_strlen(char const *str)
|
||||
for (; *p != '\0'; p++);
|
||||
return (p - str);
|
||||
}
|
||||
|
||||
int u_spacelen(char const *str)
|
||||
{
|
||||
char const *p = str;
|
||||
|
||||
for (; !isblank(*p) && *p != '\0'; p++);
|
||||
return (p - str);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** B-CPE-100-REN-1-1-cpoolday06-savinien.petitjean
|
||||
** File description:
|
||||
** Task 1
|
||||
*/
|
||||
|
||||
int u_strncmp(char const *s1, char const *s2, int nb)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (nb == 0)
|
||||
return 0;
|
||||
for (; s1[i] == s2[i] && s1[i] != '\0' && i < nb - 1; i++);
|
||||
return s1[i] - s2[i];
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** B-CPE-100-REN-1-1-cpoolday06-savinien.petitjean
|
||||
** File description:
|
||||
** Task 2
|
||||
*/
|
||||
|
||||
__attribute__((nonnull(1, 2)))
|
||||
char *u_strncpy(char *dest, char const *src, int n)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (; i < n && src[i] != '\0'; i++)
|
||||
dest[i] = src[i];
|
||||
if (src[i] == '\0' && i < n)
|
||||
dest[i] = '\0';
|
||||
return dest;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2024
|
||||
** B-CPE-100-REN-1-1-cpoolday06-savinien.petitjean
|
||||
** File description:
|
||||
** Task 2
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "u_str.h"
|
||||
|
||||
char *u_strstr(char *str, char const *to_find)
|
||||
{
|
||||
int find_len = u_strlen(to_find);
|
||||
|
||||
if (*to_find == '\0')
|
||||
return str;
|
||||
for (; *str != '\0'; str++)
|
||||
if (!u_strncmp(str, to_find, find_len))
|
||||
return str;
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user