DMBS: tiny fix [#CONV-4143].

This commit is contained in:
Evgeniy Gatov 2013-04-18 11:49:46 +00:00
parent d211d5b185
commit f94cc9d9c6

View File

@ -30,6 +30,19 @@ inline std::string escapeForFileName(const std::string & s)
return res; return res;
} }
inline char unhex(char c)
{
switch (c)
{
case '0' ... '9':
return c - '0';
case 'A' ... 'F':
return c - 'A' + 10;
default:
return 0;
}
}
inline std::string unescapeForFileName(const std::string & s) inline std::string unescapeForFileName(const std::string & s)
{ {
std::string res; std::string res;
@ -48,31 +61,12 @@ inline std::string unescapeForFileName(const std::string & s)
if (++pos == end) break; if (++pos == end) break;
c = *pos; c = *pos;
char val = 0; char val = unhex(val) * 16;
switch (c)
{
case '0' ... '9':
val = (c - '0') * 16;
break;
case 'A' ... 'F':
val = (c - 'A' + 10) * 16;
break;
};
if (++pos == end) break; if (++pos == end) break;
c = *pos; c = *pos;
switch (c) res += unhex(val);
{
case '0' ... '9':
val += (c - '0');
break;
case 'A' ... 'F':
val += c - 'A' + 10;
break;
};
res += val;
} }
++pos; ++pos;