strncasecmp.c 458 B

12345678910111213141516171819202122
  1. /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
  2. * This file is part of the Linux-8086 C library and is distributed
  3. * under the GNU Library General Public License.
  4. */
  5. #include <string.h>
  6. #include <ctype.h>
  7. int strncasecmp( const char *s, const char *d, size_t l)
  8. {
  9. while (l > 0) {
  10. if (*s != *d) {
  11. if (tolower(*s) != tolower(*d))
  12. return *s - *d;
  13. } else if (*s == '\0')
  14. return 0;
  15. s++;
  16. d++;
  17. l--;
  18. }
  19. return 0;
  20. }