[rkward-cvs] rkward/rkward/rbackend rembedinternal.cpp,1.22,1.23

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed Oct 12 10:20:20 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31603

Modified Files:
	rembedinternal.cpp 
Log Message:
Failed attempt to get at more information on parse errors. Some slight optimizations

Index: rembedinternal.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembedinternal.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** rembedinternal.cpp	29 Sep 2005 13:24:48 -0000	1.22
--- rembedinternal.cpp	12 Oct 2005 10:20:17 -0000	1.23
***************
*** 31,34 ****
--- 31,35 ----
  #include "Rinterface.h"
  #include "Rdevices.h"
+ #include "R_ext/Parse.h"
  
  #include <stdlib.h>
***************
*** 348,353 ****
  	int maxParts=1;
  	int r_error = 0;
! 	int status;
! 	int *stat = &status;
  	const char *c = command;
  	SEXP cv, pr, exp;
--- 349,353 ----
  	int maxParts=1;
  	int r_error = 0;
! 	int status = PARSE_NULL;
  	const char *c = command;
  	SEXP cv, pr, exp;
***************
*** 361,368 ****
  	SET_VECTOR_ELT(cv, 0, mkChar(command));  
  
  	while (maxParts>0) {
! 		pr=R_ParseVector(cv, maxParts, stat);
  		// 2=incomplete; 4=eof
! 		if (status!=2 && status!=4) {
  			break;
  		}
--- 361,369 ----
  	SET_VECTOR_ELT(cv, 0, mkChar(command));  
  
+ 	// TODO: Maybe we can use R_ParseGeneral instead. Then we could find the exact character, where parsing fails
  	while (maxParts>0) {
! 		pr=R_ParseVector(cv, maxParts, &status);
  		// 2=incomplete; 4=eof
! 		if (status!=PARSE_INCOMPLETE && status!=PARSE_EOF) {
  			break;
  		}
***************
*** 371,379 ****
  	UNPROTECT(1);
  
! 	if (status != 1) {
! 		if ((status == 2) || (status == 4)) {
  			*error = REmbedInternal::Incomplete;
! 		} else {
  			*error = REmbedInternal::SyntaxError;
  		}
  		exp = R_NilValue;
--- 372,384 ----
  	UNPROTECT(1);
  
! 	if (status != PARSE_OK) {
! 		if ((status == PARSE_INCOMPLETE) || (status == PARSE_EOF)) {
  			*error = REmbedInternal::Incomplete;
! 		} else if (status == PARSE_ERROR) {
! 			//extern SEXP parseError (SEXP call, int linenum);
! 			//parseError (R_NilValue, 0);
  			*error = REmbedInternal::SyntaxError;
+ 		} else { // PARSE_NULL
+ 			*error = REmbedInternal::OtherError;
  		}
  		exp = R_NilValue;





More information about the rkward-tracker mailing list