|
|
1.1 root 1: #ifndef lint
2: static char *sccsid="@(#)str.c 2.5 (smail) 9/15/87";
3: #endif
4:
5: #include "defs.h"
6: #include <ctype.h>
7:
8: /*
9: ** strncmpic: string compare, ignore case, stop after 'n' chars
10: */
11:
12: strncmpic(s1, s2, n)
13: char *s1, *s2;
14: int n;
15: {
16: register char *u = s1;
17: register char *p = s2;
18:
19: while((n > 0) && (*p != '\0')) {
20: /* chars match or only case different */
21: if(lower(*u) == lower(*p)) {
22: p++; /* examine next char */
23: u++;
24: } else {
25: break; /* no match - stop comparison */
26: }
27: n--;
28: }
29: if(n > 0) {
30: return(lower(*u) - lower(*p)); /* return "difference" */
31: } else {
32: return(0);
33: }
34: }
35:
36: /*
37: ** strcmpic: string compare, ignore case
38: */
39:
40: strcmpic(s1, s2)
41: char *s1, *s2;
42: {
43: register char *u = s1;
44: register char *p = s2;
45:
46: while(*p != '\0') {
47: /* chars match or only case different */
48: if(lower(*u) == lower(*p)) {
49: p++; /* examine next char */
50: u++;
51: } else {
52: break; /* no match - stop comparison */
53: }
54: }
55:
56: return(lower(*u) - lower(*p)); /* return "difference" */
57: }
58:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.