Changeset 70 in Main for trunk/Common/string.c
- Timestamp:
- Sep 19, 2024, 6:23:45 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/string.c
r21 r70 8 8 9 9 char* cm_strcat(const char* a, const char* b) { 10 if(a == NULL) a = ""; 11 if(b == NULL) b = ""; 10 12 char* str = malloc(strlen(a) + strlen(b) + 1); 11 13 memcpy(str, a, strlen(a)); … … 23 25 24 26 char* cm_strdup(const char* str) { return cm_strcat(str, ""); } 27 28 bool cm_endswith(const char* str, const char* end) { 29 if(strlen(str) < strlen(end)) return false; 30 int i; 31 for(i = strlen(str) - strlen(end); i < strlen(str); i++) { 32 if(str[i] != end[i - strlen(str) + strlen(end)]) return false; 33 } 34 return true; 35 } 36 37 bool cm_nocase_endswith(const char* str, const char* end) { 38 if(strlen(str) < strlen(end)) return false; 39 int i; 40 for(i = strlen(str) - strlen(end); i < strlen(str); i++) { 41 if(tolower(str[i]) != tolower(end[i - strlen(str) + strlen(end)])) return false; 42 } 43 return true; 44 } 25 45 26 46 char* cm_trimstart(const char* str) {
Note:
See TracChangeset
for help on using the changeset viewer.