Author: tfaber Date: Thu Jul 18 20:29:18 2013 New Revision: 59504
URL: http://svn.reactos.org/svn/reactos?rev=59504&view=rev Log: [INFLIB] - Avoid use of swprintf, which is blatantly incompatible with -fshort-wchar CORE-6918 #resolve
Modified: trunk/reactos/lib/inflib/CMakeLists.txt trunk/reactos/lib/inflib/infget.c
Modified: trunk/reactos/lib/inflib/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/inflib/CMakeLists.txt?r... ============================================================================== --- trunk/reactos/lib/inflib/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/lib/inflib/CMakeLists.txt [iso-8859-1] Thu Jul 18 20:29:18 2013 @@ -21,9 +21,6 @@ infhostrtl.c)
add_definitions(-D__NO_CTYPE_INLINES -DINFLIB_HOST) - if(MSVC) - add_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS) - endif() add_library(inflibhost ${GLOBAL_FILES} ${SOURCE}) if(NOT MSVC) add_target_compile_flags(inflibhost "-Wpointer-arith -Wwrite-strings")
Modified: trunk/reactos/lib/inflib/infget.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/inflib/infget.c?rev=595... ============================================================================== --- trunk/reactos/lib/inflib/infget.c [iso-8859-1] (original) +++ trunk/reactos/lib/inflib/infget.c [iso-8859-1] Thu Jul 18 20:29:18 2013 @@ -19,6 +19,18 @@ WCHAR *buffer, 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 */ /* if found, len is set to the substitution length */ static PCWSTR @@ -33,7 +45,7 @@ PINFCONTEXT Context = NULL; PWCHAR Data = NULL; WCHAR ValueName[MAX_INF_STRING_LENGTH +1]; - WCHAR StringLangId[13]; + WCHAR StringLangId[] = L"Strings.XXXX";
if (!*len) /* empty string (%%) is replaced by single percent */ { @@ -48,9 +60,8 @@
if (Inf->LanguageId != 0) { - swprintf(StringLangId, - L"Strings.%04hx", - Inf->LanguageId); + ShortToHex(&StringLangId[sizeof("Strings.") - 1], + Inf->LanguageId);
Status = InfpFindFirstLine(Inf, StringLangId, @@ -58,9 +69,8 @@ &Context); if (Status != INF_STATUS_SUCCESS) { - swprintf(StringLangId, - L"Strings.%04hx", - MAKELANGID(PRIMARYLANGID(Inf->LanguageId), SUBLANG_NEUTRAL)); + ShortToHex(&StringLangId[sizeof("Strings.") - 1], + MAKELANGID(PRIMARYLANGID(Inf->LanguageId), SUBLANG_NEUTRAL));
Status = InfpFindFirstLine(Inf, StringLangId,