[m-rev.] diff: clean up CLP(R) interface

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 9 20:57:40 AEDT 2005


On 03-Mar-2005, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> 
> Clean up the CLP(R) interface.  The main change here is
> to remove deprecated syntax that causes warnings to be
> issued by the 0.12 branch.
...
> Index: dump.m
...
> +:- pred dump.add_single_string(string::in, c_pointer::in, int::in,
>  	c_pointer::out) is det.
> -:- pragma c_code(dump__add_single_string(TheString::in, CLPRString0::in,
> -	Index::in, CLPRString::out), will_not_call_mercury,
> -		"
> -		{
> -			char *CLPRTmp, *StringTmp;
> -
> -			CLPRTmp = (char *) CLPRString0;
> -			StringTmp = (char *) TheString;
> -
> -			CLPRString = CLPRString0;
> -			CLPRTmp += Index;
> -			while (*StringTmp != '\\0')
> -				*CLPRTmp++ = *StringTmp++;
> -			*CLPRTmp = DUMP_SEPARATOR;
> -		}
> -		"
> -		).
> +:- pragma foreign_proc("C",
> +	dump.add_single_string(TheString::in, CLPRString0::in,
> +		Index::in, CLPRString::out),
> +	[promise_pure, will_not_call_mercury],
> +"{
> +	char *CLPRTmp, *StringTmp;
> +
> +	CLPRTmp = (char *) CLPRString0;
> +	StringTmp = (char *) TheString;
> 
> +	CLPRString = CLPRString0;
> +	CLPRTmp += Index;
> +	while (*StringTmp != '\\0') {
> +		*CLPRTmp++ = *StringTmp++;
> +		*CLPRTmp = DUMP_SEPARATOR;
> +	}
> +}").

The line "*CLPRTmp = DUMP_SEPARATOR;" got moved from outside of the
while loop to inside of the while loop.  That looks like a bug to me;
it won't properly terminate CLPRString in the case when TheString is
an empty string.

-- 
Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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