roxen.lists.roxen.general

Subject Author Date
Re: incompatibility between 4.5 and 5.0? David Hunter <dhunter[at]pauanui[dot]net[dot]nz> 23-01-2009
Would &var.tmp; == ({RXML.empty, "hello"})  be expect if <append
type='array'> in 5.0 ?

David Hunter.


On 23/01/09 3:53 AM, "Stephen R. van den Berg" <<srb[at]cuci.nl>> wrote:

> <set variable="var.tmp" />
> 
> which I use a lot to actually set the variable to RXML.empty, behaves
> differently in conjunction with <append /> in 5.0.
> 
> Following the above set with:
> 
> <append variable="var.tmp" value="hello" />
> 
> Results in 4.5:   &var.tmp; == "hello"
> Results in 5.0:   &var.tmp; == ({RXML.empty, "hello"})
> 
> which breaks a lot of code (obviously).
> 
> Inspecting the code, I see that the problem lies in TagAppend:
> 
> + if (zero_type (value = RXML.user_get_var (args->variable, args->scope)))
> +   value = RXML.nil;
> + 
> + value_type = 0;
> + if (value != RXML.nil) {
> +   value_type = RXML.type_for_value (value);
> +   if (!value_type || !value_type->sequential) {
> +     value = ();
> +     value_type = RXML.t_array;
> +   }
> + }
> 
> zero_type(RXML.empty) is false, therefore value is not set to RXML.nil,
> and hence the RXML.empty gets autocasted to an array.
> 
> Wouldn't it be better to fix it such that
> + if (value != RXML.nil) {
> reads
> + if (value != RXML.nil && value != RXML.empty) {
> instead?