You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2020/07/12 04:00:24 UTC
svn commit: r1879799 - in /subversion/branches/1.14.x: ./ STATUS build.conf
subversion/svn/filesize.c subversion/tests/client/
Author: svn-role
Date: Sun Jul 12 04:00:23 2020
New Revision: 1879799
URL: http://svn.apache.org/viewvc?rev=1879799&view=rev
Log:
Merge the r1878909 group from trunk:
* r1878909, r1878918, r1878950
Fix a number of thinkos in human-readable file size formatting.
Justification:
Fixes wrong output and an assertion failure in debug mode.
Votes:
+1: brane, rhuijben, jamessan
Added:
subversion/branches/1.14.x/subversion/tests/client/ (props changed)
- copied from r1878909, subversion/trunk/subversion/tests/client/
Modified:
subversion/branches/1.14.x/ (props changed)
subversion/branches/1.14.x/STATUS
subversion/branches/1.14.x/build.conf
subversion/branches/1.14.x/subversion/svn/filesize.c
Propchange: subversion/branches/1.14.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1878909,1878918,1878950
Modified: subversion/branches/1.14.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1879799&r1=1879798&r2=1879799&view=diff
==============================================================================
--- subversion/branches/1.14.x/STATUS (original)
+++ subversion/branches/1.14.x/STATUS Sun Jul 12 04:00:23 2020
@@ -29,13 +29,6 @@ Approved changes:
Votes:
+1: futatuki, stsp, rhuijben
- * r1878909, r1878918, r1878950
- Fix a number of thinkos in human-readable file size formatting.
- Justification:
- Fixes wrong output and an assertion failure in debug mode.
- Votes:
- +1: brane, rhuijben, jamessan
-
* r1879198
Fix an invalid quoting in working copy upgrade system that only works
because SQLite automatically fixed this. More recent SQLite functions
Modified: subversion/branches/1.14.x/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x/build.conf?rev=1879799&r1=1879798&r2=1879799&view=diff
==============================================================================
--- subversion/branches/1.14.x/build.conf (original)
+++ subversion/branches/1.14.x/build.conf Sun Jul 12 04:00:23 2020
@@ -53,6 +53,7 @@ private-includes =
subversion/libsvn_subr/utf8proc/utf8proc_internal.h
subversion/libsvn_subr/utf8proc/utf8proc.c
subversion/libsvn_subr/utf8proc/utf8proc_data.c
+ subversion/svn/filesize.c
private-built-includes =
subversion/svn_private_config.h
subversion/libsvn_fs_fs/rep-cache-db.h
@@ -1339,6 +1340,18 @@ libs = libsvn_client libsvn_test libsvn_
msvc-force-static = yes
# ----------------------------------------------------------------------------
+# Tests for the client's internal functions
+
+[filesize-test]
+description = Test conversion of file sizes to human-readable form
+type = exe
+path = subversion/tests/client
+sources = filesize-test.c
+install = test
+libs = libsvn_client libsvn_test libsvn_wc libsvn_subr apriconv apr
+msvc-force-static = yes
+
+# ----------------------------------------------------------------------------
# These are not unit tests at all, they are small programs that exercise
# parts of the libsvn_delta API from the command line. They are stuck here
# because of some historical association with the test-suite, but should
@@ -1565,7 +1578,7 @@ libs = __ALL__
checksum-test compat-test config-test hashdump-test mergeinfo-test
opt-test packed-data-test path-test prefix-string-test
priority-queue-test root-pools-test stream-test
- string-test time-test utf-test bit-array-test
+ string-test time-test utf-test bit-array-test filesize-test
error-test error-code-test cache-test spillbuf-test crypto-test
revision-test
subst_translate-test io-test
Modified: subversion/branches/1.14.x/subversion/svn/filesize.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/svn/filesize.c?rev=1879799&r1=1879798&r2=1879799&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/svn/filesize.c (original)
+++ subversion/branches/1.14.x/subversion/svn/filesize.c Sun Jul 12 04:00:23 2020
@@ -88,15 +88,24 @@ format_size(double human_readable_size,
+ 1 nul terminator
---
= 5 characters of space needed in the buffer. */
- char buffer[8];
+ char buffer[64];
- assert(absolute_human_readable_size < 1000.0);
+ assert(absolute_human_readable_size < 1000);
+
+ /* When the adjusted size has only one significant digit left of
+ the decimal point, show tenths of a unit, too. Except when
+ the absolute size is actually a single-digit number, because
+ files can't have fractional byte sizes. */
+ if (absolute_human_readable_size >= 10)
+ sprintf(buffer, "%.0f", human_readable_size);
+ else
+ {
+ double integral;
+ const double frac = modf(absolute_human_readable_size, &integral);
+ const int decimals = (index > 0 && (integral < 9 || frac <= .949999999));
+ sprintf(buffer, "%.*f", decimals, human_readable_size);
+ }
- /* When the adjusted size has only one significant digit left of the
- decimal point, show tenths of a unit, too. */
- sprintf(buffer, "%.*f",
- absolute_human_readable_size < 10.0 ? 1 : 0,
- human_readable_size);
return apr_pstrcat(result_pool, buffer, suffix, SVN_VA_NULL);
}
@@ -138,8 +147,9 @@ get_base2_unit_file_size(svn_filesize_t
assert(index < order_size - 1);
++index;
}
+
human_readable_size = (index == 0 ? (double)size
- : (size >> 3 * index) / 128.0 / index);
+ : (size >> (10 * index - 10)) / 1024.0);
return format_size(human_readable_size,
long_units, order, index, result_pool);
@@ -160,7 +170,7 @@ get_base10_unit_file_size(svn_filesize_t
{APR_INT64_C( 999999999999), " TB", "T"}, /* tera */
{APR_INT64_C( 999999999999999), " EB", "E"}, /* exa */
{APR_INT64_C(999999999999999999), " PB", "P"} /* peta */
- /* 18446744073709551615 is the maximum value. */
+ /* 9223372036854775807 is the maximum value. */
};
static const apr_size_t order_size = sizeof(order) / sizeof(order[0]);
@@ -170,20 +180,29 @@ get_base10_unit_file_size(svn_filesize_t
/* Adjust the size to the given order of magnitude.
- This is division by (order[index].mask + 1), which is the base-1000
- magnitude of the size. For large file sizes, we split the operation
- into an integer and a floating-point division, so that we don't
+ This is division by (order[index].mask + 1), which is the
+ base-1000 magnitude of the size. We split the operation into an
+ integer and a floating-point division, so that we don't
overflow the mantissa. */
if (index == 0)
human_readable_size = (double)size;
- else if (index <= 3)
- human_readable_size = (double)size / (order[index].mask + 1);
else
{
- /* [ Keep integer division here! ] */
- const double divisor = (double)((order[index].mask + 1) / 1000000);
- human_readable_size = (size / 1000000) / divisor;
- /* [ And here! ] */
+ const svn_filesize_t divisor = (order[index - 1].mask + 1);
+ /* [Keep integer arithmetic here!] */
+ human_readable_size = (size / divisor) / 1000.0;
+ }
+
+ /* Adjust index and number for rounding. */
+ if (human_readable_size >= 999.5)
+ {
+ /* This assertion should never fail, because we only have one
+ decimal digit in the petabyte range and so the number of
+ petabytes can't be large enough to cause the program flow
+ to enter this conditional block. */
+ assert(index < order_size - 1);
+ human_readable_size /= 1000.0;
+ ++index;
}
return format_size(human_readable_size,
Propchange: subversion/branches/1.14.x/subversion/tests/client/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jul 12 04:00:23 2020
@@ -0,0 +1,11 @@
+*.dst
+*.exe
+*.o
+*.lo
+*.src
+*~
+.*~
+.libs
+Debug
+Release
+*-test