revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / locale / strncmp.c
blobf25af7bc7bd9caa4121773d8b06a9c967a88e91b
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 or
43 NULL for the system default locale.
44 string1 - NULL terminated string.
45 string2 - NULL terminated string.
46 length - Maximum length of string to compare, or -1 to
47 compare entire strings.
48 type - How to compare the strings, values are:
50 SC_ASCII
51 Perform a simple ASCII case-insensitive comparison.
52 This is the fastest comparison, but considers that
53 accented characters are different to non-accented
54 characters.
56 SC_COLLATE1
57 This sorts using the "primary sorting order". This
58 means that characters such as 'e' and 'é' will be
59 considered the same. This method also ignores
60 case.
62 SC_COLLATE2
63 This will sort using both the primary and secondary
64 sorting order. This is the slowest sorting method
65 and should be used when presenting data to a user.
67 The first pass is the same as SC_COLLATE1, meaning
68 that two strings such as "role" and "rôle" would
69 be sorted identically. The second pass will
70 compare the diacritical marks.
72 RESULT
73 The relationship between the two strings.
75 < 0 means string1 < string2
76 = 0 means string1 == string2
77 > 0 means string1 > string2
79 NOTES
81 EXAMPLE
83 BUGS
85 SEE ALSO
86 OpenLocale(), CloseLocale(), StrConvert()
88 INTERNALS
90 *****************************************************************************/
92 AROS_LIBFUNC_INIT
94 LONG result;
95 struct Locale *def_locale = NULL;
97 if (locale == NULL)
99 locale = OpenLocale(NULL);
100 def_locale = (struct Locale *)locale;
103 DEBUG_STRNCMP(dprintf
104 ("StrnCmp: locale 0x%lx <%s> <%s> len %ld type 0x%lx\n", locale,
105 string1, string2, length, type));
107 DEBUG_STRNCMP(dprintf("StrnCmp: Function 0x%lx\n",
108 IntL(locale)->il_LanguageFunctions[16]));
110 #ifdef AROS_CALL4
111 result = AROS_CALL4(ULONG, IntL(locale)->il_LanguageFunctions[16],
112 AROS_LCA(CONST_STRPTR, string1, A1),
113 AROS_LCA(CONST_STRPTR, string2, A2),
114 AROS_LCA(ULONG, length, D0),
115 AROS_LCA(ULONG, type, D1), struct LocaleBase *, LocaleBase);
116 #else
117 result = AROS_UFC4(ULONG, IntL(locale)->il_LanguageFunctions[16],
118 AROS_UFCA(CONST_STRPTR, string1, A1),
119 AROS_UFCA(CONST_STRPTR, string2, A2),
120 AROS_UFCA(ULONG, length, D0), AROS_UFCA(ULONG, type, D1));
121 #endif
123 CloseLocale(def_locale);
125 DEBUG_STRNCMP(dprintf("StrnCmp: retval %ld\n", result));
127 return result;
129 AROS_LIBFUNC_EXIT