2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Compare the tails of two strings
11 /*****************************************************************************
24 Compare the end parts of two strings. Case is ignored.
27 str1, str2 - Strings to compare
28 cnt - Compare that many characters
31 Returns 0 if the strings are equal and != 0 otherwise.
34 This function is not part of a library and may thus be called
39 rc = strrncasecmp ("disk.info", ".INFO", 5);
42 rc = strrncasecmp ("disk.info", ".c", 2);
47 clib/strcmp(), clib/strcasecmp(), clib/strncasecmp(), clib/strrchr()
53 ******************************************************************************/
55 const char * ptr1
, * ptr2
;
58 /* If any string is empty, the strings are equal */
81 diff
= tolower (*ptr1
) - tolower (*ptr2
);
83 while (!diff
&& ptr1
!= str1
&& ptr2
!= str2
);
85 /* Compared all neccessary chars ? */
89 /* Run out of chars in only one of the two strings ? */
92 else if (ptr2
!= str2
)
95 /* The strings differ */
102 int main (int argc
, char ** argv
)
108 fprintf (stderr
, "Usage: %s string1 string2 len\n", argv
[0]);
114 printf ("strrncasecmp (\"%s\", \"%s\", %d) = %d\n",
118 strrncasecmp (argv
[1], argv
[2], n
)