[Bug 1124436] libtool wrapper corrupts command line on Windows

bugzilla at redhat.com bugzilla at redhat.com
Wed Aug 27 09:45:42 UTC 2014


https://bugzilla.redhat.com/show_bug.cgi?id=1124436



--- Comment #9 from David Woodhouse <dwmw2 at infradead.org> ---
(In reply to Pavel Raiskup from comment #8)
> Ok, I'm little bit closer to the problem, probably.  I'm not familiar with
> windows, so I'm not sure.  Looking at the GetcommandLineW from comment #1
> is not a way to go, I would say, because it does not preserve arguments with
> spaces like './test.exe "arg a" arg_b' to be parsed later.

Que?


#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    HANDLE stdout_h = GetStdHandle(STD_OUTPUT_HANDLE);
    wchar_t **argv_w;
    wchar_t *str;

    if (argc < 2) {
        printf("Need an argument\n");
        return 1;
    }

    printf("argc %d, argv[1] is '%s'\n", argc, argv[1]);

    str = GetCommandLineW();
    argv_w = CommandLineToArgvW(str, &argc);
    printf("argc_w %d, argv_w[1] is '", argc);
    WriteConsoleW(stdout_h, argv_w[1], wcslen(argv_w[1]), NULL, NULL);
    printf("'\n");
    return 0;
} 
[dwoodhou at i7 ~]$ $ wine foo.exe "foo♥ bar"
argc 2, argv[1] is 'foo? bar'
argc_w 2, argv_w[1] is 'foo♥ bar'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
Unsubscribe from this bug https://bugzilla.redhat.com/token.cgi?t=lngI2k3bHa&a=cc_unsubscribe


More information about the mingw mailing list