From 16e53ec01ef551c3df5880248c87d2e23ffdf014 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 7 Jun 2021 18:09:48 -0400
Subject: [PATCH] Fix build with strict wchar on msvc

---
 indra/llwindow/llwindowwin32.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 49b90428e4f..4b8ea59ed42 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -819,7 +819,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
 	//	}
 
     // SL-12971 dual GPU display
-    DISPLAY_DEVICEA display_device;
+    DISPLAY_DEVICEW display_device;
     int             display_index = -1;
     DWORD           display_flags = 0; // EDD_GET_DEVICE_INTERFACE_NAME ?
     const size_t    display_bytes = sizeof(display_device);
@@ -830,23 +830,23 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
         {
             // CHAR DeviceName  [ 32] Adapter name
             // CHAR DeviceString[128]
-            CHAR text[256];
+            WCHAR text[256];
 
-            size_t name_len = strlen(display_device.DeviceName  );
-            size_t desc_len = strlen(display_device.DeviceString);
+            size_t name_len = wcslen(display_device.DeviceName  );
+            size_t desc_len = wcslen(display_device.DeviceString);
 
-            CHAR *name = name_len ? display_device.DeviceName   : "???";
-            CHAR *desc = desc_len ? display_device.DeviceString : "???";
+            const WCHAR* name = name_len ? display_device.DeviceName   : TEXT("???");
+			const WCHAR* desc = desc_len ? display_device.DeviceString : TEXT("???");
 
-            sprintf(text, "Display Device %d: %s, %s", display_index, name, desc);
-            LL_INFOS("Window") << text << LL_ENDL;
+			_snwprintf(text, 256, TEXT("Display Device %d: %s, %s"), display_index, name, desc);
+            LL_INFOS("Window") << ll_convert_wide_to_string(text) << LL_ENDL;
         }
 
-        ::ZeroMemory(&display_device,display_bytes);
+        ::ZeroMemory(&display_device, display_bytes);
         display_device.cb = display_bytes;
 
         display_index++;
-    }  while( EnumDisplayDevicesA(NULL, display_index, &display_device, display_flags ));
+    }  while( EnumDisplayDevicesW(NULL, display_index, &display_device, display_flags ));
 
     LL_INFOS("Window") << "Total Display Devices: " << display_index << LL_ENDL;
 
-- 
GitLab