| 171 | } |
| 172 | |
| 173 | bool istream_real::readToken(string& token) { |
| 174 | skipWhitespace(); |
| 175 | |
| 176 | if (mPos >= mBufferLen && fl::available() == 0) { |
| 177 | mFailed = true; |
| 178 | return false; |
| 179 | } |
| 180 | |
| 181 | // If buffer is empty but data is available, read a line |
| 182 | if (mPos >= mBufferLen && fl::available() > 0) { |
| 183 | if (!readLine()) { |
| 184 | mFailed = true; |
| 185 | return false; |
| 186 | } |
| 187 | skipWhitespace(); |
| 188 | } |
| 189 | |
| 190 | // Read until whitespace or end of buffer |
| 191 | token.clear(); |
| 192 | while (mPos < mBufferLen && |
| 193 | mBuffer[mPos] != ' ' && mBuffer[mPos] != '\t' && |
| 194 | mBuffer[mPos] != '\n' && mBuffer[mPos] != '\r') { |
| 195 | // Explicitly append as a character string to avoid fl::u8->number conversion |
| 196 | char ch[2] = {mBuffer[mPos], '\0'}; |
| 197 | token.append(ch, 1); |
| 198 | mPos++; |
| 199 | } |
| 200 | |
| 201 | return !token.empty(); |
| 202 | } |
| 203 | |
| 204 | istream_real& istream_real::operator>>(string& str) { |
| 205 | if (!readToken(str)) { |