13 if (arg.empty() ==
false &&
14 arg.find_first_of(
" \t\n\v\"") == arg.npos) {
19 escaped.push_back(
'"');
20 for (
auto it = arg.begin(); ; ++it) {
21 int num_backslashes = 0;
23 while (it != arg.end() && *it ==
'\\') {
28 if (it == arg.end()) {
29 escaped.append(num_backslashes * 2,
'\\');
31 }
else if (*it ==
'"') {
32 escaped.append(num_backslashes * 2 + 1,
'\\');
33 escaped.push_back(*it);
35 escaped.append(num_backslashes,
'\\');
36 escaped.push_back(*it);
39 escaped.push_back(
'"');
92void exec_cmd(std::string
const& cmd,
int log_num, std::string
const& path) {
93 std::array<char, 128> buffer;
96 auto real_cmd =
"OpenCppCoverage --export_type binary:cov-report" + std::to_string(log_num)
97 +
".bin --quiet " +
"--sources " +
escape_arg(path) +
" --cover_children -- " + cmd;
98 std::cout <<
"=== Marker ===: Cmd: " << real_cmd <<
'\n';
99 std::shared_ptr<FILE> pipe(_popen(real_cmd.c_str(),
"r"), _pclose);
101 (void)log_num; (void)path;
102 std::shared_ptr<FILE> pipe(popen(cmd.c_str(),
"r"), pclose);
106 throw std::runtime_error(
"popen() failed!");
108 while (!feof(pipe.get())) {
109 if (fgets(buffer.data(), 128, pipe.get()) !=
nullptr) {
110 std::cout << buffer.data();
122 std::vector<std::string> args(
argv,
argv + argc);
123 auto sep = std::find(begin(args), end(args),
separator);
124 assert(sep - begin(args) == 2 &&
"Structure differs from expected!");
128 auto cmdline = std::accumulate(++sep, end(args), std::string{}, [] (
const std::string& lhs,
const std::string& rhs) {
134 }
catch (std::exception
const& ex) {
135 std::cerr <<
"Helper failed with: '" << ex.what() <<
"'\n";