MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / string_remove

Function string_remove

string/std_string.c:2750–2782  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

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 */
2776void 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 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected