From 2e19d67aece99ade2657ef9ec80bd47afd95abee Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 5 Jan 2013 20:02:51 +0100 Subject: [PATCH] allow K/KB as well as KiB for cache size configuration --- src/Composer/Config.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 6f34837b4..f4207fa5a 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -139,7 +139,7 @@ class Config return (int) $this->config[$key]; case 'cache-files-maxsize': - if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) { + if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) { throw new \RuntimeException( "Could not parse the value of 'cache-files-maxsize' from your config: {$this->config[$key]}" ); @@ -147,12 +147,15 @@ class Config $size = $matches[1]; if (isset($matches[2])) { switch (strtolower($matches[2])) { - case 'gib': + case 'g': $size *= 1024; - case 'mib': + // intentional fallthrough + case 'm': $size *= 1024; - case 'kib': + // intentional fallthrough + case 'k': $size *= 1024; + break; } }