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 == '\\')
dst += "\\\\";
else if (*src == '"')
dst += '2'; // Yes, this IS a trick ;)
dst += "\\2"; // Yes, this IS a trick ;)
else if (*src == ' ')
dst += "\\s";
else
dst += *src;
src++;
@ -1018,10 +1020,12 @@ string unescape(const char *src) {
if (*src == '\\') {
if (*next_char == 0) // This is an error...
dst += '\\';
else if (*next_char == '2') {
else {
if (*next_char == '2')
dst += '"';
src++;
} else {
else if (*next_char == 's')
dst += ' ';
else
dst += *next_char;
src++;
}