MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / trimContinuationLine

Method trimContinuationLine

astyle/src/ASFormatter.cpp:5612–5655  ·  view source on GitHub ↗

* The continuation lines must be adjusted so the leading spaces * is equivalent to the text on the opening line. * * Updates currentLine and charNum. */

Source from the content-addressed store, hash-verified

5610 * Updates currentLine and charNum.
5611 */
5612void ASFormatter::trimContinuationLine()
5613{
5614 size_t len = currentLine.length();
5615 size_t tabSize = getTabLength();
5616 charNum = 0;
5617
5618 if (leadingSpaces > 0 && len > 0)
5619 {
5620 size_t i;
5621 size_t continuationIncrementIn = 0;
5622 for (i = 0; (i < len) && (i + continuationIncrementIn < leadingSpaces); i++)
5623 {
5624 if (!isWhiteSpace(currentLine[i])) // don't delete any text
5625 {
5626 if (i < continuationIncrementIn)
5627 leadingSpaces = i + tabIncrementIn;
5628 continuationIncrementIn = tabIncrementIn;
5629 break;
5630 }
5631 if (currentLine[i] == '\t')
5632 continuationIncrementIn += tabSize - 1 - ((continuationIncrementIn + i) % tabSize);
5633 }
5634
5635 if ((int) continuationIncrementIn == tabIncrementIn)
5636 charNum = i;
5637 else
5638 {
5639 // build a new line with the equivalent leading chars
5640 string newLine;
5641 int leadingChars = 0;
5642 if ((int) leadingSpaces > tabIncrementIn)
5643 leadingChars = leadingSpaces - tabIncrementIn;
5644 newLine.append(leadingChars, ' ');
5645 newLine.append(currentLine, i, len - i);
5646 currentLine = newLine;
5647 charNum = leadingChars;
5648 if (currentLine.length() == 0)
5649 currentLine = string(" "); // a null is inserted if this is not done
5650 }
5651 if (i >= len)
5652 charNum = 0;
5653 }
5654 return;
5655}
5656
5657/**
5658 * Determine if a header is a closing header

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected