[Rd] parser does not catch strings without closing quote
William Dunlap
wdunlap at tibco.com
Fri Sep 2 00:24:19 CEST 2011
Shouldn't the parser complain about unfinished strings in files?
It doesn't and will tack on a newline if there isn't one there.
> withOption <- function(optionList, expr) {
+ oldOption <- options(optionList)
+ on.exit(options(oldOption))
+ expr
+ }
> cat(file=tf<-tempfile(), "\"string without closing quote\n")
> p <- withOption(list(keep.source=FALSE), parse(tf))
> p
expression("string without closing quote\n")
> cat(file=tf<-tempfile(), "\"string with no closing quote nor newline")
> p <- withOption(list(keep.source=FALSE), parse(tf))
> p
expression("string with no closing quote nor newline\n")
It does complain when parsing a character string with the same problem.
> p <- withOption(list(keep.source=FALSE), parse(text="\"unfinished string"))
Error in parse(text = "\"unfinished string") :
2:0: unexpected end of input
1: "unfinished string
^
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
More information about the R-devel
mailing list