The units handling was interpreting capital K/M/G as 1024/1048576/1073741824

and lowercase k/m/g as 1000/1000000/1000000000.  This was deemed to be
too confusing.  Now both capital and lowercase give the powers-of-two version.
This commit is contained in:
Jef Poskanzer 2013-01-28 16:52:04 -08:00
parent 1f4b249abb
commit 2efc602fb2

View File

@ -71,10 +71,6 @@ extern "C"
const long MEGA_UNIT = 1024 * 1024;
const long GIGA_UNIT = 1024 * 1024 * 1024;
const long KILO_UNIT_SI = 1000;
const long MEGA_UNIT_SI = 1000 * 1000;
const long GIGA_UNIT_SI = 1000 * 1000 * 1000;
/* -------------------------------------------------------------------
* unit_atof
*
@ -96,24 +92,15 @@ extern "C"
/* convert according to [Gg Mm Kk] */
switch (suffix)
{
case 'G':
case 'g': case 'G':
n *= GIGA_UNIT;
break;
case 'M':
case 'm': case 'M':
n *= MEGA_UNIT;
break;
case 'K':
case 'k': case 'K':
n *= KILO_UNIT;
break;
case 'g':
n *= GIGA_UNIT_SI;
break;
case 'm':
n *= MEGA_UNIT_SI;
break;
case 'k':
n *= KILO_UNIT_SI;
break;
default:
break;
}
@ -141,24 +128,15 @@ extern "C"
/* convert according to [Gg Mm Kk] */
switch (suffix)
{
case 'G':
case 'g': case 'G':
n *= GIGA_UNIT;
break;
case 'M':
case 'm': case 'M':
n *= MEGA_UNIT;
break;
case 'K':
case 'k': case 'K':
n *= KILO_UNIT;
break;
case 'g':
n *= GIGA_UNIT_SI;
break;
case 'm':
n *= MEGA_UNIT_SI;
break;
case 'k':
n *= KILO_UNIT_SI;
break;
default:
break;
}