Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- fix Makefile so that R.dll is found on win32

- remove embedded carriage returns from prosrc datum to
  prevent R engine syntax errors
  • Loading branch information...
commit 412947abe127b8b6a54d2023ecb909d82e5ed980 1 parent 5b09a95
jconway authored
Showing with 49 additions and 21 deletions.
  1. +28 −21 Makefile
  2. +21 −0 plr.c
View
49 Makefile
@@ -4,27 +4,6 @@ r_libdir2x = ${R_HOME}/lib
# location of R includes
r_includespec = ${R_HOME}/include
-ifeq ($(PORTNAME), darwin)
-DYSUFFIX = dylib
-endif
-
-# we can only build PL/R if libR is available
-# Since there is no official way to determine this,
-# we see if there is a file that is named like a shared library.
-ifneq ($(PORTNAME), darwin)
-ifneq (,$(wildcard $(r_libdir1x)/libR*$(DLSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DLSUFFIX)*))
- shared_libr = yes;
-endif
-else
-ifneq (,$(wildcard $(r_libdir1x)/libR*$(DYSUFFIX)*)$(wildcard $(r_libdir2x)/libR*$(DYSUFFIX)*))
- shared_libr = yes
-endif
-endif
-
-# If we don't have a shared library and the platform doesn't allow it
-# to work without, we have to skip it.
-ifneq (,$(findstring yes, $(shared_libr)$(allow_nonpic_in_shlib)))
-
MODULE_big := plr
PG_CPPFLAGS += -I$(r_includespec)
SRCS += plr.c pg_conversion.c pg_backend_support.c pg_userfuncs.c pg_rsupport.c
@@ -46,6 +25,34 @@ include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
+ifeq ($(PORTNAME), darwin)
+ DYSUFFIX = dylib
+ DLPREFIX = libR
+else
+ ifeq ($(PORTNAME), win32)
+ DLPREFIX = R
+ else
+ DLPREFIX = libR
+ endif
+endif
+
+# we can only build PL/R if libR is available
+# Since there is no official way to determine this,
+# we see if there is a file that is named like a shared library.
+ifneq ($(PORTNAME), darwin)
+ ifneq (,$(wildcard $(r_libdir1x)/$(DLPREFIX)*$(DLSUFFIX)*)$(wildcard $(r_libdir2x)/$(DLPREFIX)*$(DLSUFFIX)*))
+ shared_libr = yes;
+ endif
+else
+ ifneq (,$(wildcard $(r_libdir1x)/$(DLPREFIX)*$(DYSUFFIX)*)$(wildcard $(r_libdir2x)/$(DLPREFIX)*$(DYSUFFIX)*))
+ shared_libr = yes
+ endif
+endif
+
+# If we don't have a shared library and the platform doesn't allow it
+# to work without, we have to skip it.
+ifneq (,$(findstring yes, $(shared_libr)$(allow_nonpic_in_shlib)))
+
override CPPFLAGS := -I$(srcdir) -I$(r_includespec) $(CPPFLAGS)
override CPPFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\" -DDLSUFFIX=\"$(DLSUFFIX)\"
View
21 plr.c
@@ -814,6 +814,7 @@ do_compile(FunctionCallInfo fcinfo,
StringInfo proc_internal_args = makeStringInfo();
char *proc_source;
MemoryContext oldcontext;
+ char *p;
/* grab the function name */
proname = NameStr(procStruct->proname);
@@ -1204,6 +1205,26 @@ do_compile(FunctionCallInfo fcinfo,
elog(ERROR, "null prosrc");
proc_source = DatumGetCString(DirectFunctionCall1(textout, prosrcdatum));
+ /*
+ * replace any carriage returns with either a space or a newline,
+ * as appropriate
+ */
+ p = proc_source;
+ while (*p != '\0')
+ {
+ if (p[0] == '\r')
+ {
+ if (p[1] == '\n')
+ /* for crlf sequence, write over the cr with a space */
+ *p++ = ' ';
+ else
+ /* otherwise write over the cr with a nl */
+ *p++ = '\n';
+ }
+ else
+ p++;
+ }
+
appendStringInfo(proc_internal_def, "%s}", proc_source);
/* parse or find the R function */
Please sign in to comment.
Something went wrong with that request. Please try again.