[m-rev.] for review: fix library intialisers / finalisers

Julien Fischer juliensf at cs.mu.OZ.AU
Wed May 17 14:30:28 AEST 2006


On Wed, 17 May 2006, Zoltan Somogyi wrote:

> On 16-May-2006, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:

> > +    io.write_strings(DepStream, [
> > +        "\t$(MKLIBINIT) -k ", "$(", MakeVarName, ".cs)", " >> ",
> > +        InitFileName, "\n"
> > +    ], !IO),
> > +
> and later

> > +# Program used to create the .init file for a library.
> > +# This is usually just mkinit invoked with the `-k' option.
> > +MKLIBINIT	= mkinit
>
> Wouldn't it make more sense to have
>
> MKLIBINIT	= mkinit -k
>
> and then delete the -k from after the reference to $(MKLIBINIT) ?
>

Done.

> > -    do_path_search();
> > -    output_headers();
> > +    if (output_lib_init == MR_TRUE) {
> > +        output_lib_init_file();         /* Output a .init file. */
> > +    } else {
> > +        output_init_program();          /* Output a _init.c file. */
> > +    }
>
> The condition is a bug; it should be
>
> 	if (output_lib_init)

Fixed.

> > -    if (need_initialization_code) {
> > -        printf("#define MR_MAY_NEED_INITIALIZATION\n\n");
> > +    if (num_errors > 0) {
> > +        fputs("/* Force syntax error, since there were */\n", stdout);
> > +        fputs("/* errors in the generation of this file */\n", stdout);
> > +        fputs("#error \"You need to remake this file\"\n", stdout);
> > +        if (output_file_name != NULL) {
> > +            (void) fclose(stdout);
> > +            (void) remove(output_file_name);
> > +        }
> > +        return EXIT_FAILURE;
> > +    }
> > +
> > +    return EXIT_SUCCESS;
>
> How do you force a syntax error in a .init file?

I didn't write that code, so I'm not sure what the original intention was.

> I think this could should be in output_init_program, and some more tailored
> technique should be employed in output_lib_init_file.

Are you referring to the error handling code above or do you mean that we
should have two separate programs to handle this?

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list