* @brief Removes all occurrences of a substring from a String object. * * This function removes all instances of a specified substring from a String object. If the String object, * its data, or the substring is NULL, the function logs an error and does nothing. If the substring is empty, * the function also logs an error and does nothing. * * @param str The String object from which to remove
| 2748 | STRING_LOG("[string_to_capitalize]: Function start."); |
| 2749 | |
| 2750 | if (str == NULL) { |
| 2751 | STRING_LOG("[string_to_capitalize]: Error - The String object is NULL."); |
| 2752 | return; |
| 2753 | } |
| 2754 | if (str->dataStr == NULL) { |
| 2755 | STRING_LOG("[string_to_capitalize]: Error - The dataStr of String object is NULL."); |
| 2756 | return; |
| 2757 | } |
| 2758 | if (str->size == 0) { |
| 2759 | STRING_LOG("[string_to_capitalize]: Error - The size of String object is zero."); |
| 2760 | return; |
| 2761 | } |
| 2762 | |
| 2763 | str->dataStr[0] = sstr_ascii_toupper(str->dataStr[0]); |
| 2764 | |
| 2765 | STRING_LOG("[string_to_capitalize]: Successfully capitalized the first character."); |
| 2766 | STRING_LOG("[string_to_capitalize]: Function end."); |
| 2767 | } |
| 2768 | |
| 2769 | |
| 2770 | /** |
| 2771 | * @brief This function iterates over the characters in the String object `str` and converts |
| 2772 | * each character to its lowercase equivalent. |
| 2773 | * |
| 2774 | * @param str The String object to casefold. Must not be NULL. |
| 2775 | */ |
| 2776 | void string_to_casefold(String* str) { |
| 2777 | STRING_LOG("[string_to_casefold]: Function start."); |
| 2778 | |
| 2779 | if (str == NULL || str->dataStr == NULL) { |
| 2780 | STRING_LOG("[string_to_casefold]: Error - Invalid string input."); |
| 2781 | return; |
| 2782 | } |
| 2783 | for (size_t i = 0; i < str->size; i++) { |
| 2784 | str->dataStr[i] = sstr_ascii_tolower(str->dataStr[i]); |
| 2785 | } |
nothing calls this directly
no outgoing calls
no test coverage detected