MCPcopy Create free account
hub / github.com/Kitware/CMake / cmExecuteProcessCommandFixText

Function cmExecuteProcessCommandFixText

Source/cmExecuteProcessCommand.cxx:559–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557
558namespace {
559void 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
589void cmExecuteProcessCommandAppend(std::vector<char>& output, char const* data,
590 std::size_t length)

Callers 1

cmExecuteProcessCommandFunction · 0.85

Calls 4

push_backMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…