- Tabs to spaces.
[AROS.git] / workbench / libs / locale / strncmp.c
blobdb52de55458bc024b1f1676ea7b35cd9d2abaca0
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: StrnCmp() - Stub for the Locale StrnCmp() function.
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <proto/exec.h>
10 #include "locale_intern.h"
11 #include <aros/asmcall.h>
13 #define DEBUG_STRNCMP(x) ;
15 /*****************************************************************************
17 NAME */
18 #include <proto/locale.h>
20 AROS_LH5(LONG, StrnCmp,
22 /* SYNOPSIS */
23 AROS_LHA(const struct Locale *, locale, A0),
24 AROS_LHA(CONST_STRPTR , string1, A1),
25 AROS_LHA(CONST_STRPTR , string2, A2),
26 AROS_LHA(LONG , length, D0),
27 AROS_LHA(ULONG , type, D1),
29 /* LOCATION */
30 struct LocaleBase *, LocaleBase, 30, Locale)
32 /* FUNCTION
33 StrnCmp() will compare two strings, up to a maximum length
34 of length using a specific kind of collation information
35 according to the locale.
37 The result will be less than zero, zero, or greater than zero
38 depending upon whether the string string1 is less than, equal
39 to, or greater than the string pointed to string2.
41 INPUTS
42 locale - Which locale to use for this comparison.
43 string1 - NULL terminated string.
44 string2 - NULL terminated string.
45 length - Maximum length of string to compare, or -1 to
46 compare entire strings.
47 type - How to compare the strings, values are:
49 SC_ASCII
50 Perform a simple ASCII case-insensitive comparison.
51 This is the fastest comparison, but considers that
52 accented characters are different to non-accented
53 characters.
55 SC_COLLATE1
56 This sorts using the "primary sorting order". This
57 means that characters such as 'e' and 'é' will be
58 considered the same. This method also ignores
59 case.
61 SC_COLLATE2
62 This will sort using both the primary and secondary
63 sorting order. This is the slowest sorting method
64 and should be used when presenting data to a user.
66 The first pass is the same as SC_COLLATE1, meaning
67 that two strings such as "role" and "rôle" would
68 be sorted identically. The second pass will
69 compare the diacritical marks.
71 RESULT
72 The relationship between the two strings.
74 < 0 means string1 < string2
75 = 0 means string1 == string2
76 > 0 means string1 > string2
78 NOTES
80 EXAMPLE
82 BUGS
84 SEE ALSO
85 OpenLocale(), CloseLocale(), StrConvert()
87 INTERNALS
89 *****************************************************************************/
91 AROS_LIBFUNC_INIT
93 LONG result;
95 DEBUG_STRNCMP(dprintf
96 ("StrnCmp: locale 0x%lx <%s> <%s> len %ld type 0x%lx\n", locale,
97 string1, string2, length, type));
99 DEBUG_STRNCMP(dprintf("StrnCmp: Function 0x%lx\n",
100 IntL(locale)->il_LanguageFunctions[16]));
102 #ifdef AROS_CALL4
103 result = AROS_CALL4(ULONG, IntL(locale)->il_LanguageFunctions[16],
104 AROS_LCA(CONST_STRPTR, string1, A1),
105 AROS_LCA(CONST_STRPTR, string2, A2),
106 AROS_LCA(ULONG, length, D0),
107 AROS_LCA(ULONG, type, D1), struct LocaleBase *, LocaleBase);
108 #else
109 result = AROS_UFC4(ULONG, IntL(locale)->il_LanguageFunctions[16],
110 AROS_UFCA(CONST_STRPTR, string1, A1),
111 AROS_UFCA(CONST_STRPTR, string2, A2),
112 AROS_UFCA(ULONG, length, D0), AROS_UFCA(ULONG, type, D1));
113 #endif
115 DEBUG_STRNCMP(dprintf("StrnCmp: retval %ld\n", result));
117 return result;
119 AROS_LIBFUNC_EXIT