Changeset 70 in Main for trunk/Common
- Timestamp:
- Sep 19, 2024, 6:23:45 PM (2 months ago)
- Location:
- trunk/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/cm_string.h
r21 r70 7 7 8 8 int cm_hex(const char* str, int len); 9 bool cm_nocase_endswith(const char* str, const char* end); 10 bool cm_endswith(const char* str, const char* end); 9 11 char* cm_html_escape(const char* str); 10 12 char* cm_url_escape(const char* str); -
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.