Skip to content

Commit

Permalink
Fixes badval propagation to support all badval configurations
Browse files Browse the repository at this point in the history
The changes in <#188> broke the
build for all cases of `BADVAL_USENAN` xor `BADVAL_PER_PDL`.

This was because the checking for badvalues when copying in
`pdl_kludge_copy_*` did not take into account these variations in
accessing and setting the badvalue.
  • Loading branch information
zmughal committed Jul 10, 2016
1 parent dcebe92 commit ca57882
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Basic/Core/pdlcore.c.PL
Expand Up @@ -1077,18 +1077,25 @@ PDL_Indx pdl_kludge_copy_$type(PDL_Indx poff, // Offset into the dest data array
pdlsiz = source_pdl->dims[pdldim];
}
#if BADVAL
/* This is used inside the switch in order to detect badvalues. */
PDL_Anyval source_badval = PDL.get_pdl_badvalue(source_pdl);
#endif /* BADVAL */
/* This is the actual data-copying code. It is generated with a Perl loop, to
* ensure that all current PDL types get treated. */
switch(source_pdl->datatype) {
!WITH!SUBS!

# perl loop to emit code for all the PDL types -- ctype gets the C type of
# the source PDL, and switch_type gets the Perl name.
# the source PDL, switch_type gets the Perl name, and ppsym gets
# the symbol need to retrieve from a PDL_Anyval.
foreach my $switch_type (keys %PDL::Types::typehash) {

my $ctype = $PDL::Types::typehash{$switch_type}{ctype};
my $stype = $PDL::Types::typehash{$switch_type}{ctype};
my $ppsym = $PDL::Types::typehash{$switch_type}{ppsym};
$stype =~ s/PDL_//;

print OUT <<"!WITH!SUBS!";
Expand All @@ -1100,10 +1107,10 @@ PDL_Indx pdl_kludge_copy_$type(PDL_Indx poff, // Offset into the dest data array
for(; i<pdlsiz; i++) {
#if BADVAL
if(source_pdl->has_badvalue || (source_pdl->state & PDL_BADVAL)) {
if( (($ctype *)pptr)[i] == PDL.bvals.$stype ) {
/* Retrieve directly from .value.* instead of using ANYVAL_EQ_ANYVAL */
if( (($ctype *)pptr)[i] == source_badval.value.$ppsym ) {
/* bad value in source PDL -- use our own type's bad value instead */
pdata[i] = PDL.bvals.$type;
p->has_badvalue=1;
p->state |= PDL_BADVAL;
} else {
pdata[i] = (PDL_$type) ((${ctype} *)pptr)[i];
Expand Down

0 comments on commit ca57882

Please sign in to comment.