[Rd] Parsing code with newlines
Mikhail Titov
m|t @end|ng |rom gmx@u@
Fri Apr 5 08:14:40 CEST 2019
Hello!
This is my first post here. I came across the very same problem.
It can be reproduced within modified tests/Embedding/RParseEval.c
Actually this example has another issue, namely it doesn't wrap
everything in R_ToplevelExec . This is a major show stopper for
newcomers as that function is barely mentioned anywhere and longjmp into
terminated setuploop function followed by R_suicide look like a mystery.
Error: bad value
Fatal error: unable to initialize the JIT
That aside, here is the code with newlines that fails to parse. I hope
it will paste alright here.
#include "embeddedRCall.h"
#include <R_ext/Parse.h>
int
main(int argc, char *argv[])
{
SEXP e, tmp;
int hadError;
ParseStatus status;
init_R(argc, argv);
PROTECT(tmp = mkString("\n\r ls()"));
PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue));
if (status != PARSE_OK)
{
printf("boo boo\n");
}
else
{
PrintValue(e);
R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError);
}
UNPROTECT(2);
end_R();
return(0);
}
--
Mikhail
More information about the R-devel
mailing list