R-alpha: Two bugs reading data files

Kurt Hornik (Kurt.Hornik@ci.tuwien.ac.at)
Wed, 29 Jan 1997 16:52:35 +0100


Date: Wed, 29 Jan 1997 16:52:35 +0100
Message-Id: <199701291552.QAA01555@aragorn.ci.tuwien.ac.at>
From: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
To: Peter Dalgaard BSA <pd@kubism.ku.dk>
Subject: R-alpha: Two bugs reading data files
In-Reply-To: <x2d8uofubp.fsf@bush.kubism.ku.dk>

>>>>> On 29 Jan 1997 15:07:54 +0100,
>>>>> Peter Dalgaard BSA <pd@kubism.ku.dk> said:

> 2) This is a good ol' plain bug-a-boo:

> scan('data.txt',list("",0,"","",0,0,"")) works first time only

>> scan('data.txt',list("","","","",0,0,""))->j
> Read 240 lines
>> scan('data.txt',list("","","","",0,0,""))->j
> Read 0 lines
>> scan('data.txt')->j
> Error: "scan" expected a real got "L"
>> scan('data.txt',list("","","","",0,0,""))->j
> Read 240 lines

> after the 2nd command, j contains vectors of length 1000, full of
> garbage. Only happens when 2nd argument is a list.

Peter,

Here is a quick patch for this and some more scan() problems.  All have
made it into 0.16 which should be out soon.

*** src/main/scan.c.orig	Fri Dec 27 12:24:51 1996
--- src/main/scan.c	Fri Dec 27 12:25:18 1996
*************** done:
*** 390,399 ****
--- 390,401 ----
  	}
  	if(!quiet) REprintf("Read %d lines\n", n);
  
+ 	/*
  	if (n == maxitems ) {
  		UNPROTECT(1);
  		return ans;
  	}
+ 	*/
  
  	a = ans;
  	for (i = 0; i < nc; i++) {

*** src/main/scan.c.orig	Fri Jan 17 23:54:04 1997
--- src/main/scan.c	Fri Jan 17 23:54:46 1997
*************** static SEXP scanFrame(SEXP what, int max
*** 313,318 ****
--- 313,319 ----
  
  	n = 0; linesread = 0; colsread=0;
  	badline = 0;
+ 	bch = 1;
  
  	if (ttyflag) REprintf("1: ");
  

*** src/main/scan.c.orig	Sun Jan 19 19:38:26 1997
--- src/main/scan.c	Sun Jan 19 19:40:33 1997
*************** SEXP do_countfields(SEXP call, SEXP op, 
*** 560,566 ****
  		if(c == EOF)  {
  			if(nfields != 0) {
  				INTEGER(ans)[nlines] = nfields;
- 				nlines++;
  			}
  			else nlines--;
  			goto donecf;
--- 560,565 ----

-k
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-