Skip to content

Commit

Permalink
unify converttype and converttypei bad-detection - #502
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 3, 2024
1 parent c9a73c8 commit 677f833
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Basic/Core/pdlconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ pdl_error pdl_converttype( pdl* a, int targtype ) {
PDL_TYPELIST_ALL_, targtype, X_INNER, return pdl_make_error(PDL_EUSERERROR, "Not a known data type code=%d", targtype))
#undef X_INNER
#undef X_OUTER
#undef THIS_ISBAD

/* Store new data */
if (diffsize) {
Expand Down Expand Up @@ -157,11 +156,11 @@ pdl_error pdl_converttypei_redodims(pdl_trans *trans) {
return PDL_err;
}

#define COPYCONVERT(from, to, from_ppsym) \
#define COPYCONVERT(from, to) \
PDL_Indx i, nvals = trans->pdls[1]->nvals; \
if (trans->bvalflag) \
for (i=0; i<nvals; i++) \
to ## _datap[i] = PDL_ISBAD2(from ## _datap[i], from ## _badval, from_ppsym, from ## _badval_isnan) \
to ## _datap[i] = THIS_ISBAD(from ## _badval_isnan, from ## _badval, from ## _datap[i]) \
? to ## _badval \
: from ## _datap[i]; \
else \
Expand All @@ -181,7 +180,7 @@ pdl_error pdl_converttypei_readdata(pdl_trans *trans) {
PDL_DECLARE_PARAMETER_BADVAL(ctype_to, TOpdl, (trans->pdls[TOpdl_indx]), 1, ppsym_to)
#define X_INNER(datatype_from, ctype_from, ppsym_from, ...) \
PDL_DECLARE_PARAMETER_BADVAL(ctype_from, FROMpdl, (trans->pdls[FROMpdl_indx]), 1, ppsym_from) \
COPYCONVERT(FROMpdl, TOpdl, ppsym_from)
COPYCONVERT(FROMpdl, TOpdl)
PDL_GENERICSWITCH2(
PDL_TYPELIST_ALL, totype, X_OUTER, return pdl_make_error(PDL_EUSERERROR, "Not a known data type code=%d", totype),
PDL_TYPELIST_ALL_, fromtype, X_INNER, return pdl_make_error(PDL_EUSERERROR, "Not a known data type code=%d", fromtype))
Expand Down

0 comments on commit 677f833

Please sign in to comment.