roxen.lists.roxen.general

Subject Author Date
incompatibility between 4.5 and 5.0? Stephen R. van den Berg <srb[at]cuci[dot]nl> 22-01-2009
<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?
-- 
Sincerely,
           Stephen R. van den Berg.

"Beware: In C++, your friends can see your privates!"