[m-dev.] for review: string__fmt

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Aug 17 09:45:54 AEST 2000


On 16-Aug-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> 
> Avoid the cast to long before printing integers.  This cast is
> problematic when printing negative integers with the format string "%x".
> For instance on the alpha a long is 64 bits and a MR_integer is 32 bits,
> so printing -31 is printed as ffffffffffffffe1 instead of ffffffe1.

That change looks good.  Just a couple of suggestions:

> +:- func int_length_modifier = string.
> +:- pragma c_code(int_length_modifier = (LengthModifier::out),
> +		[will_not_call_mercury, thread_safe], "{
> +	MR_make_aligned_string_copy(LengthModifier,
> +			MR_INTEGER_LENGTH_MODIFIER);
> +}").

You should use MR_make_aligned_string() rather than
MR_make_aligned_string_copy(); that will avoid some unnecessary
memory allocation.

> +++ runtime/mercury_conf.h.in	2000/08/16 16:19:01
> @@ -45,6 +45,11 @@
>  */
>  #undef	MR_WORD_TYPE
>  
> +/* 
> +** MR_INTEGER_LENGTH_MODIFIER: the length modifier for an MR_Integer.
> +*/
> +#undef MR_INTEGER_LENGTH_MODIFIER
> +

I suggest you make the comment a bit more descriptive:

	s/the length modifier/the printf() length modifier/

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list