|
libft
|
Trims characters from the beginning and end of a string. More...
#include "libft.h"
Include dependency graph for ft_strtrim.c:Functions | |
| static int | ft_is_in_set (char c, const char *set) |
| Checks if a character is present in a given set. | |
| char * | ft_strtrim (const char *s1, const char *set) |
| Trims characters from both ends of a string. | |
| static size_t | ft_trim_end (const char *s1, const char *set) |
| Finds the ending index before trimming trailing characters. | |
| static size_t | ft_trim_start (const char *s1, const char *set) |
| Finds the starting index after trimming leading characters. | |
Trims characters from the beginning and end of a string.
This file implements the ft_strtrim function, which removes all leading and trailing characters from a string based on a given set. It also defines helper functions to locate trim boundaries efficiently.
|
static |
Checks if a character is present in a given set.
Iterates through the set and returns 1 if character c is found, 0 otherwise.
| c | The character to check. |
| set | The null-terminated string containing the set of characters. |
c is in set, 0 otherwise.
|
static |
Finds the ending index before trimming trailing characters.
Scans backward from the end of s1 and returns the index of the last character not in set + 1.
| s1 | The string to trim. |
| set | The set of characters to remove. |
|
static |
Finds the starting index after trimming leading characters.
Scans from the beginning of s1 and returns the index of the first character not included in set.
| s1 | The string to trim. |
| set | The set of characters to remove. |