You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
613 B

  1. /* Cross platform case insensitive string compare functions
  2. */
  3. #include "Python.h"
  4. int
  5. PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
  6. {
  7. if (size == 0)
  8. return 0;
  9. while ((--size > 0) &&
  10. (tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
  11. if (!*s1++ || !*s2++)
  12. break;
  13. }
  14. return tolower((unsigned)*s1) - tolower((unsigned)*s2);
  15. }
  16. int
  17. PyOS_mystricmp(const char *s1, const char *s2)
  18. {
  19. while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
  20. ;
  21. }
  22. return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
  23. }