Bug 5681: Fixes leading zeroes in Add Mulpiple Copies
authorPaul Poulain <paul.poulain@biblibre.com>
Wed, 15 Dec 2010 19:28:03 +0000 (20:28 +0100)
committerChris Nighswonger <chris.nighswonger@gmail.com>
Wed, 2 Feb 2011 22:10:05 +0000 (17:10 -0500)
From Biblibre:
I don't know why, but removing sprintf solves the problems with leading zeroes
and the problems with large values.

(written by jean-andrĂ© santoni)

Note from Chris:

The width is never set, so the sprintf always defaults to a float, which
trims the leading zeros. I am not smart enough to figure out how to set
a valid width when calling it, and removing the sprintf seems to work
See http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5681 for
test results

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
(cherry picked from commit 4f7bcdcbae336d7cceb71b60f77a8ba2249b0f54)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
C4/Barcodes.pm

index 176d878..a528bd9 100644 (file)
@@ -135,14 +135,11 @@ sub next_value ($;$) {
                # Note, this enlargement might be undesireable for some barcode formats.
                # Those should override next_value() to work accordingly.
        $incr++;
-       my $width = $self->width || undef;
-       # we would want to use %$x.$xd, but that would break on large values, like 2160700004168
-       # so we let the object tell us if it has a width to focus on.  If not, we use float.
-       my $format = ($width ? '%'."$width.$width".'d' : '%.0f');
-       $debug and warn "sprintf(\"$format\",$incr)";
+
+       $debug and warn "$incr";
        $head = $self->process_head($head,$max,$specific);
        $tail = $self->process_tail($tail,$max,$specific);
-       my $next_value = $head . sprintf($format,$incr) . $tail;
+       my $next_value = $head . $incr . $tail;
        $debug and print STDERR "(  next ) max barcode found: $next_value\n";
        return $next_value;
 }