Skip to content

Commit

Permalink
- Fixed "Rdevices.h" not found error related to R-2.8.x
Browse files Browse the repository at this point in the history
- Fixed crashbug reported by Jeff Hamann. When a data frame had a factor
  column with a value in the first row, but NA in a subsequent row,
  a non-trapped R error would cause a segfault (PL/R's bug, not R)
- Corrected Makefile for use on Gentoo per Ian Stakenvicius
- Add facility to create pdf version of docs
  • Loading branch information
jconway committed Mar 1, 2009
1 parent 384893c commit 2c727f3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -28,7 +28,10 @@ REGRESS := plr
EXTRA_CLEAN := doc/HTML.index

ifdef USE_PGXS
PGXS := $(shell pg_config --pgxs)
ifndef PG_CONFIG
PG_CONFIG := pg_config
endif
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/plr
Expand Down
4 changes: 2 additions & 2 deletions doc/pg_doc
@@ -1,5 +1,5 @@
#!/bin/bash

jade -c ${DOCBOOKSTYLE}/catalog -d ../../../doc/src/sgml/stylesheet.dsl -i output-html -t sgml $1


openjade -D . -c ${DOCBOOKSTYLE}/catalog -d ../../../doc/src/sgml/stylesheet.dsl -t tex -V tex-backend -i output-print -V texpdf-output -V '%paper-type%'=USletter -o plr-US.tex-pdf $1
pdfjadetex plr-US.tex-pdf
26 changes: 18 additions & 8 deletions pg_conversion.c
Expand Up @@ -1188,20 +1188,30 @@ get_frame_tuplestore(SEXP rval,
if(isFactor(dfcol))
{
SEXP t;
for (t = ATTRIB(dfcol); t != R_NilValue; t = CDR(t))

/*
* a factor is a special type of integer
* but must check for NA value first
*/
if (INTEGER_ELT(dfcol, i) != NA_INTEGER)
{
if(TAG(t) == R_LevelsSymbol)
for (t = ATTRIB(dfcol); t != R_NilValue; t = CDR(t))
{
SEXP obj;
int idx = INTEGER(dfcol)[i] - 1;
if(TAG(t) == R_LevelsSymbol)
{
SEXP obj;
int idx = INTEGER(dfcol)[i] - 1;

PROTECT(obj = CAR(t));
values[j] = pstrdup(CHAR(STRING_ELT(obj, idx)));
UNPROTECT(1);
PROTECT(obj = CAR(t));
values[j] = pstrdup(CHAR(STRING_ELT(obj, idx)));
UNPROTECT(1);

break;
break;
}
}
}
else
values[j] = NULL;
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions plr.h
Expand Up @@ -58,13 +58,18 @@
#endif
#include "Rinternals.h"
#include "Rdefines.h"
#if (R_VERSION < 133120) /* R_VERSION >= 2.8.0 */
#include "Rdevices.h"
#endif

/* starting in R-2.7.0 this defn was removed from Rdevices.h */
#ifndef KillAllDevices
#define KillAllDevices Rf_KillAllDevices
#endif

/* for some reason this is not in any R header files, it is locally defined */
#define INTEGER_ELT(x,__i__) INTEGER(x)[__i__]

/*
* The R headers define various symbols that are also defined by the
* Postgres headers, so undef them first to avoid conflicts.
Expand Down

0 comments on commit 2c727f3

Please sign in to comment.