Merge commit 'refs/pull/356/head' of github.com:znc/znc

This commit is contained in:
Alexey Sokolov
2013-05-18 09:10:28 +04:00
3 changed files with 37 additions and 2 deletions
+3 -1
View File
@@ -30,7 +30,9 @@
*/
#define DEBUG(f) do { \
if (CDebug::Debug()) { \
std::cout << CDebug::GetTimestamp() << f << std::endl; \
std::stringstream sDebug;\
sDebug << f;\
std::cout << CDebug::GetTimestamp() << CString(sDebug.str()).Escape_n(CString::EDEBUG) << std::endl; \
} \
} while (0)
+2 -1
View File
@@ -62,7 +62,8 @@ public:
EURL,
EHTML,
ESQL,
ENAMEDFMT
ENAMEDFMT,
EDEBUG
} EEscape;
explicit CString(bool b) : std::string(b ? "true" : "false") {}
+32
View File
@@ -164,6 +164,8 @@ CString::EEscape CString::ToEscape(const CString& sEsc) {
return ESQL;
} else if (sEsc.Equals("NAMEDFMT")) {
return ENAMEDFMT;
} else if (sEsc.Equals("DEBUG")) {
return EDEBUG;
}
return EASCII;
@@ -280,6 +282,26 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
}
break;
case EDEBUG:
if (*p == '\\' && (a +3) < iLength && *(p +1) == 'x' && isxdigit(*(p +2)) && isxdigit(*(p +3))) {
p += 2;
if (isdigit(*p)) {
ch = (unsigned char)((*p - '0') << 4);
} else {
ch = (unsigned char)((tolower(*p) - 'a' +10) << 4);
}
p++;
if (isdigit(*p)) {
ch |= (unsigned char)(*p - '0');
} else {
ch |= (unsigned char)(tolower(*p) - 'a' +10);
}
a += 3;
} else {
ch = *p;
}
}
switch (eTo) {
@@ -326,6 +348,16 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
} else if (ch == '}') { sRet += '\\'; sRet += '}';
} else { sRet += ch; }
break;
case EDEBUG:
if (ch < 0x20 || ch == 0x7F) {
sRet += "\\x";
sRet += szHex[ch >> 4];
sRet += szHex[ch & 0xf];
} else {
sRet += ch;
}
break;
}
}