From tom@@@k@||ber@ @end|ng |rom gm@||@com  Wed Apr 10 12:06:01 2019
From: tom@@@k@||ber@ @end|ng |rom gm@||@com (Tomas Kalibera)
Date: Wed, 10 Apr 2019 12:06:01 +0200
Subject: [Rd] Parsing code with newlines
In-Reply-To: <9q0r2ahx9kf.fsf@gmx.us>
References: <a564fafa0808040550j13fd5097q804fc9549cd4ad55@mail.gmail.com>
 <alpine.LFD.1.10.0808041402500.17316@gannet.stats.ox.ac.uk>
 <9q0r2ahx9kf.fsf@gmx.us>
Message-ID: <48eaf7f6-3de0-bf4b-71be-50841711b656@gmail.com>

On 4/5/19 8:14 AM, Mikhail Titov wrote:
> Hello!
>
> This is my first post here. I came across the very same problem.
> It can be reproduced within modified tests/Embedding/RParseEval.c

Please check https://www.r-project.org/posting-guide.html and update 
your post if you still need to get help here - from your current post I 
am not sure what you did, what was the error you got and from which 
tool, why you think the error was a result of something not working 
correctly/as documented, etc. The original post with the same subject 
you are probably referring to had the same problem.

Please also note that "tests" (tests/Embedding/RParseEval.c) are not 
examples - if they do not catch R errors in some cases that is perfectly 
ok, they also may use internal API that is indeed not documented e.g. in 
Writing R Extensions. Note Writing R Extensions has a section on 
embedding R and on cleanup handlers.

Best
Tomas

>
> 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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Parsing code with newlines
Tomas Kalibera