All moving on the shcat_c folder
This commit is contained in:
parent
dffb6ea577
commit
20391637b6
19 changed files with 36 additions and 39 deletions
|
|
@ -1,18 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_bzero.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:29:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void ft_bzero(void *s, t_usize n)
|
||||
{
|
||||
ft_memset(s, 0, n);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:32:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void *ft_calloc(t_usize nmemb, t_usize size)
|
||||
{
|
||||
t_usize total;
|
||||
t_str to_return;
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
return ((void *)malloc(1));
|
||||
total = nmemb * size;
|
||||
if (total / nmemb != size && total / size != nmemb)
|
||||
return (NULL);
|
||||
to_return = (char *)malloc(total);
|
||||
if (to_return == NULL)
|
||||
to_return = NULL;
|
||||
else
|
||||
ft_bzero(to_return, total);
|
||||
return (to_return);
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:32:32 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void *ft_memset(void *s, t_i32 c, t_usize n)
|
||||
{
|
||||
t_str str;
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
str = (t_str)s;
|
||||
while (i < n)
|
||||
{
|
||||
str[i] = c;
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_split.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 21:07:40 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
static t_i32 count_words(t_const_str str, t_i8 sep)
|
||||
{
|
||||
t_i32 i;
|
||||
t_i32 count;
|
||||
|
||||
i = 0;
|
||||
count = 0;
|
||||
while (str[i])
|
||||
{
|
||||
while (str[i] == sep && str[i])
|
||||
i++;
|
||||
if (str[i] != sep && str[i])
|
||||
{
|
||||
while (str[i] != sep && str[i])
|
||||
i++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
static t_str ft_strndup(t_const_str s, t_i32 j)
|
||||
{
|
||||
t_i32 i;
|
||||
t_str str;
|
||||
|
||||
i = 0;
|
||||
str = (t_str)malloc((j + 1));
|
||||
if (!str)
|
||||
return (NULL);
|
||||
while (s[i] && i < j)
|
||||
{
|
||||
str[i] = s[i];
|
||||
i++;
|
||||
}
|
||||
str[i] = '\0';
|
||||
return (str);
|
||||
}
|
||||
|
||||
static t_str *ext_w(t_str *words_array, t_const_str str, t_i8 sep, t_i32 size)
|
||||
{
|
||||
t_i32 i;
|
||||
t_i32 j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (j < size)
|
||||
{
|
||||
while (str[i] == sep && str[i])
|
||||
i++;
|
||||
str = str + i;
|
||||
i = 0;
|
||||
while (str[i] != sep && str[i])
|
||||
i++;
|
||||
words_array[j++] = ft_strndup(str, i);
|
||||
str = str + i;
|
||||
i = 0;
|
||||
}
|
||||
words_array[j] = 0;
|
||||
return (words_array);
|
||||
}
|
||||
|
||||
t_str *ft_split(t_const_str s, t_i8 c)
|
||||
{
|
||||
t_i32 size;
|
||||
t_str *words_array;
|
||||
|
||||
size = count_words(s, c);
|
||||
words_array = (t_str *)malloc(sizeof(char *) * (size + 1));
|
||||
if (!words_array)
|
||||
return (NULL);
|
||||
if (size == 0)
|
||||
{
|
||||
words_array[0] = NULL;
|
||||
return (words_array);
|
||||
}
|
||||
words_array = ext_w(words_array, s, c, size);
|
||||
return (words_array);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 21:57:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
size_t i;
|
||||
int diff;
|
||||
|
||||
i = 0;
|
||||
while ((s1[i] || s2[i]))
|
||||
{
|
||||
if (s1[i] != s2[i] && s1 && s2)
|
||||
{
|
||||
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
|
||||
return (diff);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:41:35 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
t_str ft_strdup(t_const_str s)
|
||||
{
|
||||
t_usize len;
|
||||
t_str to_return;
|
||||
|
||||
len = ft_strlen(s) + 1;
|
||||
to_return = (t_str)malloc(sizeof(t_i8) * len);
|
||||
if (!to_return)
|
||||
return (NULL);
|
||||
ft_strlcpy(to_return, s, len);
|
||||
return (to_return);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:38:28 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
t_usize ft_strlcpy(t_str dst, t_const_str src, t_usize size)
|
||||
{
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
while (src[i] && i + 1 < size)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
if (size > 0)
|
||||
{
|
||||
dst[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (ft_strlen(src));
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:37:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
size_t ft_strlen(t_const_str s)
|
||||
{
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
while (s[i] != '\0')
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue