[Issue 5926] D2 shows empty command line on Windows 98 SE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 4 23:28:19 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5926
--- Comment #13 from Denis <verylonglogin.reg at gmail.com> 2011-05-04 23:24:27 PDT ---
(From update of attachment 961)
version (Windows)
{
wchar_t* wcbuf = GetCommandLineW();
size_t wclen = wcslen(wcbuf);
char* cargp = null;
size_t cargl = WideCharToMultiByte(65001, 0, wcbuf, wclen, null, 0,
null, 0);
cargp = cast(char*) alloca(cargl);
args = ((cast(char[]*) alloca(argc * (char[]).sizeof)))[0 .. argc];
if(GetVersion() < 0x80000000) //useWfuncs
{
int wargc = 0;
wchar_t** wargs = CommandLineToArgvW(wcbuf, &wargc);
assert(wargc == argc);
for (size_t i = 0, p = 0; i < wargc; i++)
{
int wlen = wcslen(wargs[i]);
int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen,
null, 0, null, 0);
args[i] = cargp[p .. p+clen];
p += clen; assert(p <= cargl);
WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, &args[i][0],
clen, null, 0);
}
LocalFree(wargs);
}
else
{
size_t wargSize = (wclen + 1) * wchar_t.sizeof;
wchar_t* warg = cast(wchar_t*) malloc(wargSize); //or alloca is
better?
for (size_t i = 0, p = 0; i < argc; i++)
{
int wlen = MultiByteToWideChar(0, 0, argv[i], -1, warg,
wargSize);
int clen = WideCharToMultiByte(65001, 0, &warg[0], wlen, null,
0, null, 0);
args[i] = cargp[p .. p+clen];
p += clen; assert(p <= cargl);
WideCharToMultiByte(65001, 0, &warg[0], wlen, &args[i][0],
clen, null, 0);
}
free(warg); //if alloca isn't better
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list