strcasecmp.c 633 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * strcasecmp.c -- provides strcasecmp() and strncasecmp if necessary.
  3. *
  4. */
  5. #include "common.h"
  6. #include "memcpy.h"
  7. #ifndef HAVE_STRCASECMP
  8. int egg_strcasecmp(const char *s1, const char *s2)
  9. {
  10. while ((*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
  11. s1++;
  12. s2++;
  13. }
  14. return toupper(*s1) - toupper(*s2);
  15. }
  16. #endif /* !HAVE_STRCASECMP */
  17. #ifndef HAVE_STRNCASECMP
  18. int egg_strncasecmp(const char *s1, const char *s2, size_t n)
  19. {
  20. if (!n)
  21. return 0;
  22. while (--n && (*s1) && (*s2) && (toupper(*s1) == toupper(*s2))) {
  23. s1++;
  24. s2++;
  25. }
  26. return toupper(*s1) - toupper(*s2);
  27. }
  28. #endif /* !HAVE_STRNCASECMP */