glibc 函数
| 4 | |
| 5 | // glibc 函数 |
| 6 | int __strncasecmp(const char *s1, const char *s2, int n) { |
| 7 | if (n && s1 != s2) { |
| 8 | do { |
| 9 | int d = ::tolower(*s1) - ::tolower(*s2); |
| 10 | if (d || *s1 == '\0' || *s2 == '\0') |
| 11 | return d; |
| 12 | s1++; |
| 13 | s2++; |
| 14 | } while (--n); |
| 15 | } |
| 16 | return 0; |
| 17 | } |
| 18 | |
| 19 | bool CompareIgnoreCase(const std::string &lh, const std::string &rh) { |
| 20 | std::size_t llen = lh.size(); |