Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1693 serge 1
/*
2
FUNCTION
3
	<>---case-insensitive character string compare
4
 
5
INDEX
6
	strncasecmp
7
 
8
ANSI_SYNOPSIS
3065 serge 9
	#include 
1693 serge 10
	int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>);
11
 
12
TRAD_SYNOPSIS
3065 serge 13
	#include 
1693 serge 14
	int strncasecmp(<[a]>, <[b]>, <[length]>)
15
	char *<[a]>;
16
	char *<[b]>;
17
	size_t <[length]>
18
 
19
DESCRIPTION
20
	<> compares up to <[length]> characters
21
	from the string at <[a]> to the string at <[b]> in a
22
	case-insensitive manner.
23
 
24
RETURNS
25
 
26
	If <<*<[a]>>> sorts lexicographically after <<*<[b]>>> (after
27
	both are converted to lowercase), <> returns a
28
	number greater than zero.  If the two strings are equivalent,
29
	<> returns zero.  If <<*<[a]>>> sorts
30
	lexicographically before <<*<[b]>>>, <> returns a
31
	number less than zero.
32
 
33
PORTABILITY
34
<> is in the Berkeley Software Distribution.
35
 
36
<> requires no supporting OS subroutines. It uses
37
tolower() from elsewhere in this library.
38
 
39
QUICKREF
40
	strncasecmp
41
*/
42
 
3065 serge 43
#include 
1693 serge 44
#include 
45
 
46
int
47
_DEFUN (strncasecmp, (s1, s2, n),
48
	_CONST char *s1 _AND
49
	_CONST char *s2 _AND
50
	size_t n)
51
{
52
  _CONST unsigned char *ucs1 = (_CONST unsigned char *) s1;
53
  _CONST unsigned char *ucs2 = (_CONST unsigned char *) s2;
54
  int d = 0;
55
  for ( ; n != 0; n--)
56
    {
57
      _CONST int c1 = tolower(*ucs1++);
58
      _CONST int c2 = tolower(*ucs2++);
59
      if (((d = c1 - c2) != 0) || (c2 == '\0'))
60
        break;
61
    }
62
  return d;
63
}