[libcatmandu-marc-perl] 54/208: Fixing zero-padded tags treated as numbers bug

Jonas Smedegaard dr at jones.dk
Sat Oct 28 03:42:34 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 d55fd627dbc66935130a94b3f35762223b97af39
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Thu Sep 15 11:25:24 2016 +0200

    Fixing zero-padded tags treated as numbers bug
---
 Build.PL                      | 4 ++++
 Changes                       | 3 +++
 lib/Catmandu/Importer/MARC.pm | 2 +-
 lib/Catmandu/MARC.pm          | 3 ++-
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Build.PL b/Build.PL
index 05d6b0b..862c7cb 100644
--- a/Build.PL
+++ b/Build.PL
@@ -23,13 +23,17 @@ my %module_build_args = (
   "module_name" => "Catmandu::MARC",
   "recursive_test_files" => 1,
   "requires" => {
+    "Carp" => 0,
     "Catmandu" => "1.0201",
     "JSON::XS" => "2.3",
+    "List::Util" => 0,
     "MARC::File::MARCMaker" => "0.05",
     "MARC::File::MiJ" => "0.04",
     "MARC::File::XML" => "v1.0.3",
+    "MARC::Lint" => 0,
     "MARC::Parser::RAW" => 0,
     "MARC::Record" => "v2.0.6",
+    "Memoize" => 0,
     "Moo" => "1.0",
     "MooX::Singleton" => 0,
     "YAML::XS" => "0.34",
diff --git a/Changes b/Changes
index 56bedc1..99fcfca 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,9 @@
 Revision history for Catmandu-MARC
 
 {{$NEXT}}
+  - Fixing dependency problems
+  - Deleting unused modules
+  - Fixing zero-padded tags treated as numbers bug
 
 1.00_02  2016-09-14 14:20:47 CEST
   - Making default MARC importer the same as default MARC exporter (ISO)
diff --git a/lib/Catmandu/Importer/MARC.pm b/lib/Catmandu/Importer/MARC.pm
index 7b43987..683daf8 100644
--- a/lib/Catmandu/Importer/MARC.pm
+++ b/lib/Catmandu/Importer/MARC.pm
@@ -4,7 +4,7 @@ Catmandu::Importer::MARC - Package that imports MARC data
 
 =head1 SYNOPSIS
 
-    # From the command line
+    # From the command line convert MARC to JSON mapping 245a to a title
     $ catmandu convert MARC --fix "marc_map('245a','title')" < /foo/bar.mrc
 
     # From Perl
diff --git a/lib/Catmandu/MARC.pm b/lib/Catmandu/MARC.pm
index 59509c9..38eddd5 100644
--- a/lib/Catmandu/MARC.pm
+++ b/lib/Catmandu/MARC.pm
@@ -449,12 +449,13 @@ sub compile_marc_path {
     my ($field,$field_regex,$ind1,$ind2,
         $subfield,$subfield_regex,$from,$to,$len,$is_regex_field);
 
-    my $MARC_PATH_REGEX = qr/(\S{3})(\[([^,])?,?([^,])?\])?([_a-z0-9^]+)?(\/(\d+)(-(\d+))?)?/;
+    my $MARC_PATH_REGEX = qr/(\S{1,3})(\[([^,])?,?([^,])?\])?([_a-z0-9^]+)?(\/(\d+)(-(\d+))?)?/;
     if ($marc_path =~ $MARC_PATH_REGEX) {
         $field          = $1;
         $ind1           = $3;
         $ind2           = $4;
         $subfield       = $5;
+        $field = "0" x (3 - length($field)) . $field; # fixing 020 treated as 20 bug
         if (defined($subfield)) {
             unless ($subfield =~ /^[a-zA-Z0-9]$/) {
                 $subfield = "[$subfield]";

-- 
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