strcase.c 380 B

1234567891011121314151617181920212223
  1. #include <linux/ctype.h>
  2. int strcasecmp(const char *s1, const char *s2)
  3. {
  4. int c1, c2;
  5. do {
  6. c1 = tolower(*s1++);
  7. c2 = tolower(*s2++);
  8. } while (c1 == c2 && c1 != 0);
  9. return c1 - c2;
  10. }
  11. int strncasecmp(const char *s1, const char *s2, int n)
  12. {
  13. int c1, c2;
  14. do {
  15. c1 = tolower(*s1++);
  16. c2 = tolower(*s2++);
  17. } while ((--n > 0) && c1 == c2 && c1 != 0);
  18. return c1 - c2;
  19. }