From georgi@bo@hn@kov @ending from m@nche@ter@@c@uk  Mon May 14 23:23:57 2018
From: georgi@bo@hn@kov @ending from m@nche@ter@@c@uk (Georgi Boshnakov)
Date: Mon, 14 May 2018 21:23:57 +0000
Subject: [Rd] Rd parser throws error for user macros invoked with empty
 argument
Message-ID: <438D2EC9EAFE5946B2D5864670EA468E018F659ED0@MBXP01.ds.man.ac.uk>

Bug or feature?

I get the following error from parse_Rd() when a user Rd macro (including system ones) is invoked with empty argument {},
eg \mymacro{}:

Error in tools::parse_Rd(fn) :
  Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'

A full example is further below with the system macro \CRANpkg{}. In this example it doesn't make sense to use empty argument but the error is not specific to this particular macro.

------
Georgi Boshnakov


Create an Rd file containing system macro \CRANpkg{bibtex}, parse_Rd() is ok:

=================
fn <- tempfile()
writeLines("\\name{dummyfun}
\\alias{dummyfun}
\\title{Dummy title}
\\description{Dummy description}
\\usage{
dummyfun(x, ...)
}
\\arguments{
  \\item{x}{a value.}
  \\item{\\dots}{further arguments.}
}
\\details{
    \\CRANpkg{bibtex}
}
", fn)

> tools::parse_Rd(fn)
...
\details{
    \href{{https://CRAN.R-project.org/package=bibtex}{\pkg{bibtex}}}
}

================

With empty argument - \CRANpkg{} - Rd parser throws error. Of course it is silly in this example but I have used it with other user defined  macros where it may make sense to have empty argument.

================
> writeLines("\\name{dummyfun}
\\alias{dummyfun}
\\title{Dummy title}
\\description{Dummy description}
\\usage{
dummyfun(x, ...)
}
\\arguments{
  \\item{x}{a value.}
  \\item{\\dots}{further arguments.}
}
\\details{
    \\CRANpkg{}
}
", fn)
> tools::parse_Rd(fn)
Error in tools::parse_Rd(fn) :
  Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'

	[[alternative HTML version deleted]]



[Rd] Rd parser throws error for user macros invoked with empty argument
Georgi Boshnakov