mirror of
https://github.com/znc/znc.git
synced 2026-08-08 01:43:03 +02:00
Merge commit 'refs/pull/356/head' of github.com:znc/znc
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ public:
|
||||
EURL,
|
||||
EHTML,
|
||||
ESQL,
|
||||
ENAMEDFMT
|
||||
ENAMEDFMT,
|
||||
EDEBUG
|
||||
} EEscape;
|
||||
|
||||
explicit CString(bool b) : std::string(b ? "true" : "false") {}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user