define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / compiler / clib / strcasecmp.c
blobbc930c18bde1eb1b4474d54b5bfebd4f4ce1998b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function strcasecmp().
6 */
8 #include <ctype.h>
10 /*****************************************************************************
12 NAME */
13 #include <string.h>
15 int strcasecmp (
17 /* SYNOPSIS */
18 const char * str1,
19 const char * str2)
21 /* FUNCTION
22 Calculate str1 - str2 ignoring case.
24 INPUTS
25 str1, str2 - Strings to compare
27 RESULT
28 The difference of the strings. The difference is 0, if both are
29 equal, < 0 if str1 < str2 and > 0 if str1 > str2. Note that
30 it may be greater then 1 or less than -1.
32 NOTES
33 This function is not part of a library and may thus be called
34 any time.
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 ******************************************************************************/
46 int diff;
48 /* No need to check *str2 since: a) str1 is equal str2 (both are 0),
49 then *str1 will terminate the loop b) str1 and str2 are not equal
50 (eg. *str2 is 0), then the diff part will be FALSE. I calculate
51 the diff first since a) it's more probable that the first chars
52 will be different and b) I don't need to initialize diff then. */
53 while (!(diff = tolower (*str1) - tolower (*str2)) && *str1)
55 /* advance both strings. I do that here, since doing it in the
56 check above would mean to advance the strings once too often */
57 str1 ++;
58 str2 ++;
61 /* Now return the difference. */
62 return diff;
63 } /* strcasecmp */