File:  [Research Unix] / researchv10no / ipc / bin / ftp / str.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#include <ctype.h>

char
lc(ch)
char ch;
{
	if (isupper(ch))
		return(tolower(ch));
	else
		return(ch);
}

/*
 * Compare strings:  s1>s2: >0  s1==s2: 0  s1<s2: <0
 */

strcasecmp(s1, s2)
register char *s1, *s2;
{

	while (lc(*s1) == lc(*s2++))
		if (*s1++=='\0')
			return(0);
	return(lc(*s1) - lc(*--s2));
}

/*
 * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
 */

strncasecmp(s1, s2, n)
register char *s1, *s2;
register n;
{

	while (--n >= 0 && lc(*s1) == lc(*s2++))
		if (*s1++ == '\0')
			return(0);
	return(n<0 ? 0 : lc(*s1) - lc(*--s2));
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.