From 2edb077c7783820687ed86e9383612e6c1556e32 Mon Sep 17 00:00:00 2001 From: djfiander Date: Tue, 7 Apr 2009 01:47:33 +0000 Subject: [PATCH] Start getting ready to handle more complex publication patterns. git-svn-id: svn://svn.open-ils.org/ILS/trunk@12807 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm index 5efcb8e53a..7ce488f3f9 100755 --- a/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/MFHD/Caption.pm @@ -85,14 +85,25 @@ sub new } } + my $pat = $self->{_mfhdc_PATTERN}; + + # Sanity check publication frequency vs publication pattern: + # if the frequency is a number, then the pattern better + # have that number of values associated with it. + if (exists($pat->{w}) && ($pat->{w} =~ /^\d+$/) + && ($pat->{w} != scalar(@{$pat->{y}}))) { + carp("Caption::new: publication frequency '$pat->{w}' != publication pattern @{$pat->{y}}"); + } + + # If there's a $x subfield and a $j, then it's compressible - if (exists $self->{_mfhdc_PATTERN}->{x} && exists $self->{_mfhdc_CHRONS}->{'j'}) { + if (exists $pat->{x} && exists $self->{_mfhdc_CHRONS}->{'j'}) { $self->{_mfhdc_COMPRESSIBLE} = 1; } bless ($self, $class); - if (exists $self->{_mfhdc_PATTERN}->{y}) { + if (exists $pat->{y}) { $self->decode_pattern; } -- 2.11.0