Minor changes

This commit is contained in:
Benoît Blanchon
2014-07-09 13:30:08 +02:00
parent a48fbac7d7
commit 4e61a839a5

View File

@ -24,37 +24,24 @@ static inline char getSpecialChar(char c)
static inline size_t printCharTo(char c, Print& p) static inline size_t printCharTo(char c, Print& p)
{ {
char specialChar = getSpecialChar(c); char specialChar = getSpecialChar(c);
if (specialChar)
{ return specialChar != 0
return p.write('\\') + p.write(specialChar); ? p.write('\\') + p.write(specialChar)
} : p.write(c);
else
{
return p.write(c);
}
} }
size_t EscapedString::printTo(Print& p) const size_t EscapedString::printTo(Print& p) const
{ {
const char* s = rawString; const char* s = rawString;
if (!s) if (!s) return p.print("null");
{
return p.print("null");
}
size_t n = 0; size_t n = p.write('\"');
n += p.write('\"');
while (*s) while (*s)
{ {
n += printCharTo(*s, p); n += printCharTo(*s++, p);
s++;
} }
n += p.write('\"'); return n + p.write('\"');
return n;
} }