| 560 | Return a pointer to the line, or NULL if it is not found in the file. */ |
| 561 | |
| 562 | static struct cstring * |
| 563 | find_line (intmax_t linenum) |
| 564 | { |
| 565 | if (head == NULL && !load_buffer ()) |
| 566 | return NULL; |
| 567 | |
| 568 | if (linenum < head->start_line) |
| 569 | return NULL; |
| 570 | |
| 571 | for (struct buffer_record *b = head;;) |
| 572 | { |
| 573 | if (linenum < b->start_line + b->num_lines) |
| 574 | { |
| 575 | /* The line is in this buffer. */ |
| 576 | struct line *l; |
| 577 | idx_t offset; /* How far into the buffer the line is. */ |
| 578 | |
| 579 | l = b->line_start; |
| 580 | offset = linenum - b->start_line; |
| 581 | /* Find the control record. */ |
| 582 | while (offset >= CTRL_SIZE) |
| 583 | { |
| 584 | l = l->next; |
| 585 | offset -= CTRL_SIZE; |
| 586 | } |
| 587 | return &l->starts[offset]; |
| 588 | } |
| 589 | if (b->next == NULL && !load_buffer ()) |
| 590 | return NULL; |
| 591 | b = b->next; /* Try the next data block. */ |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | /* Return true if at least one more line is available for input. */ |
| 596 |
no test coverage detected