[Koha-patches] [PATCH] Avoid numeric comparisons with leading zeroes
Colin Campbell
colin.campbell at ptfs-europe.com
Thu Aug 20 12:12:57 CEST 2009
Numbers in perl with leading zeros are interpreted in octal
Ensure that comparisons are done using string operators
or where appropriate use the MARC::Field method
---
C4/Record.pm | 2 +-
cataloguing/addbiblio.pl | 2 +-
misc/batchCompareMARCvsFrameworks.pl | 2 +-
misc/migration_tools/bulkmarcimport.pl | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/C4/Record.pm b/C4/Record.pm
index 2ac9eca..2be4751 100644
--- a/C4/Record.pm
+++ b/C4/Record.pm
@@ -381,7 +381,7 @@ sub html2marcxml {
$marcxml.="<leader>@$values[$i]</leader>\n";
$first=1;
# rest of the fixed fields
- } elsif (@$tags[$i] < 010) { #FIXME: <10 was the way it was, there might even be a better way
+ } elsif (@$tags[$i] lt '010') { # don't compare numerically 010 == 8
$marcxml.="<controlfield tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
$first=1;
} else {
diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
index 8067a26..b974d28 100755
--- a/cataloguing/addbiblio.pl
+++ b/cataloguing/addbiblio.pl
@@ -665,7 +665,7 @@ sub build_tabs ($$$$$) {
fixedfield => $tag < 10?1:0,
random => CreateKey,
);
- if ($tag >= 010){ # no indicator for theses tag
+ if ($tag >= 10){ # no indicator for 00x tags
$tag_data{indicator1} = format_indicator($field->indicator(1)),
$tag_data{indicator2} = format_indicator($field->indicator(2)),
}
diff --git a/misc/batchCompareMARCvsFrameworks.pl b/misc/batchCompareMARCvsFrameworks.pl
index e255602..b0ed797 100755
--- a/misc/batchCompareMARCvsFrameworks.pl
+++ b/misc/batchCompareMARCvsFrameworks.pl
@@ -69,7 +69,7 @@ my $i=0;
while ( my $record = $batch->next() ) {
$i++;
foreach my $MARCfield ($record->fields()) {
- next if $MARCfield->tag()<=010;
+ next if $MARCfield->is_control_field(); # tag num < 10
if ($MARCfield) {
foreach my $fields ($MARCfield->subfields()) {
if ($fields) {
diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl
index 2a48540..b8f5500 100755
--- a/misc/migration_tools/bulkmarcimport.pl
+++ b/misc/migration_tools/bulkmarcimport.pl
@@ -195,7 +195,7 @@ RECORD: while ( ) {
next RECORD;
}
if (defined $idmapfl) {
- if ($sourcetag < "010"){
+ if ($sourcetag lt '010'){
if ($record->field($sourcetag)){
my $source = $record->field($sourcetag)->data();
printf(IDMAP "%s|%s\n",$source,$biblionumber);
--
1.6.2.5
More information about the Koha-patches
mailing list