[RTL] Add internal RtlpUpcaseUnicodeChar function and use instead RtlUpcaseUnicodeChar internally in RTL

svn path=/trunk/; revision=72691
This commit is contained in:
Dmitry Chapyshev 2016-09-15 20:05:26 +00:00
parent 406bb0105f
commit ce4186a1eb
6 changed files with 61 additions and 50 deletions

View file

@ -113,7 +113,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
if (RtlpIsShortIllegal(Char))
Char = L'_';
else if (Char >= L'a' && Char <= L'z')
Char = RtlUpcaseUnicodeChar(Char);
Char = RtlpUpcaseUnicodeChar(Char);
Context->NameBuffer[Context->NameLength] = Char;
++Context->NameLength;
@ -137,7 +137,7 @@ RtlGenerate8dot3Name(IN PUNICODE_STRING Name,
if (RtlpIsShortIllegal(Char))
Char = L'_';
else if (Char >= L'a' && Char <= L'z')
Char = RtlUpcaseUnicodeChar(Char);
Char = RtlpUpcaseUnicodeChar(Char);
Context->ExtensionBuffer[Context->ExtensionLength++] = Char;
}

View file

@ -54,7 +54,7 @@ RtlCustomCPToUnicodeN(IN PCPTABLEINFO CustomCP,
PAGED_CODE_RTL();
if (CustomCP->DBCSCodePage == 0)
if (!CustomCP->DBCSCodePage)
{
/* single-byte code page */
if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
@ -62,7 +62,7 @@ RtlCustomCPToUnicodeN(IN PCPTABLEINFO CustomCP,
else
Size = CustomSize;
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
@ -206,7 +206,6 @@ RtlInitNlsTables(IN PUSHORT AnsiTableBase,
if (AnsiTableBase && OemTableBase && CaseTableBase)
{
RtlInitCodePageTable(AnsiTableBase, &NlsTable->AnsiTableInfo);
RtlInitCodePageTable(OemTableBase, &NlsTable->OemTableInfo);
NlsTable->UpperCaseTable = (PUSHORT)CaseTableBase + 2;
@ -229,7 +228,7 @@ RtlMultiByteToUnicodeN(OUT PWCHAR UnicodeString,
PAGED_CODE_RTL();
if (NlsMbCodePageTag == FALSE)
if (!NlsMbCodePageTag)
{
/* single-byte code page */
if (MbSize > (UnicodeSize / sizeof(WCHAR)))
@ -237,7 +236,7 @@ RtlMultiByteToUnicodeN(OUT PWCHAR UnicodeString,
else
Size = MbSize;
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
@ -274,7 +273,7 @@ RtlMultiByteToUnicodeN(OUT PWCHAR UnicodeString,
*UnicodeString++ = NlsLeadByteInfo[LeadByteInfo + *(PUCHAR)MbString++];
}
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = i * sizeof(WCHAR);
}
@ -369,7 +368,7 @@ RtlOemToUnicodeN(OUT PWCHAR UnicodeString,
PAGED_CODE_RTL();
if (NlsMbOemCodePageTag == FALSE)
if (!NlsMbOemCodePageTag)
{
/* single-byte code page */
if (OemSize > (UnicodeSize / sizeof(WCHAR)))
@ -377,7 +376,7 @@ RtlOemToUnicodeN(OUT PWCHAR UnicodeString,
else
Size = OemSize;
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
@ -419,7 +418,7 @@ RtlOemToUnicodeN(OUT PWCHAR UnicodeString,
NlsOemLeadByteInfo[OemLeadByteInfo + *(PUCHAR)OemString++];
}
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = i * sizeof(WCHAR);
}
@ -479,7 +478,7 @@ RtlUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
PAGED_CODE_RTL();
if (CustomCP->DBCSCodePage == 0)
if (!CustomCP->DBCSCodePage)
{
/* single-byte code page */
if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
@ -487,7 +486,7 @@ RtlUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size;
for (i = 0; i < Size; i++)
@ -522,16 +521,14 @@ RtlUnicodeToMultiByteN(OUT PCHAR MbString,
PAGED_CODE_RTL();
if (NlsMbCodePageTag == FALSE)
if (!NlsMbCodePageTag)
{
/* single-byte code page */
Size = (UnicodeSize > (MbSize * sizeof (WCHAR)))
? MbSize : (UnicodeSize / sizeof (WCHAR));
if (ResultSize != NULL)
{
if (ResultSize)
*ResultSize = Size;
}
for (i = 0; i < Size; i++)
{
@ -573,7 +570,7 @@ RtlUnicodeToMultiByteN(OUT PCHAR MbString,
else break;
}
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = MbSize - i;
}
@ -640,7 +637,7 @@ RtlUnicodeToOemN(OUT PCHAR OemString,
PAGED_CODE_RTL();
if (NlsMbOemCodePageTag == FALSE)
if (!NlsMbOemCodePageTag)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
@ -648,7 +645,7 @@ RtlUnicodeToOemN(OUT PCHAR OemString,
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size;
for (i = 0; i < Size; i++)
@ -693,7 +690,7 @@ RtlUnicodeToOemN(OUT PCHAR OemString,
else break;
}
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = OemSize - i;
}
@ -704,12 +701,10 @@ RtlUnicodeToOemN(OUT PCHAR OemString,
* @implemented
*/
WCHAR NTAPI
RtlUpcaseUnicodeChar(IN WCHAR Source)
RtlpUpcaseUnicodeChar(IN WCHAR Source)
{
USHORT Offset;
PAGED_CODE_RTL();
if (Source < 'a')
return Source;
@ -728,6 +723,17 @@ RtlUpcaseUnicodeChar(IN WCHAR Source)
return Source + (SHORT)Offset;
}
/*
* @implemented
*/
WCHAR NTAPI
RtlUpcaseUnicodeChar(IN WCHAR Source)
{
PAGED_CODE_RTL();
return RtlpUpcaseUnicodeChar(Source);
}
/*
* @implemented
*/
@ -758,7 +764,7 @@ RtlUpcaseUnicodeToCustomCPN(IN PCPTABLEINFO CustomCP,
for (i = 0; i < Size; i++)
{
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString);
*CustomString = ((PCHAR)CustomCP->WideCharTable)[UpcaseChar];
++CustomString;
++UnicodeString;
@ -790,7 +796,7 @@ RtlUpcaseUnicodeToMultiByteN(OUT PCHAR MbString,
PAGED_CODE_RTL();
if (NlsMbCodePageTag == FALSE)
if (!NlsMbCodePageTag)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
@ -798,12 +804,12 @@ RtlUpcaseUnicodeToMultiByteN(OUT PCHAR MbString,
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString);
*MbString = NlsUnicodeToAnsiTable[UpcaseChar];
MbString++;
UnicodeString++;
@ -837,7 +843,7 @@ RtlUpcaseUnicodeToOemN(OUT PCHAR OemString,
ASSERT(NlsUnicodeToOemTable != NULL);
if (NlsMbOemCodePageTag == FALSE)
if (!NlsMbOemCodePageTag)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
@ -845,12 +851,12 @@ RtlUpcaseUnicodeToOemN(OUT PCHAR OemString,
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
UpcaseChar = RtlUpcaseUnicodeChar(*UnicodeString);
UpcaseChar = RtlpUpcaseUnicodeChar(*UnicodeString);
*OemString = NlsUnicodeToOemTable[UpcaseChar];
OemString++;
UnicodeString++;
@ -866,7 +872,7 @@ RtlUpcaseUnicodeToOemN(OUT PCHAR OemString,
for (i = OemSize, Size = UnicodeSize / sizeof(WCHAR); i && Size; i--, Size--)
{
WideChar = RtlUpcaseUnicodeChar(*UnicodeString++);
WideChar = RtlpUpcaseUnicodeChar(*UnicodeString++);
if (WideChar < 0x80)
{
@ -891,7 +897,7 @@ RtlUpcaseUnicodeToOemN(OUT PCHAR OemString,
else break;
}
if (ResultSize != NULL)
if (ResultSize)
*ResultSize = OemSize - i;
}
@ -926,7 +932,7 @@ RtlUpperChar(IN CHAR Source)
}
else
{
if (NlsMbCodePageTag == FALSE)
if (!NlsMbCodePageTag)
{
/* single-byte code page */
@ -934,7 +940,7 @@ RtlUpperChar(IN CHAR Source)
Unicode = NlsAnsiToUnicodeTable[(UCHAR)Source];
/* upcase conversion */
Unicode = RtlUpcaseUnicodeChar (Unicode);
Unicode = RtlpUpcaseUnicodeChar (Unicode);
/* unicode -> ansi */
Destination = NlsUnicodeToAnsiTable[(USHORT)Unicode];

View file

@ -614,7 +614,7 @@ RtlGetFullPathName_Ustr(
ASSERT(FileNameBuffer[1] == L':');
ASSERT(IS_PATH_SEPARATOR(FileNameBuffer[2]));
// FileNameBuffer[0] = RtlUpcaseUnicodeChar(FileNameBuffer[0]);
// FileNameBuffer[0] = RtlpUpcaseUnicodeChar(FileNameBuffer[0]);
Prefix = FileNameBuffer;
PrefixLength = 3 * sizeof(WCHAR);
Source += 3;
@ -631,8 +631,8 @@ RtlGetFullPathName_Ustr(
Source += 2;
SourceLength -= 2 * sizeof(WCHAR);
CurDrive = RtlUpcaseUnicodeChar(CurDirName->Buffer[0]);
NewDrive = RtlUpcaseUnicodeChar(FileNameBuffer[0]);
CurDrive = RtlpUpcaseUnicodeChar(CurDirName->Buffer[0]);
NewDrive = RtlpUpcaseUnicodeChar(FileNameBuffer[0]);
if ((NewDrive != CurDrive) || CurDirName->Buffer[1] != L':')
{

View file

@ -230,4 +230,9 @@ typedef struct _RTL_BITMAP_RUN64
ULONG64 NumberOfBits;
} RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64;
/* nls.c */
WCHAR
NTAPI
RtlpUpcaseUnicodeChar(IN WCHAR Source);
/* EOF */

View file

@ -528,7 +528,7 @@ RtlIsValidOemCharacter(IN PWCHAR Char)
Offset = NlsOemLeadByteInfo[HIBYTE(OemChar)];
/* Receive Unicode character from the table */
UnicodeChar = RtlUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]);
UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[LOBYTE(OemChar) + Offset]);
/* Receive OEM character from the table */
OemChar = NlsUnicodeToMbOemTable[UnicodeChar];
@ -536,7 +536,7 @@ RtlIsValidOemCharacter(IN PWCHAR Char)
else
{
/* Receive Unicode character from the table */
UnicodeChar = RtlUpcaseUnicodeChar(NlsOemToUnicodeTable[(UCHAR)NlsUnicodeToOemTable[*Char]]);
UnicodeChar = RtlpUpcaseUnicodeChar(NlsOemToUnicodeTable[(UCHAR)NlsUnicodeToOemTable[*Char]]);
/* Receive OEM character from the table */
OemChar = NlsUnicodeToOemTable[UnicodeChar];
@ -742,11 +742,11 @@ NTSTATUS NTAPI RtlIntegerToChar(
}
else if (len == length)
{
memcpy(str, pos, len);
RtlCopyMemory(str, pos, len);
}
else
{
memcpy(str, pos, len + 1);
RtlCopyMemory(str, pos, len + 1);
}
return STATUS_SUCCESS;
@ -943,8 +943,8 @@ RtlPrefixUnicodeString(
{
while (NumChars--)
{
if (RtlUpcaseUnicodeChar(*pc1++) !=
RtlUpcaseUnicodeChar(*pc2++))
if (RtlpUpcaseUnicodeChar(*pc1++) !=
RtlpUpcaseUnicodeChar(*pc2++))
return FALSE;
}
}
@ -1924,7 +1924,7 @@ RtlUpcaseUnicodeString(
for (i = 0; i < j; i++)
{
UniDest->Buffer[i] = RtlUpcaseUnicodeChar(UniSource->Buffer[i]);
UniDest->Buffer[i] = RtlpUpcaseUnicodeChar(UniSource->Buffer[i]);
}
UniDest->Length = UniSource->Length;
@ -2196,7 +2196,7 @@ RtlCompareUnicodeString(
if (CaseInsensitive)
{
while (!ret && len--) ret = RtlUpcaseUnicodeChar(*p1++) - RtlUpcaseUnicodeChar(*p2++);
while (!ret && len--) ret = RtlpUpcaseUnicodeChar(*p1++) - RtlpUpcaseUnicodeChar(*p2++);
}
else
{
@ -2586,13 +2586,13 @@ RtlpIsCharInUnicodeString(
USHORT i;
if (CaseInSensitive)
Char = RtlUpcaseUnicodeChar(Char);
Char = RtlpUpcaseUnicodeChar(Char);
for (i = 0; i < MatchString->Length / sizeof(WCHAR); i++)
{
WCHAR OtherChar = MatchString->Buffer[i];
if (CaseInSensitive)
OtherChar = RtlUpcaseUnicodeChar(OtherChar);
OtherChar = RtlpUpcaseUnicodeChar(OtherChar);
if (Char == OtherChar)
return TRUE;

View file

@ -96,8 +96,8 @@ CompareUnicodeStrings(IN PUNICODE_STRING Prefix,
if (FoundPrefix != FoundString)
{
/* Upcase the characters */
FoundPrefix = RtlUpcaseUnicodeChar(FoundPrefix);
FoundString = RtlUpcaseUnicodeChar(FoundString);
FoundPrefix = RtlpUpcaseUnicodeChar(FoundPrefix);
FoundString = RtlpUpcaseUnicodeChar(FoundString);
/* Compare them again */
if (FoundPrefix != FoundString) break;