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 5f29d7e commit 4412a32
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ REGRESS := plr
EXTRA_CLEAN := doc/HTML.index expected/plr.out EXTRA_CLEAN := doc/HTML.index expected/plr.out


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


jade -c ${DOCBOOKSTYLE}/catalog -d ../../../doc/src/sgml/stylesheet.dsl -i output-html -t sgml $1 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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1152,20 +1152,30 @@ get_frame_tuplestore(SEXP rval,
if(isFactor(dfcol)) if(isFactor(dfcol))
{ {
SEXP t; 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; if(TAG(t) == R_LevelsSymbol)
int idx = INTEGER(dfcol)[i] - 1; {
SEXP obj;
int idx = INTEGER(dfcol)[i] - 1;


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


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


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


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

#ifdef ERROR #ifdef ERROR
#undef ERROR #undef ERROR
#endif #endif
Expand Down

0 comments on commit 4412a32

Please sign in to comment.