From dcab2b89a7ffeabf3f5360366ea7d94ffe564f9d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 21 Jun 2007 15:51:22 +0000 Subject: [PATCH] =?utf8?q?update=5Fbusiness=20und=20update=5Fdefaults:=20B?= =?utf8?q?ei=20sehr=20langen=20Zahlenkomponenten=20wurden=20die=20erzeugte?= =?utf8?q?n=20Nummern=20leider=20auf=20-0000000...001=20gesetzt.=20Grund?= =?utf8?q?=20ist,=20dass=20der=20Formatierer=20'%d'=20f=C3=BCr=20sprintf?= =?utf8?q?=20auf=2032bit-Systemen=20nun=20mal=20nur=20mit=2032bit-Zahlen?= =?utf8?q?=20umgehen=20kann.=20Geriet=20die=20Zahlenkomponente=20gr=C3=B6?= =?utf8?q?=C3=9Fer=20als=202147483647,=20so=20erhielt=20man=20einen=20?= =?utf8?q?=C3=9Cberlauf.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Form.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 9175a6428..cc65716b4 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2648,8 +2648,14 @@ sub update_defaults { my ($var) = $sth->fetchrow_array; $sth->finish; - $var =~ s/\d+$/ sprintf '%0*d', length($&), $&+1 /e; - $var ||= 1; + if ($var =~ m/\d+$/) { + my $new_var = (substr $var, $-[0]) * 1 + 1; + my $len_diff = length($var) - $-[0] - length($new_var); + $var = substr($var, 0, $-[0]) . ($len_diff > 0 ? '0' x $len_diff : '') . $new_var; + + } else { + $var = $var . '1'; + } $query = qq|UPDATE defaults SET $fld = ?|; do_query($self, $dbh, $query, $var); @@ -2680,8 +2686,15 @@ sub update_business { WHERE id = ? FOR UPDATE|; my ($var) = selectrow_query($self, $dbh, $query, $business_id); - $var =~ s/\d+$/ sprintf '%0*d', length($&), $&+1 /e; - + if ($var =~ m/\d+$/) { + my $new_var = (substr $var, $-[0]) * 1 + 1; + my $len_diff = length($var) - $-[0] - length($new_var); + $var = substr($var, 0, $-[0]) . ($len_diff > 0 ? '0' x $len_diff : '') . $new_var; + + } else { + $var = $var . '1'; + } + $query = qq|UPDATE business SET customernumberinit = ? WHERE id = ?|; -- 2.20.1