From @@ronjgoodm@n @ending from gm@il@com  Sat May 26 05:15:42 2018
From: @@ronjgoodm@n @ending from gm@il@com (Aaron Goodman)
Date: Fri, 25 May 2018 20:15:42 -0700
Subject: [Rd] Buffering in R 3.5 connections causes incorrect data in
 readChar
Message-ID: <CAJvXDNbV+oH_SQPOBP=4S_NiuFZ=0E6ZyzTNKEALz5t7VxfTJA@mail.gmail.com>

I noticed an issue where readChar does not return the correct value after a
call to readline. It appears that readChar is not aware of the buffering,
so it reads from the end of the buffer, rather than the current position in
the file. This is a significant change of behavior from R-3.4.4.

Below is a test case that I used to home in on the problem.

---

p<-"test2.txt"
cat("abcdefg
hijklmn
opqrstu",file=p)

cat("read char after readline (h)\n")
con <- file(p,"r")
invisible(readLines(con,1))
print(readChar(con,1))
close(con)

cat("read char after readline and seek (h)\n")
con <- file(p,"r")
invisible(readLines(con,1))
invisible(seek(con,seek(con)))
print(readChar(con,1))
close(con)

cat("read lines after readline (hijklmn)\n")
con <- file(p,"r")
invisible(readLines(con,1) )
print(readLines(con,1))
close(con)


cat("read line after char (bcdefg):\n")
con <- file(p,"r")
invisible(readChar(con,1) )
print(readLines(con,1))
close(con)

	[[alternative HTML version deleted]]



[Rd] Buffering in R 3.5 connections causes incorrect data in readChar
Aaron Goodman