Better escaping.

This commit is contained in:
Moritz Bunkus 2003-11-08 08:52:57 +00:00
parent 6f95eec905
commit 122a6b7e28

View File

@ -1000,7 +1000,9 @@ string escape(const char *src) {
if (*src == '\\') if (*src == '\\')
dst += "\\\\"; dst += "\\\\";
else if (*src == '"') else if (*src == '"')
dst += '2'; // Yes, this IS a trick ;) dst += "\\2"; // Yes, this IS a trick ;)
else if (*src == ' ')
dst += "\\s";
else else
dst += *src; dst += *src;
src++; src++;
@ -1018,11 +1020,13 @@ string unescape(const char *src) {
if (*src == '\\') { if (*src == '\\') {
if (*next_char == 0) // This is an error... if (*next_char == 0) // This is an error...
dst += '\\'; dst += '\\';
else if (*next_char == '2') { else {
dst += '"'; if (*next_char == '2')
src++; dst += '"';
} else { else if (*next_char == 's')
dst += *next_char; dst += ' ';
else
dst += *next_char;
src++; src++;
} }
} else } else