]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Wchar/Comparison.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / Wchar / Comparison.c
1 /** @file
2 Comparison Functions for <wchar.h>.
3
4 Unless explicitly stated otherwise, the functions defined in this file order
5 two wide characters the same way as two integers of the underlying integer
6 type designated by wchar_t.
7
8 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials are licensed and made available under
10 the terms and conditions of the BSD License that accompanies this distribution.
11 The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php.
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 **/
17 #include <Uefi.h>
18 #include <Library/BaseLib.h>
19 #include <Library/BaseMemoryLib.h>
20
21 #include <LibConfig.h>
22
23 #include <wchar.h>
24
25 /** The wcscmp function compares the wide string pointed to by s1 to the wide
26 string pointed to by s2.
27
28 @return The wcscmp function returns an integer greater than, equal to, or
29 less than zero, accordingly as the wide string pointed to by s1
30 is greater than, equal to, or less than the wide string
31 pointed to by s2.
32 **/
33 int wcscmp(const wchar_t *s1, const wchar_t *s2)
34 {
35 return (int)StrCmp( (CONST CHAR16 *)s1, (CONST CHAR16 *)s2);
36 }
37
38 /** The wcscoll function compares the wide string pointed to by s1 to the wide
39 string pointed to by s2, both interpreted as appropriate to the LC_COLLATE
40 category of the current locale.
41
42 @return The wcscoll function returns an integer greater than, equal to,
43 or less than zero, accordingly as the wide string pointed to by
44 s1 is greater than, equal to, or less than the wide string
45 pointed to by s2 when both are interpreted as appropriate to
46 the current locale.
47 **/
48 //int wcscoll(const wchar_t *s1, const wchar_t *s2)
49 //{
50 // return -1; // STUBB
51 //}
52
53 /** The wcsncmp function compares not more than n wide characters (those that
54 follow a null wide character are not compared) from the array pointed to by
55 s1 to the array pointed to by s2.
56
57 @return The wcsncmp function returns an integer greater than, equal to,
58 or less than zero, accordingly as the possibly null-terminated
59 array pointed to by s1 is greater than, equal to, or less than
60 the possibly null-terminated array pointed to by s2.
61 **/
62 int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
63 {
64 return (int)StrnCmp( (CONST CHAR16 *)s1, (CONST CHAR16 *)s2, (UINTN)n);
65 }
66
67 /** The wcsxfrm function transforms the wide string pointed to by s2 and places
68 the resulting wide string into the array pointed to by s1. The
69 transformation is such that if the wcscmp function is applied to two
70 transformed wide strings, it returns a value greater than, equal to, or
71 less than zero, corresponding to the result of the wcscoll function applied
72 to the same two original wide strings. No more than n wide characters are
73 placed into the resulting array pointed to by s1, including the terminating
74 null wide character. If n is zero, s1 is permitted to be a null pointer.
75
76 @return The wcsxfrm function returns the length of the transformed wide
77 string (not including the terminating null wide character). If
78 the value returned is n or greater, the contents of the array
79 pointed to by s1 are indeterminate.
80 **/
81 //size_t wcsxfrm(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
82 //{
83 // return n; // STUBB
84 //}
85
86 /** The wmemcmp function compares the first n wide characters of the object
87 pointed to by s1 to the first n wide characters of the object pointed to
88 by s2.
89
90 @return The wmemcmp function returns an integer greater than, equal to,
91 or less than zero, accordingly as the object pointed to by s1 is
92 greater than, equal to, or less than the object pointed to by s2.
93 **/
94 int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
95 {
96 return (int)CompareMem( s1, s2, (UINTN)(n * sizeof(wchar_t)));
97 }