Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.783
diff -u -r1.783 common.inc
--- includes/common.inc	13 Aug 2008 07:10:20 -0000	1.783
+++ includes/common.inc	14 Aug 2008 02:06:31 -0000
@@ -1104,17 +1104,31 @@
     return format_plural($size, '1 byte', '@count bytes', array(), $langcode);
   }
   else {
-    $size = $size / 1000; // convert bytes to kilobytes (1000 bytes)
-    $units = array('KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
-    foreach ($units as $suffix) {
-      if (round($size, 2) >= 1000) {
-        $size = $size / 1000;
-      }
-      else {
-        break;
-      }
+    // It is not possible to refactor this code in a loop, because the
+    // arguments to format_plural have to be string constants.
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 KB', '@count KB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 MB', '@count MB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 GB', '@count GB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 TB', '@count TB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 PB', '@count PB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 EB', '@count EB', array(), $langcode);
+    }
+    if (($size = round($size / 1000, 2)) < 1000) {
+      return format_plural($size, '1 ZB', '@count ZB', array(), $langcode);
     }
-    return t('@size @suffix', array('@size' => round($size, 2), '@suffix' => $suffix), $langcode);
+    $size = round($size / 1000, 2);
+    return format_plural($size, '1 YB', '@count YB', array(), $langcode);
   }
 }
 
