refills the buffer */
| 305 | |
| 306 | /* refills the buffer */ |
| 307 | static int BREFILL(p_ply ply) { |
| 308 | /* move untouched data to beginning of buffer */ |
| 309 | size_t size = BSIZE(ply); |
| 310 | memmove(ply->buffer, BFIRST(ply), size); |
| 311 | ply->buffer_last = size; |
| 312 | ply->buffer_first = ply->buffer_token = 0; |
| 313 | /* fill remaining with new data */ |
| 314 | size = fread(ply->buffer+size, 1, BUFFERSIZE-size-1, ply->fp); |
| 315 | /* place sentinel so we can use str* functions with buffer */ |
| 316 | ply->buffer[BUFFERSIZE-1] = '\0'; |
| 317 | /* check if read failed */ |
| 318 | if (size <= 0) return 0; |
| 319 | /* increase size to account for new data */ |
| 320 | ply->buffer_last += size; |
| 321 | return 1; |
| 322 | } |
| 323 | |
| 324 | /* We don't care about end-of-line, generally, because we |
| 325 | * separate words by any white-space character. |
no outgoing calls
no test coverage detected