| 222 | } |
| 223 | |
| 224 | bool ShellUnescape(const std::string& str, std::string* result) |
| 225 | { |
| 226 | std::string::const_iterator pos = str.begin(); |
| 227 | std::string::const_iterator end = str.end(); |
| 228 | while (pos < end) { |
| 229 | char c = *pos++; |
| 230 | if (c == '\\') { |
| 231 | char e; |
| 232 | int unescaped_size = UnescapeChar(pos, end, &e); |
| 233 | if (unescaped_size > 0) { |
| 234 | *result += e; |
| 235 | pos += unescaped_size; |
| 236 | } else { |
| 237 | *result += *pos++; |
| 238 | } |
| 239 | } else { // Not '\\' |
| 240 | *result += c; |
| 241 | } |
| 242 | } |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | static void UnescapeCharToArg(std::string::const_iterator* pos, |
| 247 | std::string::const_iterator end, |