minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
clean_rl_copy.c File Reference

Functions for cleaning the input string by removing leading and trailing whitespaces. More...

#include "minishell.h"
Include dependency graph for clean_rl_copy.c:

Functions

int ft_isspace (int c)
 Checks if the given character is a whitespace.
 
char * replace_with_clean (char *rl_copy, size_t start, size_t end)
 Removes characters from a string that are before and after a given index.
 
char * clean_rl_copy (char *rl_copy)
 Create a copy of the input string with its leading and trailing whitespaces removed.
 

Detailed Description

Functions for cleaning the input string by removing leading and trailing whitespaces.

Function Documentation

◆ clean_rl_copy()

char * clean_rl_copy ( char *  rl_copy)

Create a copy of the input string with its leading and trailing whitespaces removed.

Removes leading and trailing whitespaces from rl_copy and creates a new string with these whitespaces removed. The original input string is freed.

Parameters
rl_copyThe input string to be cleaned.
Returns
A new allocated string with the leading and trailing whitespaces removed.

◆ ft_isspace()

int ft_isspace ( int  c)

Checks if the given character is a whitespace.

Checks if a given character is a whitespace and returns 1 if it is. Otherwise returns 0.

Parameters
cThe character to check.
Returns
1 if the character is a whitespace, otherwise 0.

◆ replace_with_clean()

char * replace_with_clean ( char *  rl_copy,
size_t  start,
size_t  end 
)

Removes characters from a string that are before and after a given index.

Creates a new string containing characters from the input string (rl_copy) starting from the 'start' index up to the 'end' index. If allocation fails, a error message is displayed and NULL is returned.

Parameters
rl_copyThe input string.
startThe starting index.
endThe ending index.
Returns
A new allocated string with the pulled portion of the input string, or NULL if malloc failed.