1*31745Sbostic /* 2*31745Sbostic * Copyright (c) 1987 Regents of the University of California. 3*31745Sbostic * All rights reserved. The Berkeley software License Agreement 4*31745Sbostic * specifies the terms and conditions for redistribution. 5*31745Sbostic */ 6*31745Sbostic 7*31745Sbostic #if defined(LIBC_SCCS) && !defined(lint) 8*31745Sbostic static char sccsid[] = "@(#)strcasecmp.c 5.1 (Berkeley) 07/02/87"; 9*31745Sbostic #endif LIBC_SCCS and not lint 10*31745Sbostic 11*31745Sbostic #include <ctype.h> 12*31745Sbostic 13*31745Sbostic /* 14*31745Sbostic * Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0 15*31745Sbostic * case insensitive 16*31745Sbostic */ 17*31745Sbostic strcasecmp(s1, s2) 18*31745Sbostic register char *s1, *s2; 19*31745Sbostic { 20*31745Sbostic register char c1, c2; 21*31745Sbostic 22*31745Sbostic for (;; ++s1, ++s2) { 23*31745Sbostic c2 = isupper(*s2) ? tolower(*s2) : *s2; 24*31745Sbostic c1 = isupper(*s1) ? tolower(*s1) : *s1; 25*31745Sbostic if (c1 != c2) 26*31745Sbostic return(c1 - c2); 27*31745Sbostic if (!c1) 28*31745Sbostic return(0); 29*31745Sbostic } 30*31745Sbostic } 31*31745Sbostic 32*31745Sbostic /* 33*31745Sbostic * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0 34*31745Sbostic * case insensitive 35*31745Sbostic */ 36*31745Sbostic strcasencmp(s1, s2, n) 37*31745Sbostic register char *s1, *s2; 38*31745Sbostic register int n; 39*31745Sbostic { 40*31745Sbostic register char c1, c2; 41*31745Sbostic 42*31745Sbostic for (; n; ++s1, ++s2, --n) { 43*31745Sbostic c2 = isupper(*s2) ? tolower(*s2) : *s2; 44*31745Sbostic c1 = isupper(*s1) ? tolower(*s1) : *s1; 45*31745Sbostic if (c1 != c2) 46*31745Sbostic return(c1 - c2); 47*31745Sbostic if (!c1) 48*31745Sbostic return(0); 49*31745Sbostic } 50*31745Sbostic return(0); 51*31745Sbostic } 52