[m-rev.] for post-commit review: improve consistency of usage message for mmc, mprof and mcov

Julien Fischer jfischer at opturion.com
Mon Sep 4 19:16:04 AEST 2023


On Mon, 4 Sep 2023, Zoltan Somogyi wrote:

> On 2023-09-04 17:20 +10:00 AEST, "Julien Fischer" <jfischer at opturion.com> wrote:
>> @@ -3152,21 +3151,31 @@ long_usage(ProgressStream, !IO) :-
>>      % copies of the long usage message. We can print both a short and along
>>      % usage message, but there is no simple way to avoid that.
>>      library.version(Version, Fullarch),
>> -    Template =
>> -        "Name: mmc -- Melbourne Mercury Compiler, version %s on %s\n" ++
>> -        "Copyright (C) 1993-2012 The University of Melbourne\n" ++
>> -        "Copyright (C) 2013-2023 The Mercury team\n" ++
>> -        "Usage: mmc [<options>] <arguments>\n" ++
>> -        "Arguments:\n" ++
>> -        "\tArguments ending in `.m' are assumed to be source file names.\n" ++
>> -        "\tArguments that do not end in `.m' " ++
>> -            "are assumed to be module names.\n" ++
>> -        "\tArguments in the form @file " ++
>> -            "are replaced with the contents of the file.\n",
>> -    io.format(ProgressStream, Template, [s(Version), s(Fullarch)], !IO),
>> +    io.format(ProgressStream,
>> +        "Name: mmc - Melbourne Mercury Compiler, version %s, on %s\n",
>> +        [s(Version), s(Fullarch)], !IO),
>> +    write_copyright_notice(ProgressStream, !IO),
>> +    io.write_strings(ProgressStream, [
>> +        "Usage: mmc [<options>] <arguments>\n",
>> +        "Arguments:\n",
>> +        "\tArguments ending in `.m' are assumed to be source file names.\n",
>> +        "\tArguments that do not end in `.m' ",
>> +            "are assumed to be module names.\n",
>> +        "\tArguments in the form @file ",
>> +            "are replaced with the contents of the file.\n"
>> +    ], !IO),
>
> Why not use write_prefixed_lines?

Shall do.

>> +:- pred write_copyright_notice(io.text_output_stream::in, io::di, io::uo)
>> +    is det.
>> +
>> +write_copyright_notice(Stream, !IO) :-
>> +    io.write_strings(Stream, [
>> +        "Copyright (C) 1993-2012 The University of Melbourne\n",
>> +        "Copyright (C) 2013-2023 The Mercury team\n"
>> +    ], !IO).
>
> This code is still repeated in several places.

It isn't - the years differ between the three programs.

Julien.


More information about the reviews mailing list