refactor(string_utils)!: rename skip_blanks to trim_blank_left and update signature

This commit is contained in:
william.valenduc 2026-01-12 17:41:24 +00:00 committed by Matteo Flebus
parent b9eb7b90cb
commit 8b75d73d56
3 changed files with 46 additions and 39 deletions

View file

@ -3,17 +3,13 @@
#include <ctype.h>
#include <stddef.h>
ssize_t skip_blanks(char **str)
char *trim_blank_left(char *str)
{
if (str == NULL || *str == NULL)
{
return 0;
}
ssize_t skipped = 0;
while (*str[skipped] != '\0' && !isblank(str[skipped]))
{
skipped++;
}
*str += skipped;
return skipped;
if (str == NULL)
return NULL;
while (*str != '\0' && isblank(*str))
str++;
return str;
}

View file

@ -4,9 +4,12 @@
#include <sys/types.h>
/*
* @brief: skips blank characters at the beginning of [str].
* @return: number of characters skipped.
* @brief trims leading blank characters (space and tab) from the input string.
* @param str input string to be trimmed.
* @return pointer to the first non-blank character in the string. If the
* string consists entirely of blank characters, returns a pointer to the null
* terminator at the end of the string.
*/
ssize_t skip_blanks(char **str);
char *trim_blank_left(char *str);
#endif /* STRING_UTILS_H */