diff --git a/.drone/drone.sh b/.drone/drone.sh index b99f5f33f..e18b21deb 100755 --- a/.drone/drone.sh +++ b/.drone/drone.sh @@ -105,6 +105,9 @@ common_install() { fi fi + # !!! See: https://github.com/boostorg/url/issues/760 + boost_cache_hit=false + # Setup boost # If no cache: Clone, patch with boost-ci/ci, run common_install, and cache the result # If cache hit: Copy boost from cache, patch $SELF, and look for new dependencies with depinst diff --git a/src/detail/format_args.cpp b/src/detail/format_args.cpp index 00890e659..2b69ce258 100644 --- a/src/detail/format_args.cpp +++ b/src/detail/format_args.cpp @@ -373,13 +373,14 @@ measure( dn += measure_one(sign, cs); ++n; } - while (v > 0) + do { int d = v % 10; v /= 10; dn += measure_one('0' + static_cast(d), cs); ++n; } + while (v > 0); std::size_t w = width; if (width_idx != std::size_t(-1) || @@ -412,13 +413,14 @@ measure( dn += measure_one(sign, cs); ++n; } - while (v != 0) + do { int d = v % 10; v /= 10; dn += measure_one('0' + static_cast(d), cs); ++n; } + while (v != 0); std::size_t w = width; if (width_idx != std::size_t(-1) || @@ -457,13 +459,14 @@ format( { ++n; } - while (v > 0) + do { if (v >= 10) p *= 10; v /= 10; ++n; } + while (v > 0); static constexpr auto m = std::numeric_limits::digits10; BOOST_ASSERT(n <= m + 1); @@ -559,13 +562,14 @@ grammar::lut_chars const& cs) const { ++n; } - while (v > 0) + do { if (v >= 10) p *= 10; v /= 10; ++n; } + while (v > 0); static constexpr auto m = std::numeric_limits::digits10; BOOST_ASSERT(n <= m + 1); diff --git a/test/unit/format.cpp b/test/unit/format.cpp index 211af670e..9fba48433 100644 --- a/test/unit/format.cpp +++ b/test/unit/format.cpp @@ -464,6 +464,28 @@ struct format_test segs_equal( u.encoded_segments(), {"v"}); BOOST_TEST_NOT( u.has_query() ); } + { + url u = format("{}", 0); + BOOST_TEST_CSTR_EQ(u.buffer(), "0"); + BOOST_TEST_NOT( u.has_authority() ); + BOOST_TEST_NOT( u.has_userinfo() ); + BOOST_TEST( u.encoded_host().empty() ); + BOOST_TEST_CSTR_EQ( u.encoded_path(), "0" ); + BOOST_TEST_NOT( u.is_path_absolute() ); + segs_equal( u.encoded_segments(), {"0"}); + BOOST_TEST_NOT( u.has_query() ); + } + { + url u = format("{}", 0U); + BOOST_TEST_CSTR_EQ(u.buffer(), "0"); + BOOST_TEST_NOT( u.has_authority() ); + BOOST_TEST_NOT( u.has_userinfo() ); + BOOST_TEST( u.encoded_host().empty() ); + BOOST_TEST_CSTR_EQ( u.encoded_path(), "0" ); + BOOST_TEST_NOT( u.is_path_absolute() ); + segs_equal( u.encoded_segments(), {"0"}); + BOOST_TEST_NOT( u.has_query() ); + } { url u = format("/a"); BOOST_TEST_CSTR_EQ(u.buffer(), "/a");