MCPcopy Create free account
hub / github.com/build-cpp/cmkr / quote

Method quote

src/cmake_generator.cpp:330–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328 }
329
330 static std::string quote(const std::string &str) {
331 // Quote an empty string
332 if (str.empty()) {
333 return "\"\"";
334 }
335 // Don't quote arguments that don't need quoting
336 // https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument
337 // NOTE: Normally '/' does not require quoting according to the documentation but this has been the case here
338 // previously, so for backwards compatibility its still here.
339 if (str.find_first_of("()#\"\\'> |/;") == std::string::npos)
340 return str;
341 std::string result;
342 result += "\"";
343 for (char ch : str) {
344 switch (ch) {
345 case '\\':
346 case '\"':
347 result += '\\';
348 default:
349 result += ch;
350 break;
351 }
352 }
353 result += "\"";
354 return result;
355 }
356
357 static std::string indent(int n) {
358 std::string result;

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected