bug in setting length of a list (PR#401)
saikat@stat.wisc.edu
saikat@stat.wisc.edu
Thu, 20 Jan 2000 20:02:50 +0100 (MET)
Setting the length of a list object nullifies the whole list!
> foo <- list(a=1)
> foo
$a
[1] 1
> length(foo) <- 2
> foo
[[1]]
NULL
[[2]]
NULL
The fix is to patch R/src/main/builtin.c with the following.
===================================================================
--- r-devel/src/main/builtin.c Sat Dec 11 15:11:05 1999
+++ r-devel.mod/src/main/builtin.c Wed Jan 19 18:01:10 2000
@@ -508,6 +508,14 @@
CAR(t) = CAR(x);
TAG(t) = TAG(x);
}
+ case VECSXP:
+ for (i = 0; i < len; i++)
+ if (i < lenx) {
+ VECTOR(rval)[i] = VECTOR(x)[i];
+ if (xnames != R_NilValue)
+ STRING(names)[i] = STRING(xnames)[i];
+ }
+ break;
}
if (isVector(x) && xnames != R_NilValue)
setAttrib(rval, R_NamesSymbol, names);
===================================================================
--please do not edit the information below--
Version:
platform = i686-unknown-linux
arch = i686
os = linux
system = i686, linux
status = Under development (unstable)
major = 0
minor = 99.0
year = 2000
month = January
day = 20
language = R
Search Path:
.GlobalEnv, Autoloads, package:base
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._