Hans Leidekker (@hans) commented about programs/whoami/main.c:
+ + status = ConvertSidToStringSidW(sid, &sid_string); + if (!status) + { + ERR("ConvertSidToStringSidW failed, error %ld\n", GetLastError()); + return 1; + } + + /* TODO: prettify the table */ + unicode_wprintf(L"\n"); + unicode_wprintf(L"%ls\n", L"USER INFORMATION"); + unicode_wprintf(L"%ls\n", L"----------------"); + unicode_wprintf(L"\n"); + unicode_wprintf(L"%ls %ls\n", L"User Name ", L"SID"); + unicode_wprintf(L"%ls %ls\n", L"=========================", L"==============================="); + unicode_wprintf(L"%-25ls %ls\n", name, sid_string); That would look like this:
output_write(L"USER INFORMATION\n----------------\n", -1);
output_write(L"User Name", wcslen(L"User Name"));
for (i = 0; i <= max(wcslen(name), wcslen(L"User Name")) - wcslen(L"User Name"); i++) output_write(L" ", 1);
output_write(L"SID\n", -1);
for (i = 0; i < wcslen(name); i++) output_write(L"=", 1);
output_write(L" ", 1);
for (i = 0; i < wcslen(sid_string); i++) output_write(L"=", 1);
output_write(L"\n", 1);
output_write(name, -1);
output_write(L" ", 1);
output_write(sid_string, -1);
output_write(L"\n", 1);
As you can see, there's no need for printf formatting and copying strings. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3473#note_41802