[Fai-commit] r4834 - people/michael/features/setup_harddisks_2/implementation/lib
mt at alioth.debian.org
mt at alioth.debian.org
Mon Jan 7 10:27:02 UTC 2008
Author: mt
Date: 2008-01-07 10:27:02 +0000 (Mon, 07 Jan 2008)
New Revision: 4834
Modified:
people/michael/features/setup_harddisks_2/implementation/lib/parser.pm
Log:
allow floating point values as inputs to convert_unit
Modified: people/michael/features/setup_harddisks_2/implementation/lib/parser.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/parser.pm 2007-12-23 15:33:46 UTC (rev 4833)
+++ people/michael/features/setup_harddisks_2/implementation/lib/parser.pm 2008-01-07 10:27:02 UTC (rev 4834)
@@ -271,14 +271,14 @@
sub convert_unit
{
my ($val) = @_;
- ($val =~ /^(\d+)([kMGTP%]?)(B)?\s*$/) or
+ ($val =~ /^(\d+(\.\d+)?)([kMGTP%]?)(B)?\s*$/) or
&FAI::internal_error("convert_unit $val");
- $val = $1 * (1 / 1024) * (1 / 1024) if ($2 eq "" && defined ($3) && $3 eq "B");
- $val = $1 * (1 / 1024) if ($2 eq "k");
- $val = $1 if ($2 eq "M");
- $val = $1 * 1024 if ($2 eq "G");
- $val = $1 * (1024 * 1024) if ($2 eq "T");
- $val = $1 * (1024 * 1024 * 1024) if ($2 eq "P");
+ $val = $1 * (1 / 1024) * (1 / 1024) if ($3 eq "" && defined ($4) && $4 eq "B");
+ $val = $1 * (1 / 1024) if ($3 eq "k");
+ $val = $1 if ($3 eq "M");
+ $val = $1 * 1024 if ($3 eq "G");
+ $val = $1 * (1024 * 1024) if ($3 eq "T");
+ $val = $1 * (1024 * 1024 * 1024) if ($3 eq "P");
# % is returned as is
return $val;
}
More information about the Fai-commit
mailing list