Thread overview | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 04, 2011 [Issue 5926] New: D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5926 Summary: D2 shows empty command line on Windows 98 SE Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: major Priority: P2 Component: druntime AssignedTo: nobody@puremagic.com ReportedBy: verylonglogin.reg@gmail.com --- Comment #0 from Denis <verylonglogin.reg@gmail.com> 2011-05-04 03:31:28 PDT --- Created an attachment (id=959) Test case The problem is in file druntime\src\rt\dmain2.d Windows Windows 98 SE really has GetCommandLineW function, but hasn't CommandLineToArgvW. So dmd v2.052 compiled printArgsD.d always shows args.length is 0 (dmd v1.067 compiled works fine). It is sad to live without command line or to have own CommandLineToArgvW-like function in every small console util... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg@gmx.com --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-05-04 04:15:17 PDT --- I certainly won't say that we aren't going to worry about having druntime or Phobos work with Windows 98, but there were a _lot_ of system functions added to Windows with Win2k, and it would be incredibly constraining to have to make it so that everything worked with Windows 98. std.datetime definitely won't, and it can't. And realistically, very few people are using anything prior to Windows XP at this point, let alone something as old as Windows 98, so it's not necessarily realistic to expect that everything work with Windows 98. Now, something as basic as the command line arguments not working is at least worth looking into. However, I'd strongly argue against making it work if it resulted in worse code than what we have now, thereby restricting code on current operating systems just to maintain compatability with an ancient one. So, I'd say whether this is worth fixing strongly depends on what is required to fix the problem and what impact it has on anything built on a more modern OS. However, it is true that we don't want to close such doors if we can reasonably avoid it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #2 from Denis <verylonglogin.reg@gmail.com> 2011-05-04 06:50:01 PDT --- Created an attachment (id=960) getCommandLineArgs function with it's unittests -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #3 from Denis <verylonglogin.reg@gmail.com> 2011-05-04 06:52:27 PDT --- I wrote a function getCommandLineArgs and tested it on all such arguments: [aZяЫ \t\\"]{1,6} | [\r\nЫ \t\\"]{1,6} and others (in test.d). It's output was equal to CommandLineToArgvW. Please, add it to dmain2.d instead of CommandLineToArgvW at least if second is not available on current system. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-05-04 10:40:37 PDT --- The std.file functions have a special code path in them for earlier Windows versions. I believe this is a reasonable approach. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #5 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-05-04 11:04:14 PDT --- That definitely sounds like a good approach where it can be done. And in this case, it looks like that should be possible. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 Sean Kelly <sean@invisibleduck.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |sean@invisibleduck.org --- Comment #6 from Sean Kelly <sean@invisibleduck.org> 2011-05-04 11:38:40 PDT --- Thanks! However, when this routine is run, the GC is not yet initialized, so array operations won't work. What would be ideal is if the new function were a functional clone of CommandLineToArgvW, so the surrounding logic could be reused. ie. wchar_t** doCommandLineToArgvW(wchar_t* cmdLine, int* numArgs) { if (GetVersion() < 0x80000000) { return CommandLineToArgvW(cmdLine, numArgs); } // TODO: parse manually here. } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2011-05-04 14:01:50 PDT --- Why is this code there to begin with anyway? The C runtime already sets up argc/argv. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #8 from Sean Kelly <sean@invisibleduck.org> 2011-05-04 16:36:31 PDT --- It's there because the argv data on Windows is in code pages instead of Unicode, and it seemed easiest to let the OS deal with the conversion. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 05, 2011 [Issue 5926] D2 shows empty command line on Windows 98 SE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=5926 --- Comment #9 from Walter Bright <bugzilla@digitalmars.com> 2011-05-04 17:56:09 PDT --- (In reply to comment #8) > It's there because the argv data on Windows is in code pages instead of Unicode, and it seemed easiest to let the OS deal with the conversion. Here's the code from druntime/src/rt/dmain2.d in question: wchar_t* wcbuf = GetCommandLineW(); size_t wclen = wcslen(wcbuf); int wargc = 0; wchar_t** wargs = CommandLineToArgvW(wcbuf, &wargc); assert(wargc == argc); char* cargp = null; size_t cargl = WideCharToMultiByte(65001, 0, wcbuf, wclen, null, 0, null, 0); cargp = cast(char*) alloca(cargl); args = ((cast(char[]*) alloca(wargc * (char[]).sizeof)))[0 .. wargc]; 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); wargs = null; wargc = 0; Since the only thing necessary is to convert argv[] from code pages to utf8, there is no need for the calls to GetCommandLineW and CommandLineToArgvW, and so no compatibility problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation