From 4fb276ddccc94a540641f4972e093e5afd982a14 Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Mon, 15 Jul 2024 10:20:08 +0100 Subject: [PATCH] Added brackets to binary operators --- src/amulet_nbt/cpp/string_encoding/mutf8.cpp | 18 +++++++++--------- src/amulet_nbt/cpp/string_encoding/utf8.cpp | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/amulet_nbt/cpp/string_encoding/mutf8.cpp b/src/amulet_nbt/cpp/string_encoding/mutf8.cpp index 598814ad..6eecb5ba 100644 --- a/src/amulet_nbt/cpp/string_encoding/mutf8.cpp +++ b/src/amulet_nbt/cpp/string_encoding/mutf8.cpp @@ -110,24 +110,24 @@ namespace Amulet { dst.push_back(c & 0b01111111); } else if (c <= 2047) { - dst.push_back(0b11000000 | 0b00011111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b11000000 | (0b00011111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else if (c <= 65535) { if ((c >= 0xD800) && (c <= 0xDFFF)) { throw std::invalid_argument("code point at index " + std::to_string(index) + " cannot be encoded."); } - dst.push_back(0b11100000 | 0b00001111 & (c >> 12)); - dst.push_back(0b10000000 | 0b00111111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b11100000 | (0b00001111 & (c >> 12))); + dst.push_back(0b10000000 | (0b00111111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else if (c <= 1114111) { dst.push_back(0b11101101); - dst.push_back(0b10100000 | 0b00001111 & ((c >> 16) - 1)); - dst.push_back(0b10000000 | 0b00111111 & (c >> 10)); + dst.push_back(0b10100000 | (0b00001111 & ((c >> 16) - 1))); + dst.push_back(0b10000000 | (0b00111111 & (c >> 10))); dst.push_back(0b11101101); - dst.push_back(0b10110000 | 0b00001111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b10110000 | (0b00001111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else { throw std::invalid_argument("Invalid code point at index " + std::to_string(index)); diff --git a/src/amulet_nbt/cpp/string_encoding/utf8.cpp b/src/amulet_nbt/cpp/string_encoding/utf8.cpp index 71337578..a0b7b260 100644 --- a/src/amulet_nbt/cpp/string_encoding/utf8.cpp +++ b/src/amulet_nbt/cpp/string_encoding/utf8.cpp @@ -181,8 +181,8 @@ constexpr void _write_utf8(std::string &dst, const Amulet::CodePointVector& src) dst.push_back(c & 0b01111111); } else if (c <= 2047) { - dst.push_back(0b11000000 | 0b00011111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b11000000 | (0b00011111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else if (c <= 65535) { if constexpr (escapeErrors){ @@ -203,15 +203,15 @@ constexpr void _write_utf8(std::string &dst, const Amulet::CodePointVector& src) if ((c >= 0xD800) && (c <= 0xDFFF)){ throw std::invalid_argument("code point at index " + std::to_string(index) + " cannot be encoded."); } - dst.push_back(0b11100000 | 0b00001111 & (c >> 12)); - dst.push_back(0b10000000 | 0b00111111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b11100000 | (0b00001111 & (c >> 12))); + dst.push_back(0b10000000 | (0b00111111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else if (c <= 1114111) { - dst.push_back(0b11110000 | 0b00000111 & (c >> 18)); - dst.push_back(0b10000000 | 0b00111111 & (c >> 12)); - dst.push_back(0b10000000 | 0b00111111 & (c >> 6)); - dst.push_back(0b10000000 | 0b00111111 & c); + dst.push_back(0b11110000 | (0b00000111 & (c >> 18))); + dst.push_back(0b10000000 | (0b00111111 & (c >> 12))); + dst.push_back(0b10000000 | (0b00111111 & (c >> 6))); + dst.push_back(0b10000000 | (0b00111111 & c)); } else { throw std::invalid_argument("Invalid code point at index " + std::to_string(index));