Experiments showed that printf format %ws is supported in all CRT libraries 
except:
- msvcrt20.dll (Visual C++ 2.0 - 2.2)
- msvcrt40.dll (Visual C++ 4.0 - 4.1)
- msvcr40d.dll (Visual C++ 4.0 - 4.1)
- mingw-w64 (__mingw_printf function)

Calling printf("%ws", ...) for above cases just prints "%ws".

So it is supported by crtdll.dll (since first NT 3.10 system lib),
msvcrt10.dll (Visual C++ 1.0), msvcrt.dll (Visual C++ 4.2 and up, and in
system lib) and all later msvcr* and UCRT versions.

It is not supported by mingw-w64 printf functions, so any application
compiled by -D__USE_MINGW_ANSI_STDIO=1 cannot use %ws printf format.

ISO C95+ way to print wchar_t* string is to use %ls format.

So for compatibility with older CRT libs and alignment with ISO C, avoid
using printf %ws format in mingw-w64 codebase. Replce it by ISO %ls.
---
 mingw-w64-crt/stdio/ftruncate64.c                      | 10 +++++-----
 mingw-w64-crt/testcases/t_fseeko64.c                   |  2 +-
 mingw-w64-crt/testcases/t_wreaddir.c                   |  2 +-
 .../winstorecompat/src/GetModuleHandle.c               |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/mingw-w64-crt/stdio/ftruncate64.c 
b/mingw-w64-crt/stdio/ftruncate64.c
index 589645c77e49..ab50ad763fed 100644
--- a/mingw-w64-crt/stdio/ftruncate64.c
+++ b/mingw-w64-crt/stdio/ftruncate64.c
@@ -82,7 +82,7 @@ static LPWSTR xp_normalize_fn(const LPWSTR fn) {
     free(target);
     return NULL;
   }
-  _snwprintf(ret,MAX_PATH,L"%ws%ws",tmplt,fn+wcslen(target));
+  _snwprintf(ret,MAX_PATH,L"%ls%ls",tmplt,fn+wcslen(target));
 
   return ret;
 }
@@ -206,10 +206,10 @@ checkfreespace (const HANDLE f, const ULONGLONG 
requiredspace)
   dirpath = NULL;
 
   vol = FindFirstVolumeW(volumeid,50);
-  /* wprintf(L"%d - %ws\n",wcslen(volumeid),volumeid); */
+  /* wprintf(L"%d - %ls\n",wcslen(volumeid),volumeid); */
   do {
     check = 
GetVolumeInformationW(volumeid,volumepath,MAX_PATH+1,&volumeserial,NULL,NULL,NULL,0);
-    /* wprintf(L"GetVolumeInformationW %d id %ws path %ws error 
%d\n",check,volumeid,volumepath,GetLastError()); */
+    /* wprintf(L"GetVolumeInformationW %d id %ls path %ls error 
%d\n",check,volumeid,volumepath,GetLastError()); */
     if(volumeserial == fileinfo.dwVolumeSerialNumber) {
       dirpath = volumeid; 
       break;
@@ -320,8 +320,8 @@ int main(){
 /*  path = xp_getfilepath((HANDLE)_get_osfhandle(f),sz);
   dir = getdirpath(path);
   GetDiskFreeSpaceExW(dir,&freespace,NULL,NULL);
-  wprintf(L"fs - %ws\n",path);
-  wprintf(L"dirfs - %ws\n",dir);
+  wprintf(L"fs - %ls\n",path);
+  wprintf(L"dirfs - %ls\n",dir);
   wprintf(L"free - %I64u\n",freespace.QuadPart);
   free(dir);
   free(path);*/
diff --git a/mingw-w64-crt/testcases/t_fseeko64.c 
b/mingw-w64-crt/testcases/t_fseeko64.c
index 353b29272621..4d57f22343d6 100644
--- a/mingw-w64-crt/testcases/t_fseeko64.c
+++ b/mingw-w64-crt/testcases/t_fseeko64.c
@@ -54,7 +54,7 @@ int main(int argc, char **argv){
   SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,0,szPath);
   path = _wtempnam(szPath, L"mingw-w64-lfs64-test-");
 #ifdef debugtest
-  wprintf(L"Path: %ws\n", path);
+  wprintf(L"Path: %ls\n", path);
 #endif
   if (!path) return 1;
 
diff --git a/mingw-w64-crt/testcases/t_wreaddir.c 
b/mingw-w64-crt/testcases/t_wreaddir.c
index afb5bebd0969..93f3fc298cd4 100644
--- a/mingw-w64-crt/testcases/t_wreaddir.c
+++ b/mingw-w64-crt/testcases/t_wreaddir.c
@@ -13,7 +13,7 @@ int main(int argc, char **argv)
   if (!h)
     return 1;
   while ((di = _wreaddir (h)) != NULL)
-    printf ("%ws\n", di->d_name);
+    printf ("%ls\n", di->d_name);
   _wclosedir (h);
   return 0;
 }
diff --git a/mingw-w64-libraries/winstorecompat/src/GetModuleHandle.c 
b/mingw-w64-libraries/winstorecompat/src/GetModuleHandle.c
index 0567da8915fb..dbd9f01d580f 100644
--- a/mingw-w64-libraries/winstorecompat/src/GetModuleHandle.c
+++ b/mingw-w64-libraries/winstorecompat/src/GetModuleHandle.c
@@ -48,7 +48,7 @@ HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
 {
     wchar_t msg[512];
 
-    _snwprintf(msg, 511, L"GetModuleHandleW (%ws) call suppressed\n", 
lpModuleName);
+    _snwprintf(msg, 511, L"GetModuleHandleW (%ls) call suppressed\n", 
lpModuleName);
     msg[511] = '\0';
 
     OutputDebugStringW(msg);
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to