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

Function string_compare

string/std_string.c:592–608  ·  view source on GitHub ↗

* @brief Compares two String objects lexicographically. * * This function compares two String objects lexicographically. * If either string is NULL, the NULL string is considered less than the non-NULL string. * If both are NULL, they are considered equal. * * @param str1 The first String object to compare. Can be NULL. * @param str2 The second String object to compare. Can be NULL. *

Source from the content-addressed store, hash-verified

590 * - A value greater than 0 if str1 is greater than str2
591 */
592int string_compare(const String* str1, const String* str2) {
593 STRING_LOG("[string_compare]: Comparing two strings.\n");
594
595 if (str1 == NULL || str2 == NULL) {
596 if (str1 == str2) {
597 STRING_LOG("[string_compare]: Both strings are NULL. Returning 0 (equal).\n");
598 return 0;
599 }
600
601 STRING_LOG("[string_compare]: One or both String objects are NULL.\n");
602 return (str1 == NULL) ? -1 : 1;
603 }
604 int result = strcmp(str1->dataStr, str2->dataStr);
605 STRING_LOG("[string_compare]: Comparison result is %d.\n", result);
606
607 return result;
608}
609
610
611/**

Callers 6

string_is_equalFunction · 0.85
string_is_lessFunction · 0.85
string_is_greaterFunction · 0.85
string_is_less_or_equalFunction · 0.85
string_is_not_equalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected