IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17116


Ignore:
Timestamp:
Mar 24, 2008, 5:37:47 PM (18 years ago)
Author:
Paul Price
Message:

Adding check for NULL-like values when parsing statistics.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Config/lib/PS/IPP/Metadata/Stats.pm

    r15185 r17116  
    11# Copyright (c) 2006  Paul Price, Joshua Hoblitt
    22#
    3 # $Id: Stats.pm,v 1.25 2007-10-03 22:49:39 price Exp $
     3# $Id: Stats.pm,v 1.26 2008-03-25 03:37:47 price Exp $
    44
    55package PS::IPP::Metadata::Stats;
     
    8989        my $type = $entry->{type};
    9090        my $data = $entry->{data};
    91        
     91
    9292        if ($type eq "constant") {
    9393            if (not defined $entry->{value}) {
     
    177177
    178178    return $self;
     179}
     180
     181# Return 1 if a metadata item value is effectively NULL
     182sub _is_null_for_type
     183{
     184    my ($item) = @_;            # Metadata item
     185
     186    return 1 unless defined $item->{type} and defined $item->{value};
     187
     188    if (($item->{type} eq "F32" or $item->{type} eq "F64") and lc($item->{value} eq 'nan')) {
     189        return 1;
     190    }
     191    if ($item->{type} eq "STR" and lc($item->{value}) eq 'null') {
     192        return 1;
     193    }
     194    return 0;
    179195}
    180196
     
    225241    my $name = $mdItem->{name};        # Name of the item
    226242    my $value = $mdItem->{value}; # Value of the item
    227 
     243   
     244    if ( _is_null_for_type($mdItem) and $mdItem->{class} eq 'scalar' ) {
     245        print "Stats: Ignoring NULL entry $name\n";
     246        return;
     247    }
     248       
    228249    my $entries = $self->{entries};        # The data
    229250
Note: See TracChangeset for help on using the changeset viewer.