purge remaining gpl code from clib, and make clib build again
[tangerine.git] / compiler / clib / strcmp.c
blobd021bc316f8861fe569df9f8233b3dd38043b8c3
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function strcmp().
6 */
8 /*****************************************************************************
10 NAME */
11 #include <string.h>
13 int strcmp (
15 /* SYNOPSIS */
16 const char * str1,
17 const char * str2)
19 /* FUNCTION
20 Calculate str1 - str2.
22 INPUTS
23 str1, str2 - Strings to compare
25 RESULT
26 The difference of the strings. The difference is 0, if both are
27 equal, < 0 if str1 < str2 and > 0 if str1 > str2. Note that
28 it may be greater then 1 or less than -1.
30 NOTES
31 This function is not part of a library and may thus be called
32 any time.
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 int diff;
46 /* No need to check *str2 since: a) str1 is equal str2 (both are 0),
47 then *str1 will terminate the loop b) str1 and str2 are not equal
48 (eg. *str2 is 0), then the diff part will be FALSE. I calculate
49 the diff first since a) it's more probable that the first chars
50 will be different and b) I don't need to initialize diff then. */
51 while (!(diff = *str1 - *str2) && *str1)
53 /* advance both strings. I do that here, since doing it in the
54 check above would mean to advance the strings once too often */
55 str1 ++;
56 str2 ++;
59 /* Now return the difference. */
60 return diff;
61 } /* strcmp */