| 120 | } |
| 121 | |
| 122 | std::string first_word(std::string& str, size_t start) { |
| 123 | // If start is (at least) the length of str, then next_word_start is |
| 124 | // negative, so there's no word, so return "" |
| 125 | if (start >= str.length()) return ""; |
| 126 | const std::string chars = "\t\n\v\f\r "; |
| 127 | size_t next_word_start = str.find_first_not_of(chars, start); |
| 128 | size_t next_word_end = str.find_first_of(chars, next_word_start); |
| 129 | assert(next_word_start != std::string::npos); |
| 130 | return str.substr(next_word_start, next_word_end - next_word_start); |
| 131 | } |
no test coverage detected