Bugzilla – Attachment 21934 Details for
Bug 10996
Cannot exclude numeric subfields on export
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Cannot exclude numeric subfields on export
0005-Bug-10996-Allow-numeric-subfields-to-be-stripped-on-.patch (text/plain), 2.70 KB, created by
Paola Rossi
on 2013-10-10 07:47:33 UTC
(
hide
)
Description:
Cannot exclude numeric subfields on export
Filename:
MIME Type:
Creator:
Paola Rossi
Created:
2013-10-10 07:47:33 UTC
Size:
2.70 KB
patch
obsolete
>From 32e128d215d26aec8bb2efdd91448fc472631278 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Fri, 4 Oct 2013 11:01:27 +0100 >Subject: [PATCH 5/5] Bug 10996 Allow numeric subfields to be stripped on > export > >Regex assumed all numeric characters were part of the tag number >This is obviously false as $9 would be a likely candidate >to be removed on export. Constrain the tag by length > >The code can be any printing ascii character other than space >according to LoC's website > >Also changed regexp to no longer allow a zero length tag number >which is nonsensical. >The old regex would accept shorter than 3 digit tags but these were >not stripped so I've removed that option considering it a bug >not a feature > >NB assumption that the code makes that a tag is always numeric is >incorrect but works in practice. Handling non-numeric tags is >a 'To be done' > >Made code dependent on the regex succeeding. Picking up results >from a previous regex on failure can lead to weird hard to >identify bugs > >Signed-off-by: Paola Rossi <paola.rossi@cineca.it> >--- > tools/export.pl | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > >diff --git a/tools/export.pl b/tools/export.pl >index 40c3b9b..a9e54ec 100755 >--- a/tools/export.pl >+++ b/tools/export.pl >@@ -360,17 +360,19 @@ if ( $op eq "export" ) { > if ($export_remove_fields) { > my @fields = split " ", $export_remove_fields; > foreach (@fields) { >- /^(\d*)(\w)?$/; >- my $field = $1; >- my $subfield = $2; >- >- # skip if this record doesn't have this field >- next if not defined $record->field($field); >- if ($subfield) { >- $record->field($field)->delete_subfields($subfield); >- } >- else { >- $record->delete_field( $record->field($field) ); >+ if (/^(\d{3})(.)?$/) { >+ my $field = $1; >+ my $subfield = $2; >+ >+ # skip if this record doesn't have this field >+ next if not defined $record->field($field); >+ if ($subfield) { >+ $record->field($field) >+ ->delete_subfields($subfield); >+ } >+ else { >+ $record->delete_field( $record->field($field) ); >+ } > } > } > } >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10996
:
21806
|
21934
|
21974
|
22009
|
22586
|
22596
|
23067