[Roxygen-devel] Improper escaping of " in R-forge version

Cameron Bracken cameron.bracken at gmail.com
Mon Jun 13 19:18:03 CEST 2011


Hi-

In the development version of roxygen there seems to be a small bug in
the way " characters are escaped. The following code:

    #' percent
    #'
    #' A function
    #'
    #'
    #' @param x
    #' @param use_symbol
    #' @param symbol
    #' @return value is printed
    #' @examples
    #'
    #' percent(.1)
    #'
    percent <- function(x, use_symbol = TRUE,
symbol=ifelse(use_symbol, "", "%")){
      print(paste(x*100,symbol,sep=''))
    }

Will produce:

    \name{percent}
    \alias{percent}
    \title{percent...}
    \usage{percent(x, use_symbol=TRUE, symbol=ifelse(use_symbol, "\", \"%"))}
    \description{percent}
    \details{A function}
    \value{value is printed}
    \arguments{\item{x}{}
    \item{symbol}{}
    \item{use_symbol}{}}
    \examples{percent(.1)}

Which then generates the error in installation:

    Warning: newline within quoted string at percent.Rd:4
    Warning: /Users/cameron/percent.roxygen/man/percent.Rd:7:
unexpected section header '\value'
    Warning: newline within quoted string at percent.Rd:4
    Error in parse_Rd("/Users/cameron/percent.roxygen/man/percent.Rd",
encoding = "unknown",  :
      Unexpected end of input (in " quoted string opened at percent.Rd:4:63)

The output should be:

...
 \usage{percent(x, use_symbol=TRUE, symbol=ifelse(use_symbol, "", "\%"))}
...

This is not a problem in the CRAN version though as a side note in
both versions the % character is not escaped properly. I have isolated
the problem to line 371 in Rd.R and 293 in Rd2.R.

Thanks,
-Cameron


More information about the Roxygen-devel mailing list