| 557 | |
| 558 | namespace { |
| 559 | void cmExecuteProcessCommandFixText(std::vector<char>& output, |
| 560 | bool strip_trailing_whitespace) |
| 561 | { |
| 562 | // Remove \0 characters and the \r part of \r\n pairs. |
| 563 | unsigned int in_index = 0; |
| 564 | unsigned int out_index = 0; |
| 565 | while (in_index < output.size()) { |
| 566 | char c = output[in_index++]; |
| 567 | if ((c != '\r' || |
| 568 | !(in_index < output.size() && output[in_index] == '\n')) && |
| 569 | c != '\0') { |
| 570 | output[out_index++] = c; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | // Remove trailing whitespace if requested. |
| 575 | if (strip_trailing_whitespace) { |
| 576 | while (out_index > 0 && |
| 577 | cmExecuteProcessCommandIsWhitespace(output[out_index - 1])) { |
| 578 | --out_index; |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | // Shrink the vector to the size needed. |
| 583 | output.resize(out_index); |
| 584 | |
| 585 | // Put a terminator on the text string. |
| 586 | output.push_back('\0'); |
| 587 | } |
| 588 | |
| 589 | void cmExecuteProcessCommandAppend(std::vector<char>& output, char const* data, |
| 590 | std::size_t length) |
no test coverage detected
searching dependent graphs…