| 95 | /////////////////////////////////////////// |
| 96 | |
| 97 | bool string_endswith(const char *a, const char *end, bool case_sensitive) { |
| 98 | size_t len_a = strlen(a); |
| 99 | size_t len_end = strlen(end); |
| 100 | if (len_end > len_a) |
| 101 | return false; |
| 102 | a = a + (len_a - len_end); |
| 103 | |
| 104 | if (!case_sensitive) { |
| 105 | while (*a != '\0' && *end != '\0') { |
| 106 | if (tolower(*a) != tolower(*end)) |
| 107 | return false; |
| 108 | a++; |
| 109 | end++; |
| 110 | } |
| 111 | return tolower(*a) == tolower(*end); |
| 112 | } else { |
| 113 | while (*a != '\0' && *end != '\0') { |
| 114 | if (*a != *end) |
| 115 | return false; |
| 116 | a++; |
| 117 | end++; |
| 118 | } |
| 119 | return *a == *end; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /////////////////////////////////////////// |
| 124 |
no test coverage detected