[Rinside-commits] r155 - in pkg/src: . setenv

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 15 15:54:49 CEST 2010


Author: romain
Date: 2010-06-15 15:54:49 +0200 (Tue, 15 Jun 2010)
New Revision: 155

Added:
   pkg/src/setenv/setenv.c
Removed:
   pkg/src/setenv.c
Modified:
   pkg/src/RInside.cpp
Log:
moving setenv.c out of src so that it does not automatically compile when we move to Makevars

Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp	2010-06-15 13:54:22 UTC (rev 154)
+++ pkg/src/RInside.cpp	2010-06-15 13:54:49 UTC (rev 155)
@@ -32,7 +32,7 @@
 
 #ifdef WIN32
     // on Windows, we need to provide setenv which is in the file setenv.c here
-    #include "setenv.c"
+    #include "setenv/setenv.c"
     extern int optind;
 #endif
 

Copied: pkg/src/setenv/setenv.c (from rev 153, pkg/src/setenv.c)
===================================================================
--- pkg/src/setenv/setenv.c	                        (rev 0)
+++ pkg/src/setenv/setenv.c	2010-06-15 13:54:49 UTC (rev 155)
@@ -0,0 +1,80 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// RInside.cpp: R/C++ interface class library -- Easier R embedding into C++
+//
+// Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Richard Holbrey
+//
+// This file is part of RInside.
+//
+// RInside is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// RInside is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RInside.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+// borrowed from Renviron.c
+extern "C" int setenv(const char *env_var, const char *env_val, int dummy) {
+    char *buf, *value, *p, *q, *a, *b, quote='\0';
+    int inquote = 0;
+
+    //make non-const copies
+    a = (char *) malloc((strlen(env_var) + 1) * sizeof(char));
+    b = (char *) malloc((strlen(env_val) + 1) * sizeof(char));
+    if (!a || !b) {
+	fprintf(stderr, "memory allocation failure in setenv");
+        exit(1);
+    }
+    strcpy(a, env_var);
+    strcpy(b, env_val);
+
+    buf = (char *) malloc((strlen(a) + strlen(b) + 2) * sizeof(char));
+    if (!buf) {
+	fprintf(stderr, "memory allocation failure in setenv");
+        exit(1);
+    }
+    strcpy(buf, a); strcat(buf, "=");
+    value = buf+strlen(buf);
+
+    /* now process the value */
+    for(p = b, q = value; *p; p++) {
+	/* remove quotes around sections, preserve \ inside quotes */
+	if(!inquote && (*p == '"' || *p == '\'')) {
+	    inquote = 1;
+	    quote = *p;
+	    continue;
+	}
+
+	if(inquote && *p == quote && *(p-1) != '\\') {
+	    inquote = 0;
+	    continue;
+	}
+
+	if(!inquote && *p == '\\') {
+	    if(*(p+1) == '\n') p++;
+	    else if(*(p+1) == '\\') *q++ = *p;
+	    continue;
+	}
+
+	if(inquote && *p == '\\' && *(p+1) == quote)
+	    continue;
+	*q++ = *p;
+    }
+    *q = '\0';
+    //if (putenv(buf)) 
+	//warningcall(R_NilValue, _("problem in setting variable '%s' in Renviron"), a);
+    return putenv(buf);
+
+    /* no free here: storage remains in use */
+}
+

Deleted: pkg/src/setenv.c
===================================================================
--- pkg/src/setenv.c	2010-06-15 13:54:22 UTC (rev 154)
+++ pkg/src/setenv.c	2010-06-15 13:54:49 UTC (rev 155)
@@ -1,80 +0,0 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
-//
-// RInside.cpp: R/C++ interface class library -- Easier R embedding into C++
-//
-// Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Richard Holbrey
-//
-// This file is part of RInside.
-//
-// RInside is free software: you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// RInside is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with RInside.  If not, see <http://www.gnu.org/licenses/>.
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-// borrowed from Renviron.c
-extern "C" int setenv(const char *env_var, const char *env_val, int dummy) {
-    char *buf, *value, *p, *q, *a, *b, quote='\0';
-    int inquote = 0;
-
-    //make non-const copies
-    a = (char *) malloc((strlen(env_var) + 1) * sizeof(char));
-    b = (char *) malloc((strlen(env_val) + 1) * sizeof(char));
-    if (!a || !b) {
-	fprintf(stderr, "memory allocation failure in setenv");
-        exit(1);
-    }
-    strcpy(a, env_var);
-    strcpy(b, env_val);
-
-    buf = (char *) malloc((strlen(a) + strlen(b) + 2) * sizeof(char));
-    if (!buf) {
-	fprintf(stderr, "memory allocation failure in setenv");
-        exit(1);
-    }
-    strcpy(buf, a); strcat(buf, "=");
-    value = buf+strlen(buf);
-
-    /* now process the value */
-    for(p = b, q = value; *p; p++) {
-	/* remove quotes around sections, preserve \ inside quotes */
-	if(!inquote && (*p == '"' || *p == '\'')) {
-	    inquote = 1;
-	    quote = *p;
-	    continue;
-	}
-
-	if(inquote && *p == quote && *(p-1) != '\\') {
-	    inquote = 0;
-	    continue;
-	}
-
-	if(!inquote && *p == '\\') {
-	    if(*(p+1) == '\n') p++;
-	    else if(*(p+1) == '\\') *q++ = *p;
-	    continue;
-	}
-
-	if(inquote && *p == '\\' && *(p+1) == quote)
-	    continue;
-	*q++ = *p;
-    }
-    *q = '\0';
-    //if (putenv(buf)) 
-	//warningcall(R_NilValue, _("problem in setting variable '%s' in Renviron"), a);
-    return putenv(buf);
-
-    /* no free here: storage remains in use */
-}
-



More information about the Rinside-commits mailing list