[m-rev.] for review: unicode command line arguments on windows

Julien Fischer juliensf at csse.unimelb.edu.au
Sat Dec 17 15:06:06 AEDT 2011



On Sat, 17 Dec 2011, Peter Wang wrote:

>> @@ -539,17 +538,15 @@
>>       ** Convert wide-character representation of the command line
>>       ** arguments to UTF-8.
>>       */
>> -    "#ifdef MR_WIN32\n"
>> +    "#if defined(MR_MSVC)\n"
>>       "static char **\n"
>> -    "mercury_win32_args(int *argc_ptr)\n"
>> +    "mercury_msvc_args(int argc, wchar_t **wargv)\n"
>>       "{\n"
>> -    "   LPWSTR  *wargv;\n"
>>       "   char    **argv;\n"
>>       "   int     i;\n"
>>       "\n"
>> -    "   wargv = CommandLineToArgvW(GetCommandLineW(), argc_ptr);\n"
>> -    "   argv = MR_GC_NEW_ARRAY(char *, (*argc_ptr + 1));\n"
>> -    "   for (i = 0; i < (*argc_ptr); i++) {\n"
>> +    "   argv = MR_GC_NEW_ARRAY(char *, argc + 1);\n"
>> +    "   for (i = 0; i < argc; i++) {\n"
>>       "       int bytes = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,\n"
>>       "           NULL, 0, NULL, NULL);\n"
>>       "       argv[i] = MR_GC_malloc(bytes);\n"
>
> Actually, we are calling GC_malloc before the GC is initialised.
> I think we need to use plain malloc to be safe in some situations(?).

I've replaced the calls the MR_GC_malloc with MR_malloc and so forth ...

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list