diff --git a/Makefile b/Makefile index f0a571f3..43f816ff 100755 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/doc/pg_doc b/doc/pg_doc index 23c595a4..24771652 100755 --- a/doc/pg_doc +++ b/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 \ No newline at end of file diff --git a/pg_conversion.c b/pg_conversion.c index 5eb59895..677fcec5 100755 --- a/pg_conversion.c +++ b/pg_conversion.c @@ -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 { diff --git a/plr.h b/plr.h index 56e97eb3..68e9a732 100755 --- a/plr.h +++ b/plr.h @@ -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.