Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / locale / strncmp.c
blob8fc7376356b0bd00046643beb995e96531a5ff43
1 /*
2 Copyright © 1995-2008, 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("StrnCmp: locale 0x%lx <%s> <%s> len %ld type 0x%lx\n",
96 locale,
97 string1,
98 string2,
99 length,
100 type));
102 DEBUG_STRNCMP(dprintf("StrnCmp: Function 0x%lx\n",
103 IntL(locale)->il_LanguageFunctions[16]));
105 #ifdef AROS_CALL4
106 Result = AROS_CALL4(ULONG, IntL(locale)->il_LanguageFunctions[16],
107 AROS_LCA(CONST_STRPTR, string1, A1),
108 AROS_LCA(CONST_STRPTR, string2, A2),
109 AROS_LCA(ULONG, length, D0),
110 AROS_LCA(ULONG, type, D1),
111 struct LocaleBase *, LocaleBase);
112 #else
113 Result = AROS_UFC4(ULONG, IntL(locale)->il_LanguageFunctions[16],
114 AROS_UFCA(CONST_STRPTR, string1, A1),
115 AROS_UFCA(CONST_STRPTR, string2, A2),
116 AROS_UFCA(ULONG, length, D0),
117 AROS_UFCA(ULONG, type, D1));
118 #endif
120 DEBUG_STRNCMP(dprintf("StrnCmp: retval %ld\n",
121 Result));
123 return(Result);
125 AROS_LIBFUNC_EXIT
126 } /* StrnCmp */