From fb3a18f9494b661b2df8964f7eba1d1f30a1e379 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Mon, 14 Sep 2009 19:26:47 +0100 Subject: [PATCH] bug 3614 Fix incorrect setting of indicator Pull the code into its own subr so that the dangers of inaccurate copy & paste are avoided in future Signed-off-by: Galen Charlton --- C4/Biblio.pm | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 27f1d21d99..ce9c431dd3 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1802,10 +1802,8 @@ sub TransformHtmlToXml { $first = 1; } else { - my $ind1 = substr( @$indicator[$j], 0, 1 ); - my $ind2 = substr( @$indicator[$j], 1, 1 ); - $ind1 = " " if !defined($ind2) or $ind2 eq ""; - $ind2 = " " if !defined($ind2) or $ind2 eq ""; + my $ind1 = default_ind_to_space( substr( @$indicator[$j], 0, 1 ) ); + my $ind2 = default_ind_to_space( substr( @$indicator[$j], 1, 1 ) ); $xml .= "\n"; $xml .= "@$values[$i]\n"; $first = 0; @@ -1818,10 +1816,8 @@ sub TransformHtmlToXml { } else { if ($first) { - my $ind1 = substr( @$indicator[$j], 0, 1 ); - my $ind2 = substr( @$indicator[$j], 1, 1 ); - $ind1 = " " if !defined($ind2) or $ind2 eq ""; - $ind2 = " " if !defined($ind2) or $ind2 eq ""; + my $ind1 = default_ind_to_space( substr( @$indicator[$j], 0, 1 ) ); + my $ind2 = default_ind_to_space( substr( @$indicator[$j], 1, 1 ) ); $xml .= "\n"; $first = 0; } @@ -1848,6 +1844,21 @@ sub TransformHtmlToXml { return $xml; } +=head2 default_ind_to_space + +Passed what should be an indicator returns a space +if its undefined or zero length + +=cut + +sub default_ind_to_space { + my $s = shift; + if (!defined $s || $s eq q{} ) { + return ' '; + } + return $s; +} + =head2 TransformHtmlToMarc L<$record> = TransformHtmlToMarc(L<$params>,L<$cgi>) -- 2.39.5