| 459 ) { |
459 ) { |
| 460 return cx_strsplit_a(allocator, cx_strcast(string), |
460 return cx_strsplit_a(allocator, cx_strcast(string), |
| 461 delim, limit, (cxstring **) output); |
461 delim, limit, (cxstring **) output); |
| 462 } |
462 } |
| 463 |
463 |
| 464 int cx_strcmp( |
464 int cx_strcmp_( |
| 465 cxstring s1, |
465 cxstring s1, |
| 466 cxstring s2 |
466 cxstring s2 |
| 467 ) { |
467 ) { |
| 468 if (s1.length == s2.length) { |
468 if (s1.length == s2.length) { |
| 469 return strncmp(s1.ptr, s2.ptr, s1.length); |
469 return strncmp(s1.ptr, s2.ptr, s1.length); |
| 545 cxmutstr cx_strtrim_m(cxmutstr string) { |
545 cxmutstr cx_strtrim_m(cxmutstr string) { |
| 546 cxstring result = cx_strtrim(cx_strcast(string)); |
546 cxstring result = cx_strtrim(cx_strcast(string)); |
| 547 return (cxmutstr) {(char *) result.ptr, result.length}; |
547 return (cxmutstr) {(char *) result.ptr, result.length}; |
| 548 } |
548 } |
| 549 |
549 |
| 550 bool cx_strprefix( |
550 bool cx_strprefix_( |
| 551 cxstring string, |
551 cxstring string, |
| 552 cxstring prefix |
552 cxstring prefix |
| 553 ) { |
553 ) { |
| 554 if (string.length < prefix.length) return false; |
554 if (string.length < prefix.length) return false; |
| 555 return memcmp(string.ptr, prefix.ptr, prefix.length) == 0; |
555 return memcmp(string.ptr, prefix.ptr, prefix.length) == 0; |
| 556 } |
556 } |
| 557 |
557 |
| 558 bool cx_strsuffix( |
558 bool cx_strsuffix_( |
| 559 cxstring string, |
559 cxstring string, |
| 560 cxstring suffix |
560 cxstring suffix |
| 561 ) { |
561 ) { |
| 562 if (string.length < suffix.length) return false; |
562 if (string.length < suffix.length) return false; |
| 563 return memcmp(string.ptr + string.length - suffix.length, |
563 return memcmp(string.ptr + string.length - suffix.length, |
| 564 suffix.ptr, suffix.length) == 0; |
564 suffix.ptr, suffix.length) == 0; |
| 565 } |
565 } |
| 566 |
566 |
| 567 bool cx_strcaseprefix( |
567 bool cx_strcaseprefix_( |
| 568 cxstring string, |
568 cxstring string, |
| 569 cxstring prefix |
569 cxstring prefix |
| 570 ) { |
570 ) { |
| 571 if (string.length < prefix.length) return false; |
571 if (string.length < prefix.length) return false; |
| 572 #ifdef _WIN32 |
572 #ifdef _WIN32 |