gallium/os: call "ANSI" version of GetCommandLine
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 1 Jun 2020 15:23:46 +0000 (17:23 +0200)
committerMarge Bot <eric+marge@anholt.net>
Sat, 20 Jun 2020 06:51:54 +0000 (06:51 +0000)
commiteda684142050cf54b86f62e147edee921c65fa7e
tree953478b1590c38790b04dd267a7b82c55774df96
parent04f77595f0bb5adc31e9e0ff2114c1ed5b60371d
gallium/os: call "ANSI" version of GetCommandLine

The GetCommandLine API comes in two versions, GetCommandLineA (which
returns "ANSI" results), and GetCommandLineW which returns UTF-16
("WIDE") results. Then finally, windows.h provides a wrapper-macro that
defines GetCommandLine to either of the two, based on the setting of
the UNICODE macro.

More information about this mechanism can be found here:
https://docs.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api

For some reason, the UNICODE macro is set during build, even if we're
not explicitly setting it. This leads to us trying to cast a UTF-16
result to a char-pointer, which is obviously not going to do the right
thing.

So let's be defensive, and just call GetCommandLineA directly instead.
This avoids us depending on the setting of the UNICODE-macro in the
first place.

Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5497>
src/gallium/auxiliary/os/os_process.c