[libcatmandu-marc-perl] 188/208: Fixing 0 as undef bug for marc_spec
Jonas Smedegaard
dr at jones.dk
Sat Oct 28 03:42:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag upstream/1.19
in repository libcatmandu-marc-perl.
commit b3da71dbab0b44fe096ab21455dcf85612241132
Author: Carsten Klee <cKlee at users.noreply.github.com>
Date: Thu Jul 13 08:01:04 2017 +0200
Fixing 0 as undef bug for marc_spec
---
lib/Catmandu/Fix/marc_spec.pm | 4 ++--
t/21-marc-spec.t | 2 ++
t/marc_spec.fix | 2 ++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/Catmandu/Fix/marc_spec.pm b/lib/Catmandu/Fix/marc_spec.pm
index 652219d..62d0aaf 100644
--- a/lib/Catmandu/Fix/marc_spec.pm
+++ b/lib/Catmandu/Fix/marc_spec.pm
@@ -45,10 +45,10 @@ sub emit {
my $perl = "";
$perl .= $fixer->emit_declare_vars($current_value, "[]");
$perl .=<<EOF;
-if (my ${result} = ${marc}->marc_spec(
+if (defined(my ${result} = ${marc}->marc_spec(
${var},
${marc_spec},
- ${marc_opt}) ) {
+ ${marc_opt})) ) {
${result} = ref(${result}) ? ${result} : [${result}];
for ${current_value} (\@{${result}}) {
EOF
diff --git a/t/21-marc-spec.t b/t/21-marc-spec.t
index b8456c2..dfeacfe 100644
--- a/t/21-marc-spec.t
+++ b/t/21-marc-spec.t
@@ -149,5 +149,7 @@ is $records->[0]->{my}{level2}{inverted}, 'black leatherblue pigskin', q|fix: ma
is $records->[0]->{my}{level1}{inverted}, 'ebinding', q|fix: marc_spec('020[#]$a$q[#]/1-5', my.level1.inverted, invert:1);|;
is $records->[0]->{my}{multi}{level1}{inverted}, 'bleatherbigskinebinding', q|fix: marc_spec('020[#]$a$q[0]/1-5$q[1]/1-5$q[2]/1-5', my.multi.level1.inverted, invert:1);|;
+is $records->[0]->{my}{nullvalue} , '0' , q|fix: marc_spec('008/0', my.nullvalue);|;
+
done_testing;
\ No newline at end of file
diff --git a/t/marc_spec.fix b/t/marc_spec.fix
index 1b35d92..842e0c5 100644
--- a/t/marc_spec.fix
+++ b/t/marc_spec.fix
@@ -60,3 +60,5 @@ marc_spec('260[#]$b$a', my.level3.inverted, invert:1)
marc_spec('020$a$q[#]', my.level2.inverted, invert:1)
marc_spec('020[#]$a$q[#]/1-5', my.level1.inverted, invert:1)
marc_spec('020[#]$a$q[0]/1-5$q[1]/1-5$q[2]/1-5', my.multi.level1.inverted, invert:1)
+
+marc_spec('008/0', my.nullvalue)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-marc-perl.git
More information about the Pkg-perl-cvs-commits
mailing list