[Monetr-users] r90 - in pkg/MonetDB.R: R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 23 17:16:10 CEST 2013
Author: hannes
Date: 2013-07-23 17:16:10 +0200 (Tue, 23 Jul 2013)
New Revision: 90
Modified:
pkg/MonetDB.R/R/monetdb.R
pkg/MonetDB.R/src/mapisplit.c
Log:
mc
Modified: pkg/MonetDB.R/R/monetdb.R
===================================================================
--- pkg/MonetDB.R/R/monetdb.R 2013-07-23 14:56:38 UTC (rev 89)
+++ pkg/MonetDB.R/R/monetdb.R 2013-07-23 15:16:10 UTC (rev 90)
@@ -618,8 +618,8 @@
# determines and partially parses the answer from the server in response to a query
.mapiParseResponse <- function(response) {
- #lines <- .Call("mapiSplitLines", response,PACKAGE="MonetDB.R")
- lines <- strsplit(response,"\n",fixed=TRUE,useBytes=TRUE)[[1]]
+ lines <- .Call("mapiSplitLines", response,PACKAGE="MonetDB.R")
+ #lines <- strsplit(response,"\n",fixed=TRUE,useBytes=TRUE)[[1]]
typeLine <- lines[[1]]
Modified: pkg/MonetDB.R/src/mapisplit.c
===================================================================
--- pkg/MonetDB.R/src/mapisplit.c 2013-07-23 14:56:38 UTC (rev 89)
+++ pkg/MonetDB.R/src/mapisplit.c 2013-07-23 15:16:10 UTC (rev 90)
@@ -4,14 +4,12 @@
#include <string.h>
#include <errno.h>
-
typedef enum {
INQUOTES, ESCAPED, NORMAL
} chrstate;
char nullstr[] = "NULL";
-
SEXP mapiSplit(SEXP mapiLinesVector, SEXP numCols) {
PROTECT(mapiLinesVector = AS_CHARACTER(mapiLinesVector));
@@ -58,15 +56,22 @@
}
if (chr == ',' || curPos == linelen - 2) {
int tokenLen = curPos - tokenStart + 1 - endQuote;
+ if (tokenLen < 1) {
+ printf("parsing error in '%s'\n", val);
+ return colVec;
+ }
char *valPtr = (char*) malloc(tokenLen * sizeof(char));
if (valPtr == NULL) {
- printf("malloc() failed. Are you running out of memory? [%s]\n", strerror(errno));
+ printf(
+ "malloc() failed. Are you running out of memory? [%s]\n",
+ strerror(errno));
+ return colVec;
}
strncpy(valPtr, val + tokenStart, tokenLen);
valPtr[tokenLen - 1] = '\0';
SEXP colV = VECTOR_ELT(colVec, cCol);
- if (strcmp(valPtr,nullstr) == 0) {
+ if (strcmp(valPtr, nullstr) == 0) {
SET_STRING_ELT(colV, cRow, NA_STRING);
} else {
More information about the Monetr-users
mailing list