Skip to content

Commit 5025f5e

Browse files
authored
Move unicodedata to minipal (#102139)
* Move unicodedata to minipal * Fix linux build * Shave off a few bytes with 'static const' * Add a separate header * Regenerate unicodedata.c * Cleanups
1 parent 76cd4be commit 5025f5e

File tree

16 files changed

+2596
-2628
lines changed

16 files changed

+2596
-2628
lines changed

src/coreclr/pal/inc/pal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,9 +3963,6 @@ PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);
39633963

39643964
#define ERANGE 34
39653965

3966-
PALIMPORT WCHAR __cdecl PAL_ToUpperInvariant(WCHAR);
3967-
PALIMPORT WCHAR __cdecl PAL_ToLowerInvariant(WCHAR);
3968-
39693966
/****************PAL Perf functions for PInvoke*********************/
39703967
#if PAL_PERF
39713968
PALIMPORT

src/coreclr/pal/src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ set(SOURCES
144144
init/sxs.cpp
145145
loader/module.cpp
146146
locale/unicode.cpp
147-
locale/unicodedata.cpp
148147
${CLR_SRC_NATIVE_DIR}/minipal/utf8.c
148+
${CLR_SRC_NATIVE_DIR}/minipal/unicodedata.c
149149
map/common.cpp
150150
map/map.cpp
151151
map/virtual.cpp

src/coreclr/pal/src/cruntime/wchar.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Module Name:
2424
#include "config.h"
2525
#endif
2626

27-
#include <wctype.h>
2827
#include <errno.h>
2928
#include <algorithm>
3029

src/coreclr/pal/src/include/pal/unicodedata.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/coreclr/pal/src/locale/unicode.cpp

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
/*++
5-
6-
7-
85
Module Name:
9-
106
unicode.cpp
117
128
Abstract:
13-
149
Implementation of all functions related to Unicode support
15-
16-
Revision History:
17-
18-
19-
2010
--*/
2111

2212
#include "pal/thread.hpp"
@@ -27,7 +17,6 @@ Revision History:
2717
#include <minipal/utf8.h>
2818
#include "pal/cruntime.h"
2919
#include "pal/stackstring.hpp"
30-
#include "pal/unicodedata.h"
3120

3221
#include <pthread.h>
3322
#include <locale.h>
@@ -39,138 +28,6 @@ using namespace CorUnix;
3928

4029
SET_DEFAULT_DEBUG_CHANNEL(UNICODE);
4130

42-
/*++
43-
Function:
44-
UnicodeDataComp
45-
This is the comparison function used by the bsearch function to search
46-
for unicode characters in the UnicodeData array.
47-
48-
Parameter:
49-
pnKey
50-
The unicode character value to search for.
51-
elem
52-
A pointer to a UnicodeDataRec.
53-
54-
Return value:
55-
<0 if pnKey < elem->nUnicodeValue
56-
0 if pnKey == elem->nUnicodeValue
57-
>0 if pnKey > elem->nUnicodeValue
58-
--*/
59-
static int UnicodeDataComp(const void *pnKey, const void *elem)
60-
{
61-
WCHAR uValue = ((UnicodeDataRec*)elem)->nUnicodeValue;
62-
63-
if (*((INT*)pnKey) < uValue)
64-
{
65-
return -1;
66-
}
67-
else if (*((INT*)pnKey) > uValue)
68-
{
69-
return 1;
70-
}
71-
else
72-
{
73-
return 0;
74-
}
75-
}
76-
77-
/*++
78-
Function:
79-
GetUnicodeData
80-
This function is used to get information about a Unicode character.
81-
82-
Parameters:
83-
nUnicodeValue
84-
The numeric value of the Unicode character to get information about.
85-
pDataRec
86-
The UnicodeDataRec to fill in with the data for the Unicode character.
87-
88-
Return value:
89-
TRUE if the Unicode character was found.
90-
91-
--*/
92-
BOOL GetUnicodeData(INT nUnicodeValue, UnicodeDataRec *pDataRec)
93-
{
94-
BOOL bRet;
95-
96-
UnicodeDataRec *dataRec;
97-
INT nNumOfChars = UNICODE_DATA_SIZE;
98-
dataRec = (UnicodeDataRec *) bsearch(&nUnicodeValue, UnicodeData, nNumOfChars,
99-
sizeof(UnicodeDataRec), UnicodeDataComp);
100-
if (dataRec == NULL)
101-
{
102-
bRet = FALSE;
103-
}
104-
else
105-
{
106-
bRet = TRUE;
107-
*pDataRec = *dataRec;
108-
}
109-
return bRet;
110-
}
111-
112-
char16_t
113-
__cdecl
114-
PAL_ToUpperInvariant( char16_t c )
115-
{
116-
UnicodeDataRec dataRec;
117-
118-
PERF_ENTRY(PAL_ToUpperInvariant);
119-
ENTRY("PAL_ToUpperInvariant (c=%d)\n", c);
120-
121-
if (!GetUnicodeData(c, &dataRec))
122-
{
123-
TRACE( "Unable to retrieve unicode data for the character %c.\n", c );
124-
LOGEXIT("PAL_ToUpperInvariant returns int %d\n", c );
125-
PERF_EXIT(PAL_ToUpperInvariant);
126-
return c;
127-
}
128-
129-
if ( dataRec.nFlag != LOWER_CASE )
130-
{
131-
LOGEXIT("PAL_ToUpperInvariant returns int %d\n", c );
132-
PERF_EXIT(PAL_ToUpperInvariant);
133-
return c;
134-
}
135-
else
136-
{
137-
LOGEXIT("PAL_ToUpperInvariant returns int %d\n", dataRec.nOpposingCase );
138-
PERF_EXIT(PAL_ToUpperInvariant);
139-
return dataRec.nOpposingCase;
140-
}
141-
}
142-
143-
char16_t
144-
__cdecl
145-
PAL_ToLowerInvariant( char16_t c )
146-
{
147-
UnicodeDataRec dataRec;
148-
149-
PERF_ENTRY(PAL_ToLowerInvariant);
150-
ENTRY("PAL_ToLowerInvariant (c=%d)\n", c);
151-
152-
if (!GetUnicodeData(c, &dataRec))
153-
{
154-
TRACE( "Unable to retrieve unicode data for the character %c.\n", c );
155-
LOGEXIT("PAL_ToLowerInvariant returns int %d\n", c );
156-
PERF_EXIT(PAL_ToLowerInvariant);
157-
return c;
158-
}
159-
160-
if ( dataRec.nFlag != UPPER_CASE )
161-
{
162-
LOGEXIT("PAL_ToLowerInvariant returns int %d\n", c );
163-
PERF_EXIT(PAL_ToLowerInvariant);
164-
return c;
165-
}
166-
else
167-
{
168-
LOGEXIT("PAL_ToLowerInvariant returns int %d\n", dataRec.nOpposingCase );
169-
PERF_EXIT(PAL_ToLowerInvariant);
170-
return dataRec.nOpposingCase;
171-
}
172-
}
173-
17431
/*++
17532
Function:
17633
GetConsoleOutputCP

0 commit comments

Comments
 (0)