mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:52:56 +00:00
[INFLIB]
- Avoid use of swprintf, which is blatantly incompatible with -fshort-wchar CORE-6918 #resolve svn path=/trunk/; revision=59504
This commit is contained in:
parent
a937917f7f
commit
cc5e6fe6a6
2 changed files with 17 additions and 10 deletions
|
@ -21,9 +21,6 @@ else()
|
||||||
infhostrtl.c)
|
infhostrtl.c)
|
||||||
|
|
||||||
add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST)
|
add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST)
|
||||||
if(MSVC)
|
|
||||||
add_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS)
|
|
||||||
endif()
|
|
||||||
add_library(inflibhost ${GLOBAL_FILES} ${SOURCE})
|
add_library(inflibhost ${GLOBAL_FILES} ${SOURCE})
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_target_compile_flags(inflibhost "-Wpointer-arith -Wwrite-strings")
|
add_target_compile_flags(inflibhost "-Wpointer-arith -Wwrite-strings")
|
||||||
|
|
|
@ -19,6 +19,18 @@ InfpSubstituteString(PINFCACHE Inf,
|
||||||
WCHAR *buffer,
|
WCHAR *buffer,
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
|
|
||||||
|
static void
|
||||||
|
ShortToHex(PWCHAR Buffer,
|
||||||
|
USHORT Value)
|
||||||
|
{
|
||||||
|
WCHAR HexDigits[] = L"0123456789abcdef";
|
||||||
|
|
||||||
|
Buffer[0] = HexDigits[Value >> 12 & 0xf];
|
||||||
|
Buffer[1] = HexDigits[Value >> 8 & 0xf];
|
||||||
|
Buffer[2] = HexDigits[Value >> 4 & 0xf];
|
||||||
|
Buffer[3] = HexDigits[Value >> 0 & 0xf];
|
||||||
|
}
|
||||||
|
|
||||||
/* retrieve the string substitution for a given string, or NULL if not found */
|
/* retrieve the string substitution for a given string, or NULL if not found */
|
||||||
/* if found, len is set to the substitution length */
|
/* if found, len is set to the substitution length */
|
||||||
static PCWSTR
|
static PCWSTR
|
||||||
|
@ -33,7 +45,7 @@ InfpGetSubstitutionString(PINFCACHE Inf,
|
||||||
PINFCONTEXT Context = NULL;
|
PINFCONTEXT Context = NULL;
|
||||||
PWCHAR Data = NULL;
|
PWCHAR Data = NULL;
|
||||||
WCHAR ValueName[MAX_INF_STRING_LENGTH +1];
|
WCHAR ValueName[MAX_INF_STRING_LENGTH +1];
|
||||||
WCHAR StringLangId[13];
|
WCHAR StringLangId[] = L"Strings.XXXX";
|
||||||
|
|
||||||
if (!*len) /* empty string (%%) is replaced by single percent */
|
if (!*len) /* empty string (%%) is replaced by single percent */
|
||||||
{
|
{
|
||||||
|
@ -48,9 +60,8 @@ InfpGetSubstitutionString(PINFCACHE Inf,
|
||||||
|
|
||||||
if (Inf->LanguageId != 0)
|
if (Inf->LanguageId != 0)
|
||||||
{
|
{
|
||||||
swprintf(StringLangId,
|
ShortToHex(&StringLangId[sizeof("Strings.") - 1],
|
||||||
L"Strings.%04hx",
|
Inf->LanguageId);
|
||||||
Inf->LanguageId);
|
|
||||||
|
|
||||||
Status = InfpFindFirstLine(Inf,
|
Status = InfpFindFirstLine(Inf,
|
||||||
StringLangId,
|
StringLangId,
|
||||||
|
@ -58,9 +69,8 @@ InfpGetSubstitutionString(PINFCACHE Inf,
|
||||||
&Context);
|
&Context);
|
||||||
if (Status != INF_STATUS_SUCCESS)
|
if (Status != INF_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
swprintf(StringLangId,
|
ShortToHex(&StringLangId[sizeof("Strings.") - 1],
|
||||||
L"Strings.%04hx",
|
MAKELANGID(PRIMARYLANGID(Inf->LanguageId), SUBLANG_NEUTRAL));
|
||||||
MAKELANGID(PRIMARYLANGID(Inf->LanguageId), SUBLANG_NEUTRAL));
|
|
||||||
|
|
||||||
Status = InfpFindFirstLine(Inf,
|
Status = InfpFindFirstLine(Inf,
|
||||||
StringLangId,
|
StringLangId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue