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

Method getPreviousWord

astyle/src/ASFormatter.cpp:5177–5196  ·  view source on GitHub ↗

* get the previous word on a line * the argument 'currPos' must point to the current position. * * @return is the previous word or an empty string if none found. */

Source from the content-addressed store, hash-verified

5175 * @return is the previous word or an empty string if none found.
5176 */
5177string ASFormatter::getPreviousWord(const string &line, int currPos) const
5178{
5179 // get the last legal word (may be a number)
5180 if (currPos == 0)
5181 return string();
5182
5183 size_t end = line.find_last_not_of(" \t", currPos - 1);
5184 if (end == string::npos || !isLegalNameChar(line[end]))
5185 return string();
5186
5187 int start; // start of the previous word
5188 for (start = end; start > -1; start--)
5189 {
5190 if (!isLegalNameChar(line[start]) || line[start] == '.')
5191 break;
5192 }
5193 start++;
5194
5195 return (line.substr(start, end - start + 1));
5196}
5197
5198/**
5199 * check if a line break is needed when a closing bracket

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected