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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libc/] [string/] [strcasecmp.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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