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

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Dec 15 12:53:34 AEDT 2011


Hi,

On Wed, 14 Dec 2011, Peter Wang wrote:

> This can be applied to a later 11.07 release if you like.
> --
>
> Branches: main, 11.07
>
> Support Unicode characters in command line arguments on Windows.
>
> util/mkinit.c:
> 	Retrieve the array of wide-character command-line argument
> 	strings with GetCommandLineW and CommandLineToArgvW.
>
> 	Convert the strings to UTF-8.
>
> 	Pass the array of UTF-8 argument strings to mercury_main as usual.

argv[0] behaves oddly in if the name of the program is directory
qualified and some of the directory components are quoted.  With the
Mercury program foo (below) I get:

    c:\> c:\ws\foo.exe

PRINTS: c:\ws\foo.exe

    c:\> "c:\ws"\foo.exe

PRINTS: c:\ws
         \foo.exe

as opposed to the following with the C program bar (also below)

   c:\> c:\ws\bar.exe

PRINTS: c:\ws\bar.exe

   c:\> "c:\ws"\bar.exe

PRINTS c:\ws\bar.exe

Variations on the above produce equally odd results.

Julien.

%---- foo.m ---%
:- module foo.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
     io.progname("<<unavailable>>", ProgName, !IO),
     io.write_string("ProgName, !IO),
     io.nl(!IO),
     io.command_line_arguments(Args, !IO),
     io.write_list(Args, "\n", io.write_string, !IO).


/*** bar.c ***/
#include <stdio.h>
int main(int argc, char **argv(
{
    int i;
    for (i = 0; i < argc; i++) {
      printf("%s\n", argv[i]);
    }
    return 0;
}
--------------------------------------------------------------------------
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