Skip to content

Commit 8c77dbe

Browse files
Fixup Unix methods, minor refactor of CompareInfo
1 parent 84084c1 commit 8c77dbe

File tree

6 files changed

+151
-232
lines changed

6 files changed

+151
-232
lines changed

src/libraries/Common/src/Interop/Unix/System.Globalization.Native/Interop.Collation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal static partial class Globalization
2424
internal static extern unsafe int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
2525

2626
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")]
27-
internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options);
27+
internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
2828

2929
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")]
3030
internal static extern unsafe int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast);

src/libraries/Native/Unix/System.Globalization.Native/pal_collation.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ int32_t GlobalizationNative_LastIndexOf(
501501
int32_t cwTargetLength,
502502
const UChar* lpSource,
503503
int32_t cwSourceLength,
504-
int32_t options)
504+
int32_t options,
505+
int32_t* pMatchedLength)
505506
{
506507
int32_t result = USEARCH_DONE;
507508
UErrorCode err = U_ZERO_ERROR;
@@ -514,6 +515,13 @@ int32_t GlobalizationNative_LastIndexOf(
514515
if (U_SUCCESS(err))
515516
{
516517
result = usearch_last(pSearch, &err);
518+
519+
// if the search was successful,
520+
// we'll try to get the matched string length.
521+
if (result != USEARCH_DONE && pMatchedLength != NULL)
522+
{
523+
*pMatchedLength = usearch_getMatchedLength(pSearch);
524+
}
517525
usearch_close(pSearch);
518526
}
519527
}

src/libraries/Native/Unix/System.Globalization.Native/pal_collation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ DLLEXPORT int32_t GlobalizationNative_LastIndexOf(SortHandle* pSortHandle,
3434
int32_t cwTargetLength,
3535
const UChar* lpSource,
3636
int32_t cwSourceLength,
37-
int32_t options);
37+
int32_t options,
38+
int32_t* pMatchedLength);
3839

3940
DLLEXPORT int32_t GlobalizationNative_IndexOfOrdinalIgnoreCase(const UChar* lpTarget,
4041
int32_t cwTargetLength,

0 commit comments

Comments
 (0)