summaryrefslogtreecommitdiff
path: root/src/util/hex.h
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
committerShadowNinja <shadowninja@minetest.net>2017-06-03 14:55:10 -0400
commitcaecdb681c428c1aab9c0f7eec2570c0460f995c (patch)
treee5115982ea59bbf2343ba9b35bc4a0cfbb56f407 /src/util/hex.h
parent81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (diff)
parent80dc961d24e1964e25d57039ddb2ba639f9f4d22 (diff)
downloadminetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.gz
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.tar.bz2
minetest-caecdb681c428c1aab9c0f7eec2570c0460f995c.zip
Merge 0.4.16 into stable-0.4
Diffstat (limited to 'src/util/hex.h')
-rw-r--r--src/util/hex.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/util/hex.h b/src/util/hex.h
index 6f00a79bf..c205d01da 100644
--- a/src/util/hex.h
+++ b/src/util/hex.h
@@ -30,9 +30,8 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
char buf2[3];
buf2[2] = '\0';
- for(unsigned int i = 0; i < data_size; i++)
- {
- unsigned char c = (unsigned char) data[i];
+ for (unsigned int i = 0; i < data_size; i++) {
+ unsigned char c = (unsigned char)data[i];
buf2[0] = hex_chars[(c & 0xf0) >> 4];
buf2[1] = hex_chars[c & 0x0f];
ret.append(buf2);
@@ -43,16 +42,16 @@ static inline std::string hex_encode(const char *data, unsigned int data_size)
static inline std::string hex_encode(const std::string &data)
{
- return hex_encode(data.c_str(), data.size());
+ return hex_encode(data.c_str(), data.size());
}
static inline bool hex_digit_decode(char hexdigit, unsigned char &value)
{
- if(hexdigit >= '0' && hexdigit <= '9')
+ if (hexdigit >= '0' && hexdigit <= '9')
value = hexdigit - '0';
- else if(hexdigit >= 'A' && hexdigit <= 'F')
+ else if (hexdigit >= 'A' && hexdigit <= 'F')
value = hexdigit - 'A' + 10;
- else if(hexdigit >= 'a' && hexdigit <= 'f')
+ else if (hexdigit >= 'a' && hexdigit <= 'f')
value = hexdigit - 'a' + 10;
else
return false;