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

Method unindentLine

astyle/src/ASEnhancer.cpp:727–771  ·  view source on GitHub ↗

* unindent a line by a given number of tabsets * by erasing the leading whitespace from the line argument. * * @param line a reference to the line to unindent. * @param unindent the number of tabsets to erase. * @return the number of characters erased. */

Source from the content-addressed store, hash-verified

725 * @return the number of characters erased.
726 */
727int ASEnhancer::unindentLine(string &line, int unindent) const
728{
729 size_t whitespace = line.find_first_not_of(" \t");
730
731 if (whitespace == string::npos) // if line is blank
732 whitespace = line.length(); // must remove padding, if any
733
734 if (whitespace == 0)
735 return 0;
736
737 size_t charsToErase = 0;
738
739 if (forceTab && indentLength != tabLength)
740 {
741 // replace tab indents with spaces
742 convertForceTabIndentToSpaces(line);
743 // remove the space indents
744 size_t spaceIndentLength = line.find_first_not_of(" \t");
745 charsToErase = unindent * indentLength;
746 if (charsToErase <= spaceIndentLength)
747 line.erase(0, charsToErase);
748 else
749 charsToErase = 0;
750 // replace leading spaces with tab indents
751 convertSpaceIndentToForceTab(line);
752 }
753 else if (useTabs)
754 {
755 charsToErase = unindent;
756 if (charsToErase <= whitespace)
757 line.erase(0, charsToErase);
758 else
759 charsToErase = 0;
760 }
761 else // spaces
762 {
763 charsToErase = unindent * indentLength;
764 if (charsToErase <= whitespace)
765 line.erase(0, charsToErase);
766 else
767 charsToErase = 0;
768 }
769
770 return charsToErase;
771}
772
773
774} // end namespace astyle

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected