Loading lib/progress.c +25 −6 Original line number Diff line number Diff line Loading @@ -68,8 +68,10 @@ static void time2str(char *r, long t) static char *max5data(curl_off_t bytes, char *max5) { #define ONE_KILOBYTE 1024 #define ONE_MEGABYTE (1024*1024) #define ONE_GIGABYTE (1024*1024*1024) #define ONE_MEGABYTE (1024* ONE_KILOBYTE) #define ONE_GIGABYTE (1024* ONE_MEGABYTE) #define ONE_TERRABYTE ((curl_off_t)1024* ONE_GIGABYTE) #define ONE_PETABYTE ((curl_off_t)1024* ONE_TERRABYTE) if(bytes < 100000) { sprintf(max5, "%5" FORMAT_OFF_T, bytes); Loading @@ -84,14 +86,31 @@ static char *max5data(curl_off_t bytes, char *max5) (int)(bytes%ONE_MEGABYTE)/(ONE_MEGABYTE/10) ); } #if SIZEOF_CURL_OFF_T > 4 else if(bytes < ((curl_off_t)10000*ONE_MEGABYTE)) { else if(bytes < ( (curl_off_t)10000*ONE_MEGABYTE)) /* 'XXXXM' is good until we're at 10000MB or above */ sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); } else /* 10000 MB - 8589934587 GB !! */ else if(bytes < (curl_off_t)100*ONE_GIGABYTE) /* 10000 MB - 100 GB, we show it as XX.XG */ sprintf(max5, "%2d.%0dG", (int)(bytes/ONE_GIGABYTE), (int)(bytes%ONE_GIGABYTE)/(ONE_GIGABYTE/10) ); else if(bytes < (curl_off_t)10000 * ONE_GIGABYTE) /* up to 10000GB, display without decimal: XXXXG */ sprintf(max5, "%4dG", (int)(bytes/ONE_GIGABYTE)); else if(bytes < (curl_off_t)10000 * ONE_TERRABYTE) /* up to 10000TB, display without decimal: XXXXT */ sprintf(max5, "%4dT", (int)(bytes/ONE_TERRABYTE)); else { /* up to 10000PB, display without decimal: XXXXP */ sprintf(max5, "%4dP", (int)(bytes/ONE_PETABYTE)); /* 16384 petabytes (16 exabytes) is maximum a 64 bit number can hold, but this type is signed so 8192PB will be max.*/ } #else else sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); Loading Loading
lib/progress.c +25 −6 Original line number Diff line number Diff line Loading @@ -68,8 +68,10 @@ static void time2str(char *r, long t) static char *max5data(curl_off_t bytes, char *max5) { #define ONE_KILOBYTE 1024 #define ONE_MEGABYTE (1024*1024) #define ONE_GIGABYTE (1024*1024*1024) #define ONE_MEGABYTE (1024* ONE_KILOBYTE) #define ONE_GIGABYTE (1024* ONE_MEGABYTE) #define ONE_TERRABYTE ((curl_off_t)1024* ONE_GIGABYTE) #define ONE_PETABYTE ((curl_off_t)1024* ONE_TERRABYTE) if(bytes < 100000) { sprintf(max5, "%5" FORMAT_OFF_T, bytes); Loading @@ -84,14 +86,31 @@ static char *max5data(curl_off_t bytes, char *max5) (int)(bytes%ONE_MEGABYTE)/(ONE_MEGABYTE/10) ); } #if SIZEOF_CURL_OFF_T > 4 else if(bytes < ((curl_off_t)10000*ONE_MEGABYTE)) { else if(bytes < ( (curl_off_t)10000*ONE_MEGABYTE)) /* 'XXXXM' is good until we're at 10000MB or above */ sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); } else /* 10000 MB - 8589934587 GB !! */ else if(bytes < (curl_off_t)100*ONE_GIGABYTE) /* 10000 MB - 100 GB, we show it as XX.XG */ sprintf(max5, "%2d.%0dG", (int)(bytes/ONE_GIGABYTE), (int)(bytes%ONE_GIGABYTE)/(ONE_GIGABYTE/10) ); else if(bytes < (curl_off_t)10000 * ONE_GIGABYTE) /* up to 10000GB, display without decimal: XXXXG */ sprintf(max5, "%4dG", (int)(bytes/ONE_GIGABYTE)); else if(bytes < (curl_off_t)10000 * ONE_TERRABYTE) /* up to 10000TB, display without decimal: XXXXT */ sprintf(max5, "%4dT", (int)(bytes/ONE_TERRABYTE)); else { /* up to 10000PB, display without decimal: XXXXP */ sprintf(max5, "%4dP", (int)(bytes/ONE_PETABYTE)); /* 16384 petabytes (16 exabytes) is maximum a 64 bit number can hold, but this type is signed so 8192PB will be max.*/ } #else else sprintf(max5, "%4" FORMAT_OFF_T "M", (curl_off_t)(bytes/ONE_MEGABYTE)); Loading