OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [strncasecmp.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
        <<strncasecmp>>---case-insensitive character string compare
4
 
5
INDEX
6
        strncasecmp
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        int strncasecmp(const char *<[a]>, const char * <[b]>, size_t <[length]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        int strncasecmp(<[a]>, <[b]>, <[length]>)
15
        char *<[a]>;
16
        char *<[b]>;
17
        size_t <[length]>
18
 
19
DESCRIPTION
20
        <<strncasecmp>> 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), <<strncasecmp>> returns a
28
        number greater than zero.  If the two strings are equivalent,
29
        <<strncasecmp>> returns zero.  If <<*<[a]>>> sorts
30
        lexicographically before <<*<[b]>>>, <<strncasecmp>> returns a
31
        number less than zero.
32
 
33
PORTABILITY
34
<<strncasecmp>> is in the Berkeley Software Distribution.
35
 
36
<<strncasecmp>> requires no supporting OS subroutines. It uses
37
tolower() from elsewhere in this library.
38
 
39
QUICKREF
40
        strncasecmp
41
*/
42
 
43
#include <string.h>
44
#include <ctype.h>
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.