mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-14 15:09:09 +00:00
Add minor improvements and cleanup
This commit is contained in:
parent
9e3e985ae5
commit
feed0d2b0e
163 changed files with 2286 additions and 2245 deletions
|
@ -25,11 +25,10 @@
|
|||
* @param s is a NUL-terminated string
|
||||
* @param suffix is also NUL-terminated
|
||||
*/
|
||||
bool(endswith)(const char *s, const char *suffix) {
|
||||
size_t l1, l2;
|
||||
if (s == suffix) return true;
|
||||
l1 = strlen(s);
|
||||
l2 = strnlen(suffix, l1);
|
||||
if (l2 > l1) return false;
|
||||
return memcmp(s + (l1 - l2) * sizeof(char), suffix, l2 * sizeof(char)) == 0;
|
||||
bool endswith(const char *s, const char *suffix) {
|
||||
size_t n, m;
|
||||
n = strlen(s);
|
||||
m = strlen(suffix);
|
||||
if (m > n) return false;
|
||||
return memcmp(s + n - m, suffix, m) == 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue