[Rd] (HP-UX) scan: last line gets duplicated (PR#790)

Peter Kleiweg kleiweg@let.rug.nl
Fri, 22 Dec 2000 22:15:36 +0100 (CET)


ripley@stats.ox.ac.uk skriver...

> On Fri, 22 Dec 2000 kleiweg@let.rug.nl wrote:

> > Prof Brian D Ripley wrote:
> > 
> > > This bug PR#672, also reported from your institution.
> > 
> > That would be me. I reported this bug before, for R version
> > 1.1.0
> 
> It *is* in the BUGS list shipped with 1.2.0, so why send it in again
> with no references to the earlier one?

Well, that was a bug in 1.1.0, this is the same bug in 1.2.0. I
didn't check the BUGS list, didn't notice there was such a file.
I'm sorry.

> It might be a compiler bug, so perhaps you would like to try compiling
> with gcc.

Usually, bugs aren't. Usually, it's that one compiler just
happens to produce code and data that won't generate an
exceptional situation you just hadn't thought of, and you won't
notice the error until you use another compiler.

Which seems to be the case here.

I fixed the bug. Luckily, I didn't have to resort to using the
HP debugger. Inspecting the code was enough to locate the
problem, once I noticed the problem occurs only when stripping
white space is selected. Here is the fix:

*** src/main/scan.c	Sat Dec  2 19:42:25 2000
--- src/main/scan.c.new	Fri Dec 22 21:51:44 2000
***************
*** 240,248 ****
      }
   donefill:
      if (strip) {
! 	while (isspace((int)*--bufp))
! 	    ;
! 	bufp++;
      }
      *bufp = '\0';
      return filled;
--- 240,247 ----
      }
   donefill:
      if (strip) {
!         while (bufp > buffer && isspace((int)(*bufp - 1)))
! 	    bufp--;
      }
      *bufp = '\0';
      return filled;



You can see what the problem was. The faulty code doesn't
prevent to test whether the characters *before* the start of the
buffer are white space, which can be anything.

-- 
Peter Kleiweg
http://www.let.rug.nl/~kleiweg/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._