mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
WIP: internal environment manipulation
Added a function to join two strings putting a separator in between. (Predicted useful for PATH manipulation and general translation of internal structure back to char ** form)
This commit is contained in:
parent
46401ef417
commit
eaa1afda5f
4 changed files with 32 additions and 1 deletions
|
|
@ -153,6 +153,7 @@ int max_int(int a, int b);
|
|||
int min_int(int a, int b);
|
||||
long max_long(long a, long b);
|
||||
long min_long(long a, long b);
|
||||
char *ft_strjoin_sepc(char *s1, char *s2, char sep);
|
||||
/*BONUSLIBFT*/
|
||||
t_list *ft_lstnew(void *content);
|
||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ SOURCES = ft_atoi.c ft_itoa.c ft_putendl_fd.c ft_strlcat.c ft_substr.c \
|
|||
ft_memcmp.c ft_split.c ft_strmapi.c ft_isalpha.c ft_memcpy.c ft_strchr.c \
|
||||
ft_strncmp.c ft_isascii.c ft_memmove.c ft_strdup.c ft_strnstr.c \
|
||||
ft_isdigit.c ft_memset.c ft_striteri.c ft_strrchr.c ft_isprint.c \
|
||||
ft_putchar_fd.c ft_strjoin.c ft_strtrim.c ft_min_max.c
|
||||
ft_putchar_fd.c ft_strjoin.c ft_strtrim.c ft_min_max.c ft_strjoin_sepc.c
|
||||
BONUSSOURCES = ft_lstnew_bonus.c ft_lstadd_back_bonus.c ft_lstsize_bonus.c \
|
||||
ft_lstadd_front_bonus.c ft_lstclear_bonus.c ft_lstdelone_bonus.c \
|
||||
ft_lstiter_bonus.c ft_lstlast_bonus.c ft_lstmap_bonus.c
|
||||
|
|
|
|||
29
libft/libft/ft_strjoin_sepc.c
Normal file
29
libft/libft/ft_strjoin_sepc.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strjoin_sepc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 18:08:52 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/14 18:15:28 by jguelen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strjoin_sepc(char *s1, char *s2, char sep)
|
||||
{
|
||||
char *new;
|
||||
size_t len1;
|
||||
size_t len2;
|
||||
|
||||
len1 = ft_strlen(s1);
|
||||
len2 = ft_strlen(s2);
|
||||
new = malloc((len1 + len2 + 2) * sizeof(char));
|
||||
ft_memmove(new, s1, len1);
|
||||
new[len1] = sep;
|
||||
ft_memmove(new + len1 + 1, s2, len2);
|
||||
new[len1 + len2 + 1] = '\0';
|
||||
return (new);
|
||||
}
|
||||
|
|
@ -63,6 +63,7 @@ int max_int(int a, int b);
|
|||
int min_int(int a, int b);
|
||||
long max_long(long a, long b);
|
||||
long min_long(long a, long b);
|
||||
char *ft_strjoin_sepc(char *s1, char *s2, char sep);
|
||||
/*BONUS*/
|
||||
t_list *ft_lstnew(void *content);
|
||||
void ft_lstadd_front(t_list **lst, t_list *new);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue