Consume up to |max_len| characters and put them in |token_chars|. A delimiter is expected. The resulting string is NUL-terminated.
| 248 | // Consume up to |max_len| characters and put them in |token_chars|. A |
| 249 | // delimiter is expected. The resulting string is NUL-terminated. |
| 250 | void NextN(char token_chars[9], size_t max_len) { |
| 251 | assert(max_len < 9); |
| 252 | |
| 253 | for (size_t i = 0; i <= max_len; ++i) { |
| 254 | char c = Next(); |
| 255 | if (IsSpace(c)) { |
| 256 | token_chars[i] = '\0'; |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | token_chars[i] = c; |
| 261 | if (!isxdigit(c)) { |
| 262 | ParseError("encountered non-hex character"); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // If space is not reached before the maximum number of characters where |
| 267 | // consumed, that's an error. |
| 268 | ParseError("expected delimiter (space or comma)"); |
| 269 | token_chars[max_len] = '\0'; |
| 270 | } |
| 271 | |
| 272 | // Consume one hex digit. |
| 273 | char NextHexDigit() { |