Skip to content

Commit

Permalink
refactor: no implicit char conversions
Browse files Browse the repository at this point in the history
fix #816
  • Loading branch information
alandefreitas committed Feb 7, 2024
1 parent 47c8323 commit 2ecc9ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/boost/url/detail/encode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ re_encode_unsafe(
detail::hexdigs[opt.lower_case];
auto const encode = [end, hex](
char*& dest,
unsigned char c) noexcept
char c0) noexcept
{
auto c = static_cast<unsigned char>(c0);
ignore_unused(end);
*dest++ = '%';
BOOST_ASSERT(dest != end);
Expand Down
12 changes: 10 additions & 2 deletions include/boost/url/grammar/lut_chars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class lut_chars
unsigned char ch) noexcept
{
return ch == 255
? construct(ch, pred(ch))
: construct(ch, pred(ch)) +
? construct(ch, pred(static_cast<char>(ch)))
: construct(ch, pred(static_cast<char>(ch))) +
construct(pred, ch + 1);
}

Expand Down Expand Up @@ -257,6 +257,14 @@ class lut_chars
bool
operator()(
unsigned char ch) const noexcept
{
return operator()(static_cast<char>(ch));
}

/// @copydoc operator()(unsigned char) const
constexpr
bool
operator()(char ch) const noexcept
{
return mask_[lo(ch)] & hi(ch);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_rule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_char_set(
for_each_char(
[&cs](char c)
{
if(cs(0) || ! cs(c))
if(cs(static_cast<unsigned char>(0)) || ! cs(c))
{
if(cs(c))
{
Expand Down

0 comments on commit 2ecc9ad

Please sign in to comment.