461 |
462 |
462 int cx_strcmp( |
463 int cx_strcmp( |
463 cxstring s1, |
464 cxstring s1, |
464 cxstring s2 |
465 cxstring s2 |
465 ) { |
466 ) { |
466 int r = strncmp(s1.ptr, s2.ptr, s1.length); |
|
467 if (r != 0) return r; |
|
468 if (s1.length == s2.length) { |
467 if (s1.length == s2.length) { |
469 return 0; |
468 return strncmp(s1.ptr, s2.ptr, s1.length); |
470 } else if (s1.length > s2.length) { |
469 } else if (s1.length > s2.length) { |
|
470 int r = strncmp(s1.ptr, s2.ptr, s2.length); |
|
471 if (r != 0) return r; |
471 return 1; |
472 return 1; |
472 } else { |
473 } else { |
|
474 int r = strncmp(s1.ptr, s2.ptr, s1.length); |
|
475 if (r != 0) return r; |
473 return -1; |
476 return -1; |
474 } |
477 } |
475 } |
478 } |
476 |
479 |
477 int cx_strcasecmp( |
480 int cx_strcasecmp( |
478 cxstring s1, |
481 cxstring s1, |
479 cxstring s2 |
482 cxstring s2 |
480 ) { |
483 ) { |
481 #ifdef _WIN32 |
|
482 int r = _strnicmp(s1.ptr, s2.ptr, s1.length); |
|
483 #else |
|
484 int r = strncasecmp(s1.ptr, s2.ptr, s1.length); |
|
485 #endif |
|
486 if (r != 0) return r; |
|
487 if (s1.length == s2.length) { |
484 if (s1.length == s2.length) { |
488 return 0; |
485 return cx_strcasecmp_impl(s1.ptr, s2.ptr, s1.length); |
489 } else if (s1.length > s2.length) { |
486 } else if (s1.length > s2.length) { |
|
487 int r = cx_strcasecmp_impl(s1.ptr, s2.ptr, s2.length); |
|
488 if (r != 0) return r; |
490 return 1; |
489 return 1; |
491 } else { |
490 } else { |
|
491 int r = cx_strcasecmp_impl(s1.ptr, s2.ptr, s1.length); |
|
492 if (r != 0) return r; |
492 return -1; |
493 return -1; |
493 } |
494 } |
494 } |
495 } |
495 |
496 |
496 int cx_strcmp_p( |
497 int cx_strcmp_p( |