aboutsummaryrefslogtreecommitdiff
path: root/src/util/string.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
committerest31 <MTest31@outlook.com>2016-12-22 23:16:00 +0100
commit81d56b94919dceb7b2e51d70b21a7ca22f852bd5 (patch)
tree1e9ef1be1b3295a8673d6e4f0bdeb4c2d3a6015f /src/util/string.cpp
parent8077612dcb48221281e726a60eb97bf73fde462b (diff)
parent231ac33d34dfaaddf292c5f31b1eae43eeefba2d (diff)
downloadminetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.gz
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.tar.bz2
minetest-81d56b94919dceb7b2e51d70b21a7ca22f852bd5.zip
Merge 0.4.15 changes into stable-0.4
0.4.15 release!
Diffstat (limited to 'src/util/string.cpp')
-rw-r--r--src/util/string.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp
index 2c4143c76..94064ef93 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -314,7 +314,7 @@ std::string wide_to_narrow(const std::wstring &wcs)
#endif
-std::string urlencode(std::string str)
+std::string urlencode(const std::string &str)
{
// Encodes non-unreserved URI characters by a percent sign
// followed by two hex digits. See RFC 3986, section 2.3.
@@ -322,17 +322,18 @@ std::string urlencode(std::string str)
std::ostringstream oss(std::ios::binary);
for (u32 i = 0; i < str.size(); i++) {
unsigned char c = str[i];
- if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~')
+ if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~') {
oss << c;
- else
+ } else {
oss << "%"
<< url_hex_chars[(c & 0xf0) >> 4]
<< url_hex_chars[c & 0x0f];
+ }
}
return oss.str();
}
-std::string urldecode(std::string str)
+std::string urldecode(const std::string &str)
{
// Inverse of urlencode
std::ostringstream oss(std::ios::binary);
@@ -343,18 +344,20 @@ std::string urldecode(std::string str)
hex_digit_decode(str[i+2], lowvalue)) {
oss << (char) ((highvalue << 4) | lowvalue);
i += 2;
- }
- else
+ } else {
oss << str[i];
+ }
}
return oss.str();
}
u32 readFlagString(std::string str, const FlagDesc *flagdesc, u32 *flagmask)
{
- u32 result = 0, mask = 0;
+ u32 result = 0;
+ u32 mask = 0;
char *s = &str[0];
- char *flagstr, *strpos = NULL;
+ char *flagstr;
+ char *strpos = NULL;
while ((flagstr = strtok_r(s, ",", &strpos))) {
s = NULL;