diff --git a/c/mapping/lrec_evaluators.c b/c/mapping/lrec_evaluators.c index 4604a2c45..f197395b1 100644 --- a/c/mapping/lrec_evaluators.c +++ b/c/mapping/lrec_evaluators.c @@ -110,8 +110,7 @@ mv_t lrec_evaluator_f_f_func(lrec_t* prec, context_t* pctx, void* pvstate) { NULL_OR_ERROR_OUT(val1); mt_get_double_nullable(&val1); - if (val1.type == MT_NULL) - return val1; + NULL_OUT(val1); if (val1.type != MT_DOUBLE) return MV_ERROR; @@ -142,16 +141,14 @@ mv_t lrec_evaluator_f_ff_func(lrec_t* prec, context_t* pctx, void* pvstate) { mv_t val1 = pstate->parg1->pevaluator_func(prec, pctx, pstate->parg1->pvstate); NULL_OR_ERROR_OUT(val1); mt_get_double_nullable(&val1); - if (val1.type == MT_NULL) - return val1; + NULL_OUT(val1); if (val1.type != MT_DOUBLE) return MV_ERROR; mv_t val2 = pstate->parg2->pevaluator_func(prec, pctx, pstate->parg2->pvstate); NULL_OR_ERROR_OUT(val2); mt_get_double_nullable(&val2); - if (val2.type == MT_NULL) - return val2; + NULL_OUT(val2); if (val2.type != MT_DOUBLE) return MV_ERROR; diff --git a/c/mapping/mlr_val.h b/c/mapping/mlr_val.h index c646d1239..be31ec0dd 100644 --- a/c/mapping/mlr_val.h +++ b/c/mapping/mlr_val.h @@ -44,6 +44,10 @@ extern mv_t MV_ERROR; return MV_NULL; \ } +#define NULL_OUT(val) { \ + if ((val).type == MT_NULL) \ + return MV_NULL; \ +} #define ERROR_OUT(val) { \ if ((val).type == MT_ERROR) \ return MV_ERROR; \ diff --git a/c/todo.txt b/c/todo.txt index e008aa6d8..84398ca54 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -7,7 +7,7 @@ TOP OF LIST * make a -D for hash-collision stats ... * go through remaining functions to decide when null-through is ok. -* also document thoroughly. +* also document thoroughly. emphasize this is crucial for heterogeneous data. * doc w/ very specific examples of sed/grep/etc preprocessing to structurize semi-structured data (e.g. logs)