From 9f2266f01878382abccef4610d6f235a61bd87f0 Mon Sep 17 00:00:00 2001 From: djfiander Date: Thu, 26 Nov 2009 01:35:03 +0000 Subject: [PATCH] Add some simple error checking to deal with common types of bad data that I'm seeing in MFHD dumps from real ILSs. git-svn-id: svn://svn.open-ils.org/ILS/trunk@15034 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm index 35f1db798..2b5a9329f 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm @@ -44,10 +44,21 @@ sub new { $self->{_mfhdc_CHRONS}->{$key} = $val; } elsif ($key eq 'u') { # Bib units per next higher enumeration level + + # Some files seem to have "empty" $u subfields, + # especially for top level of enumeration. Just drop them + next if (!defined($val) || !$val); + carp('$u specified for top-level enumeration') unless defined($last_enum); $self->{_mfhdc_ENUMS}->{$last_enum}->{COUNT} = $val; } elsif ($key eq 'v') { + # Is this level of enumeration continuous, or does it restart? + + # Some files seem to have "empty" $v subfields, + # especially for top level of enumeration. Just drop them + next if (!defined($val) || !$val); + carp '$v specified for top-level enumeration' unless defined($last_enum); $self->{_mfhdc_ENUMS}->{$last_enum}->{RESTART} = ($val eq 'r'); @@ -666,7 +677,7 @@ sub next_enum { # 2) Increment the highest level of enumeration (either by date # or because $carry is set because of the above loop - if (!$self->subfield('i')) { + if (!$self->subfield('i') || !$next->{i}) { # The simple case: if there is no chronology specified # then just check $carry and return $next->{'a'} += $carry; -- 2.11.0