From: Frank Brehm Date: Wed, 29 Mar 2006 16:15:50 +0000 (+0000) Subject: Bugfixing bei to_int() X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=5e6c4afe62f9ab4f549de14fe91aa955f8c51383;p=scripts%2Fsolaris.git Bugfixing bei to_int() --- diff --git a/LogRotate/Common.pm b/LogRotate/Common.pm index d575fe6..3463313 100644 --- a/LogRotate/Common.pm +++ b/LogRotate/Common.pm @@ -326,15 +326,15 @@ sub to_int($;$) { my $p = verbose() ? __PACKAGE__ . "::to_int(): " : ""; return undef unless defined $val; - print $p . "aufgerufen mit '" . $val . "'.\n" if verbose() > 5; + print $p . "aufgerufen mit '" . $val . "' (" . ($signed ? 'mit' : 'ohne'). " Vorzeichen) .\n" if verbose() > 5; unless ( $val =~ /\d/ ) { return undef; } if ( $signed ) { - $val =~ s/.*((-\s*)?\d+).*/$1$2/; + $val =~ s/^[^\d-]*(?:(-)\s*)?(\d+)\D?.*?/$1$2/; } else { - $val =~ s/.*(\d+).*/$1/; + $val =~ s/^\D*(\d+)\D?.*$/$1/; } print $p . "Neuer Wert: '" . ( defined($val) ? $val : "" ) . "'.\n" if verbose() > 5;